pdepe help! (PDE solver)

9 views (last 30 days)
Joe
Joe on 18 Aug 2012
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

Jose Jeremias Caballero
Jose Jeremias Caballero on 19 Aug 2012
function edp11
close all; clc;
m=0;
options=odeset('NonNegative',[]);
x = linspace(0,1,30);
t = linspace(0,20,30);
u = pdepe(m,@eqn1,@initial1,@bc1,x,t,options);
surf(x,t,u(:,:,1));
title('Surface plot of solution.');
xlabel('Distance x');
ylabel('Time t');
function [c,f,s] = eqn1(x,t,u,DuDx)
c=DuDx;
f=-x*u;
s=x;
%%initial condition
function value = initial1(x)
value=0.5*(x^2);
%%boundary conditions
function [pl,ql,pr,qr] = bc1(xl,ul,xr,ur,t)
pl=ul;
ql=0;
pr=ur-1;
qr=0;
  1 Comment
Hari
Hari on 5 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

Sign in to comment.

More Answers (2)

Star Strider
Star Strider on 18 Aug 2012
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
Joe on 19 Aug 2012
Thanks.
Hari
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

Sign in to comment.


Joe
Joe on 19 Aug 2012
thanks once again! much appreciated

Community Treasure Hunt

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

Start Hunting!