Solve piecewise PDE system
8 ビュー (過去 30 日間)
古いコメントを表示
I am trying to solve a system of PDEs describing the diffusion and reaction of 4 different substances.
The reaction is as follows:
The concentration of E does not matter and is not calculated.
My eqn. system is set up as
as the system is symmetric, 
The initial conditions are defined piecewise, so that there are three different regions with differing concentrations initially.
The boundary condition is no flux over the edges of the system:
My code is
clear vars; close all;
DH = 9.31e-5; % cm^2 s^-1
DOH = 5.3e-5; % cm^2 s^-1
DDMP = 2.25e-5; % cm^2 s^-1
DAcetone = 1.28e-5; % cm^2 s^-1
T = 298; % K
global R
R = 3.144; % J K^-1 mol^-1
% concentration guesses
scale_factor = 3;
cDMP_A = 0.4*scale_factor; % mol L^-1
cDMP_B = 0*scale_factor;
cDMP_C = 0*scale_factor;
cOH_A = 0.35*scale_factor; % mol L^-1
cH_A = 1e-14/cOH_A;
cOH_B = 1e-7; % mol L^-1
cH_B = 1e-7;
cH_C = 0.251*scale_factor;
cOH_C = 1e-14/cH_C;
% define mesh
x = 0:0.001:1.379;
t = 0:0.001:60;
sol = pdepe(0, @(x, t, u, dudx)pdefunc(x, t, u, dudx, [DDMP; DAcetone; DH; DOH], T), @(x)pdeic(x, 0.1895, 1.1895, 1.379, cDMP_A, cH_A, cOH_A, cH_C, cOH_C), @pdebc, x, t);
% functions
function [c, f, s] = pdefunc(x, t, u, dudx, D, T)
global R
c = ones(4, 1);
f = D.*dudx;
s = [-7.32e10.*exp(-46200/(R.*T)).*u(1).*u(3); ...
7.32e10.*exp(-46200/(R.*T)).*u(1).*u(3); ...
-1e20.*u(3).*u(4);
-1e20.*u(3).*u(4)];
end
function u0 = pdeic(x, xa, xb, xc, cDMP_A, cH_A, cOH_A, cH_C, cOH_C)
if x >= 0 && x <= xa
u0 = [cDMP_A; ...
0; ...
cH_A; ...
cOH_A];
elseif x > xa && x <= xb
u0 = [0; ...
0; ...
1e-7; ...
1e-7];
elseif x > xb && x <= xc
u0 = [0; ...
0; ...
cH_C;
cOH_C];
end
end
function [pl, ql, pr, qr] = pdebc(xl, ul, xr, ur, t)
pl = [0; 0; 0; 0];
pr = [0; 0; 0; 0];
ql = [1; 1; 1; 1];
qr = [1; 1; 1; 1];
end
The output I get is
Warning: Failure at t=7.476760e-13. Unable to meet integration tolerances without reducing the step size below the smallest value allowed
(1.615587e-27) at time t.
Expected output: Solved PDE.
How can I change my code to let it calculate my concentrations successfully?
9 件のコメント
J. Alex Lee
2020 年 9 月 18 日
agree...i also wondered at first if your very sharp steps (in space) in the initial conditions will be problematic...what if you try smoothing out the IC into more sigmoidal shapes...do you get the same oscillations?
回答 (0 件)
参考
製品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

