pdepe help! (PDE solver)
Show older comments
Hello, I need some help with differential equation solving in MATLAB. i got the following equation: (f is a function of two variables: distance x and time t)
df(x,t)/dt = (x - f(x,t))/(f'(x,t)) - x
where f'(x,t) is the derivative of f in respect to x. i wrote the function as: (by multiplying both sides with df/dx)
(df/dt) * (df/dx) = x-f - x*(df/dx)
i am using the MATLAB pdepe function to solve the equation and i keep receiving the following error:
"Warning: Failure at t=3.221102e-001. Unable to meet integration tolerances without reducing the step size below the smallest value allowed (8.881784e-016) at time t. > In ode15s at 747 In pdepe at 317 In solve at 11
Warning: Time integration has failed. Solution is available at requested time points up to t=3.201601e-001."
Can someone help me??
This is my code:
%%defining equation
function [c,f,s] = eqn1(x,t,u,DuDx)
c=DuDx;
f=-x*u;
s=x;
end
%%initial condition
function value = initial1(x)
value=0.5*(x^2);
end
%%boundary conditions
function [pl,ql,pr,qr] = bc1(xl,ul,xr,ur,t)
pl=ul;
ql=0;
pr=ur-1;
qr=0;
end
%PDE1: MATLAB script
%solutions to the PDE stored in eqn1.m
close all; clc; clear all; clc;
m=0;
options=odeset('NonNegative',[]);
%Define solution
x = linspace(0,1,100);
t = linspace(0,20,20*100);
%Solve the PDE
u = pdepe(m,@eqn1,@initial1,@bc1,x,t,options);
%Plot solution
surf(x,t,u);
title('Surface plot of solution.');
xlabel('Distance x');
ylabel('Time t');
Accepted Answer
More Answers (2)
Star Strider
on 18 Aug 2012
2 votes
I suggest you set a vector for tspan and experiment with it until you see what your function is doing and why it is crashing at that time. (The solver will evaluate the function at times other than those in the tspan vector. However, in my experience, you can use tspan to avoid such singularities if the vector elements aren't too close to them.)
Another possibility is to use the 'Events' option in odeset to do what you can to avoid what may be a singularity. It depends on how important the time in the region of 0.322 is to you.
4 Comments
Joe
on 18 Aug 2012
Star Strider
on 18 Aug 2012
Edited: Star Strider
on 18 Aug 2012
I suggest replacing t in your pdepe call with something like tvct defined as:
tvct = 0 : 0.1 : 5;
or some such, depending on the times over which you want your functon to be integrated. That would produce time values for the function to integrate specifically at 0.3 and 0.4, avoiding the discontinuity or singularity in the region of 0.322. That strategy has worked for me in the past.
I've only used 'Events' once and not recently. I refer you to odeset for details. However depending on what you want to accomplish with your integration (for instance how important the time around 0.322 is in your application), it might be something to consider.
Be assured that your question is definitely not stupid.
Joe
on 19 Aug 2012
Hari
on 6 Jul 2013
Dear Star, I also faced the same problem as it is, So as you suggested, i change the time span and also xspan. But the warning still gives indication that it cant be integrated at the value in which i change them into. So, do you have other suggestion ? Thank you
Joe
on 19 Aug 2012
0 votes
Categories
Find more on PDE Solvers in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!