Insert f coefficient in pdetool

2 ビュー (過去 30 日間)
NaN1988
NaN1988 2014 年 4 月 23 日
コメント済み: NaN1988 2014 年 4 月 27 日
Hi all,
I am using pdetool to solve the following parabolic partial differential equation:
y = parabolic(y0,time,b,p,e,t,c,a,f,d)
I need to indicate that the coefficient f depends on the solution "y" and a constant "F" calculated in the previous step. It is clear how to do it when f depends on (x,y,t), however, I don't know how to introduce another parameter. I would need something like
y = parabolic(y0,time,b,p,e,t,c,a,'fcoeff(y,F)',d)
where fcoeff(y,F) is a user function. However, I keep getting this error
Undefined function or variable 'F'
It only recognizes the variables x,y,t. Any suggestion?

回答 (1 件)

Bill Greene
Bill Greene 2014 年 4 月 27 日
Do you calculate F in fcoeff? If so, you can make it a global variable and it will retain its value between calls to fcoeff.
One complicating factor is that the parabolic function uses the variable time step ODE solver, ode15s, internally. So fcoeff gets called at unevenly-spaced and possibly non-monotonically increasing time points. You may need to save several values of F along with the times where they are computed and select a particular one or interpolate between values to obtain the value of F you need.
Bill
  1 件のコメント
NaN1988
NaN1988 2014 年 4 月 27 日
Thanks for the answer Bill,
The problem is a particle-cell simulation. I have a field represented in a grid, and particles that move off-lattice. These two dynamics are linked because at each time step particles take properties from the grid (extrapolating grid values) and move. At each time step the field is solved; nodes without a particle in the surroundings have F=0, whereas for nodes with particles in the surrounings F=au/(u+1), where a depends on the particle positions. At this moment I am doing the following:
Solve this equation assuming F=0 for all nodes using parabolic in only one time step dt
du/dt-grad(c*grad(u))=0
Recalculate u for the nodes with non-zero F, so du = au/(u+1)*dt for these nodes.
In this way, the command parabolic is inside a for loop and F is recalculated at each step, so I cannot declared it global variable.
I don't really like this method, any suggestion?

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

カテゴリ

Help Center および File ExchangeMathematics and Optimization についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by