How to solve a system of parabolic partial differential equations in time and 1 D space

1 view (last 30 days)
Hi,
I cannot seem to solve the PDF in the figures below. This is the code I have but it produces the wrong graphs:
function New
m=0;
x=0:0.5:15;
t=1:100:28800;
sol = pdepe(m,@pdefun,@icfun,@bcfun,x,t);
u1=sol(:,:,1);
u2=sol(:,:,2);
surf(x,t,u1)
title('u1(x,t)')
xlabel('Distance x')
ylabel('Time t')
figure
surf(x,t,u2)
title('u2(x,t)')
xlabel('Distance x')
ylabel('Time t')
function [c,f,s]=pdefun(x,t,u,DuDx)
P=1200;
R=0.208;
cv=0.313;
rho=7.5;
v=0.3;
A=70;
mdot=1.2;
k=0.016/1000;
alph=0.5;
rhoG=1600;
cG=0.7;
kG=0.7/1000;
c=[((P*cv/R)/u(1));(rhoG*cG)];
f=[((k*DuDx(1))-((P*cv/R)*(mdot*R/(P*A))));(kG*DuDx(2))];
s=[(u(2)-u(1));(u(1)-u(2))]*alph;
function u0=icfun(x)
u0=[300;300];
function[pl,ql,pr,qr]=bcfun(xl,ul,xr,ur,t)
pl = [ul(1)-773; 0];
ql = [0; 1];
pr = [0; 0];
qr = [1; 1];
I think my boundary conditions are incorrect but I don't know how to fit them.
I would appreciate any help with this problem, thank you in advance.
<<
>>
%

Accepted Answer

Torsten
Torsten on 22 Nov 2017
One mistake in your settings:
f = [k*DuDx(1) ; kG*DuDx(2)];
s = [(u(2)-u(1))*alph-cv*mdot/A*DuDx(1);(u(1)-u(2))*alph];
And maybe in your boundary condition for T_A at x=0, you will need a ramp that linearly increases the temperature from 300 K to 773 K in, say, one minute.
Best wishes
Torsten.
  7 Comments
Torsten
Torsten on 22 Nov 2017
Edited: Torsten on 22 Nov 2017
Increasing the number of discretization points together with the ramp for a=100 solved the problem:
x = linspace(0,15,3000);
Best wishes
Torsten.
Lucy
Lucy on 22 Nov 2017
Hi Torsten,
Thank you so much for your help. It is now working how I believe it should.
Lucy

Sign in to comment.

More Answers (0)

Categories

Find more on Programming 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!