How to control times at which PDE Toolbox solves a parabolic equation?

10 views (last 30 days)
I am solving a 1D groundwater flow equation with time-dependent forcing using PDE Toolbox. I managed to input the time-dependent forcing (which is a vector of data values at specific times) into the PDE Toolbox using the following function:
function f = fcoeff(t)
W = importdata('Rainfall_daily.mat'); % the forcing
nt=length(W);
tW = 0:nt-1; % values of time at which forcing data is available
W_intrp = interp1(tW,W,t,'linear'); % interpolated values of forcing at
times used by toolbox
disp([t, W_intrp])
f = W_intrp;
However, the PDE toolbox misses some data points in the vector 'W' because it sometimes takes too large time steps. This does not yield correct results at the time values I ask it to plot the results at. That is why I want to force the PDE toolbox to solve the parabolic PDE at time values that I specify. This will also help me avoid using interp1 in the above function.
Thanks, Abrar

Accepted Answer

Bill Greene
Bill Greene on 4 Mar 2014
I'm afraid I wasn't able to run your example. I believe that your fcoeff function has an error in it.
I did take a look at the Rainfall_daily.mat file. If I am right in assuming that the first column is some kind of time measure and the second is the function value, it looks like the function is extremely discontinuous.
The ODE solver used by the PDE Toolbox parabolic function has an option, MaxStep, that allows you to specify the maximum step size used during the solution. It might be possible to improve the solution you are getting by setting this to a fraction of the delta_time of your data.
Unfortunately, there is no simple way to do this without editing the PDE Toolbox parabolic function. If you edit this function (I suggest making a copy of the original first), you will see where the ode15s function is being called and where the other options to ode15s are being set. Adding the MaxStep option should be straightforward. I think this change will cause the parabolic function to execute much slower so I suggest you remove this change when you are through with this particular example.
Good luck!
Bill

More Answers (1)

Bill Greene
Bill Greene on 12 Feb 2014
>This does not yield correct results at the time values I ask it to plot the results
So, why don't you request results at the time of each point in your W-vector?
You could also experiment with setting smaller values of the rtol and atol optional input arguments to the parabolic function.
Regardless, you will still need the interp1() function to perform interpolation because the function ode15s, the ODE solver used by parabolic(), will call your function at arbitrary times between the initial and final times.
Bill
  3 Comments
Bill Greene
Bill Greene on 12 Feb 2014
So if I understand you right, you are including every time in your W vector in the tlist argument to parabolic, but parabolic is not calling your f-coefficient evaluator at those times?
I would need to investigate this further. If you can post your complete example, (using the paper-clip icon in the editor dialog below), I'll take a look.
Bill
Abrar Habib
Abrar Habib on 28 Feb 2014
Edited: Abrar Habib on 1 Mar 2014
Thanks for your reply Bill and sorry for the late response.
I have been playing around with the atol and rtol values and this helps by reducing the time step values (obviously)and hence taking into account most rainfall events, however as I mentioned earlier this introduces inaccuracies to my system where, due to interpolation in the fcoeff function, additional rainfall is accounted for. So after days of playing around with the fcoeff function to try and reduce this inaccuracy, I think I am back to square one where I think the solution to this problem is to dictate the times at which PDE Tool performs computation (if this is possible).
I have attached both the PDE model and a function, in addition to the fcoeff pasted in the first post, that is used by the model, and the rainfall data file I use.
Thanks for your effort, Abrar

Sign in to comment.

Community Treasure Hunt

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

Start Hunting!