Boundary condtions for an index reduced DAE system using ode solvers

13 views (last 30 days)
Hey,
so i have the following set of differential equations. Its called the poisson nerst planck equation and i am trying to solve it using the ode solvers of matlab.
with the boundary conditions for are neuman boudnary conditions
(it depends on i)
and for ϕ are dirichlet boundary conditions
Now I have allready tried to formulate this problem into a system of frist oder differential equation as follows:
Now i insert and in and solve for
The complete ode system should consist of these 3 first oder equations now:
with boundary conditions:
as you can see I have only 3 first oder equations but 4 boundary conditions. aditionally i dont have boundary conditions for for each but rather two boundary conditions for and two boudnary condition for .
Now i am clueless on how to implement the boundary conditions for this system of equations with a suitible ode solver for matlab. Is there a way of implementing two dirichlet and two neuman boundary conditions?
As an extra. I want to solve this set of equations for 3 adjacient regions within the overall domain of as , where for and and for . This gives the problem a stiff character becasue almost instantanious increas of at these internal regions.
  10 Comments
Torsten
Torsten on 3 Mar 2023
Edited: Torsten on 3 Mar 2023
ode15s solves initial value problems, not boundary value problems.
You have a boundary value problem.
That's why you have to use bvp4c or bvp5c.
Or program your own code.
Berat Cagan Türkmen
Berat Cagan Türkmen on 3 Mar 2023
%parameters
DH = 3.33*10^-9;
DHM = 3.5*10^-10;
F = 96485;
I = 100;
R = 8.314;
T = 300;
f = F/(R*T);
zH = 1;
RH =I/(zH*F*DH);
PHI = 10;
PHIM = 1;
p = [DH DHM F I R T f zH RH PHI PHIM];
%mesh
N = 100; %step size
L= 0.005; %chanel width in m
dx = L/N; %step size in m
xmesh = [0:dx:3*L];
%initial condition
yinit = [100;1;0;0];
sol = bvpinit(xmesh,yinit);
%solver
%sol = bvp5c(@(x,y,r) fun(x,y), @bc, sol);
eps = 1;
for i = 2:13
eps = eps/10;
sol = bvp5c(@(x,y,r) fun(x,y,eps), @bc, sol);
end
%plot
plot(sol.x,sol.y(1,:),sol.x,sol.y(3,:));
ylabel('y1(x)')
function dydt = fun(x,y,eps)
%parameters
DH = 3.33*10^-9;
DHM = 3.5*10^-10;
F = 96485;
I = 0.1;
R = 8.314;
T = 300;
f = F/(R*T);
zH = 1;
RH =I/(zH*F*DH);
PHI = 10;
PHIM = 1;
%eps = 1e1;
L=0.015;
dydt=zeros(4,1);
if x<=L/3
zfix = 0;
cfix = 0;
dydt(1)=y(2);
dydt(2)=-zH*f*y(1)*y(4)+zH*f*(F/eps)*(zH*y(1))+zfix*cfix;
dydt(3)=y(4);
dydt(4)=zH*f*(F/eps)*(zH*y(1))+zfix*cfix;
elseif (x >= L/3) && (x <= 2/3*L)
zfix = 1;
cfix = 2;
dydt(1)=y(2);
dydt(2)=-zH*f*y(1)*y(4)+zH*f*(F/eps)*(zH*y(1))+zfix*cfix;
dydt(3)=y(4);
dydt(4)=zH*f*(F/eps)*(zH*y(1))+zfix*cfix;
elseif (x >= 2/3*L) && (x <= L)
zfix = 0;
cfix = 0;
dydt(1)=y(2);
dydt(2)=-zH*f*y(1)*y(4)+zH*f*(F/eps)*(zH*y(1))+zfix*cfix;
dydt(3)=y(4);
dydt(4)=zH*f*(F/eps)*(zH*y(1))+zfix*cfix;
end
end
function res = bc(YL,YR) % boundary conditions
DH = 3.33*10^-9;
DHM = 3.5*10^-10;
F = 96485;
I = 10;
R = 8.314;
T = 300;
f = F/(R*T);
zH = 1;
RH =I/(zH*F*DH);
PHI = 10;
PHIM = 1;
res = [YL(2)+RH
YR(2)
YL(3)
YR(3)-4
];
end
%-------------------------------------------
so i tried to implemnt the problmem but i am not getting satisfying results.
the variable eps is around 10^-12 which is suposed to cause an almost instantanious increase at the internal interfaces. (like the jump condition from my other post). Due to the high eps value the problem becomes stiff.
I tried to iteratively increase the value of eps as shown in this docuentation:
but with no success.
Are there any other ways i can improve the solvability?

Sign in to comment.

Answers (0)

Products


Release

R2019b

Community Treasure Hunt

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

Start Hunting!