pdepe help! (PDE solver)

1 次查看(过去 30 天)
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');

采纳的回答

Jose Jeremias Caballero
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 个评论
Hari
Hari 2013-7-5
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

请先登录,再进行评论。

更多回答(2 个)

Star Strider
Star Strider 2012-8-18
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 个评论
Joe
Joe 2012-8-19
Thanks.
Hari
Hari 2013-7-6
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
Joe 2012-8-19
thanks once again! much appreciated

Community Treasure Hunt

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

Start Hunting!

Translated by