# Insert f coefficient in pdetool

1 view (last 30 days)
NaN1988 on 23 Apr 2014
Commented: NaN1988 on 27 Apr 2014
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?

Bill Greene on 27 Apr 2014
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
NaN1988 on 27 Apr 2014
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
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?