Solving partial differential system

1 view (last 30 days)
Daniel Head
Daniel Head on 24 Mar 2019
Commented: m_p on 11 Oct 2019
Hello,
I am trying to sovle a modelling problem, however pdepe will not solve a mixed PDE system (as far as I know) with the following PDE's:
With the following initial conditions:
And boundary conditions:
A similar question was asked here: https://uk.mathworks.com/matlabcentral/answers/371313-error-in-solving-system-of-two-reaction-diffusion-equations this talks about the use of discretisation, something I am unsure of and I am unable to figure out how to use this code (suggested by Torsten) with my system.
Any help or codes would be greatly appreciated.
  5 Comments
Daniel Head
Daniel Head on 25 Mar 2019
Here is my code that I'm using, the main issue I have is I want to define q as u2 but I am unsure how to define it:
function Modelling1
m = 0;
x = [0 0.005 0.01 0.05 0.1 0.2 0.5 0.7 0.9 0.95 0.99 0.995 1];
t = [0 0.005 0.01 0.05 0.1 0.5 1 1.5 2];
sol = pdepe(m,@pdex4pde,@pdex4ic,@pdex4bc,x,t);
u1 = sol(:,:,1);
u2 = sol(:,:,2);
figure;
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] = pdex4pde(x,t,u,DuDx)
c = [1; 1];
Q=2.5; %mL min^-1
A_c=1.96e-5; %cm^2
u=Q/A_c;
e_b=0.368;
v=u/e_b;
A=35.13;
d_p=50e-6; %m
D_L=A*0.5*d_p*v;
k_max=0.18; %min^-1
S_1=0.6245;
S_2=2.071;
q_sat=94.72; %mg mL^-1
H_ref=246.8;
pH=7.5;
pH_ref=6;
N=0.5;
H_c=H_ref*(pH/pH_ref)^N
qst=H_c/(1+(H_c/q_sat));
qe=qst;
km=k_max*(S_1+(1-S_1)*(1-(qst/q_sat))^(S_2^2));
f = [D_L; 0] .* DuDx;
s = [-v*DuDx; km*(qe-u2)];
% --------------------------------------------------------------------------
function u0 = pdex4ic(x)
u10=1.2; %mg mL^-1
u20=0; %mg mL^-1
u0 = [u10; u20];
% --------------------------------------------------------------------------
function [pl,ql,pr,qr] = pdex4bc(xl,ul,xr,ur,t)
pl = [u1-pu2; ul(2)];
ql = [-1/v; 0];
pr = [1/DL; 0];
qr = [0; 1];
m_p
m_p on 11 Oct 2019
can u send me your final correct code i am facing some problem ?

Sign in to comment.

Accepted Answer

Torsten
Torsten on 25 Mar 2019
Edited: Torsten on 25 Mar 2019
s= [-v*DuDx(1)-psi*km*(qe-u(2)); km*(qe-u(2))];
function [pl,ql,pr,qr] = pdex4bc(xl,ul,xr,ur,t)
Q=2.5; %mL min^-1
A_c=1.96e-5; %cm^2
u=Q/A_c;
e_b=0.368;
v=u/e_b;
pu2 = ?;
pl = [ul(1)-pu2; 0.0];
ql = [-1/v; 1.0];
pr = [0; 0];
qr = [1.0; 1.0];
  7 Comments
Torsten
Torsten on 25 Mar 2019
In pdex4pde, you overwrite the two-element solution variable vector u by the setting
u=Q/A_c;
Daniel Head
Daniel Head on 25 Mar 2019
I have changed this variable name and now the system solves! Thank you!

Sign in to comment.

More Answers (0)

Categories

Find more on Partial Differential Equation Toolbox in Help Center and File Exchange

Products


Release

R2018b

Community Treasure Hunt

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

Start Hunting!