pdepe extract intermediate values

2 ビュー (過去 30 日間)
Guy Elisha
Guy Elisha 2022 年 6 月 27 日
編集済み: Torsten 2022 年 7 月 12 日
Hi everyone,
I am solving a pdes using the pdepe function, but I have an issue.
Suppose you want to solve for u, and have your c, f, and s. However, s includes some function g(u)
Suppose that g is a sigmoid function that depends on the neighboring node.
For instance, g(i) = u(i) - sig(u(i-1) - threshold)
That way, the value of u at point i depends on neighboring nodes of previous time steps.
To overcome this issue, I would like to extract all my values of u at each time step into a function, calculate g and return back to the regular itteration. Basically calulate g at each time step, feed it into the giv equation, and proceed in solving.
Is there a way for me to extract all the solutions for u at each time step?
Thank you!
  2 件のコメント
Torsten
Torsten 2022 年 6 月 28 日
編集済み: Torsten 2022 年 6 月 28 日
Is there a way for me to extract all the solutions for u at each time step?
No, only the u-value(s) in the actual grid point x(i).
And the fact that you need the values of u in neighbouring nodes of previous time steps makes your problem a delay pde - even more complicated.
Guy Elisha
Guy Elisha 2022 年 6 月 28 日
Hi, thanks for the response!
That is what I thought.
Also, sorry for being not clear, I dont need it in the previous time step but of neighboring nodes.
In my s term, I have s = (u * g) where g is a sigmoid function (g = tanh(u(i+1)-threshold)), so that if u ahead of the current node is greater than some threshold, g=1, and if u ahead of the current node is smaller than some threshold, g=-1.
Hence, s depends on u ahead of the current node (u(i+1))
To check that, I need basically all values of u at each time step.
Do you have a suggestion of how I can go around it?
Thanks again!

サインインしてコメントする。

採用された回答

Bill Greene
Bill Greene 2022 年 6 月 28 日
I have written a PDE solver, pde1dm, that has some similarities to pdepe and accepts the same input syntax as pdepe. Most input that is acceptable to pdepe will also work in pde1dm.
However pde1dm has some additional capabilities. If you pass the option vectorized='on' to pde1dm, your pde function will be passed a vector of x-values spanning your complete spatial domain along with u and DuDx matrices at these x values. This allows your pde function to, for example, evaluate an integral involving the solution over the complete spatial domain. (Note that if you use this vectorized option, your pde function is also expected to return c, f, and s matrices corresponding to all values in the x vector.) You may be able to use this capability for your particular application.
You can find more information and download pde1dm here.
  19 件のコメント
Guy Elisha
Guy Elisha 2022 年 7 月 11 日
Thanks! Yes I saw that. Maybe my question was worded wrong.
In pdepe you can include variables and structs,
ex: sol = pdepe(0,@goveqns,@ICs,@BCs,xspan,tspan,a, b, c).
Is this an option in pde1dm?
Torsten
Torsten 2022 年 7 月 11 日
編集済み: Torsten 2022 年 7 月 12 日
Pass extra arguments directly to the functions where they are needed, e.g.
sol = pdepe(0,@(x,t,u,dudx)goveqns(x,t,u,dudx,a,b,c),@ICs,@BCs,xspan,tspan)
That's the usual way in "modern" MATLAB and is also supported by pde1dm:

サインインしてコメントする。

その他の回答 (0 件)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by