My code is working fine until I try to increase the value of parameter phi1
, error such as
NDSolveValue::ndsz: At x == 0.23372152690117168`, step size is effectively zero; singularity or stiff system suspected.
starts to appear. Previously, I fixed this error in my code by employing this trick. However, this does not work anymore when i increase the value of parameter phi1
Clear["Global`*"]
(*constants*)
phi1 = 12;
KcKbRatio = 2;
DbDaRatio = 2;
DcDaRatio = 0.5;
Cref = 1;
lambda = 2;
aEnd = 0.95;
bEnd = 0.8;
cEnd = 0.6;
alpha = 1 - cEnd *Cref/lambda -
KcKbRatio*Cref/(KcKbRatio + 1)/DcDaRatio/lambda*aEnd ;
del = $MachineEpsilon;
(*sidenotes:
when lambda>Cref, graphs tend to look normal
*)
(*the system of ode and bcs*)
ode = {a''[x] + 2/x*a'[x] - phi1^2*(1 + KcKbRatio)*phi[x]*a[x] == 0,
b''[x] + 2/x*b'[x] + phi1^2/DbDaRatio*phi[x]*a[x] == 0,
phi''[x] + 2/x*phi'[x] -
KcKbRatio*phi1^2*Cref/DcDaRatio/lambda*phi[x]*a[x] == 0};
bcs = {a'[del] == 0, a[1] == aEnd , b'[del] == 0, b[1] == bEnd,
phi'[del] == 0, phi[1] == (lambda - cEnd *Cref)/lambda};
(*ndsolve*)
{asol, bsol, phisol} =
NDSolveValue[{ode, bcs}, {a, b, phi}, {x, del, 1}];
(*Dsolve*)
exactsol =
DSolve[{a''[x] + 2/x*a'[x] -
phi1^2*(1 + KcKbRatio)*(1 - cEnd*Cref/lambda)*a[x] == 0,
a'[0] == 0, a[1] == aEnd,
b''[x] + 2/x*b'[x] +
phi1^2/DbDaRatio*(1 - cEnd*Cref/lambda)*a[x] == 0, b'[0] == 0,
b[1] == bEnd}, {a[x], b[x]}, x];
(*Plot*)
Plot[{asol[x], bsol[x], phisol[x],
KcKbRatio*Cref/(KcKbRatio + 1)/DcDaRatio/lambda*asol[x] + alpha,
Evaluate[{a[x], b[x]} /. exactsol]}, {x, del, 1},
PlotLegends -> "Expressions"]
phi1 = 0.01
. Is it possible that you missed some part of your code? $\endgroup$v12
$\endgroup$