I am trying to solve the following set of 2nd order non-linear and coupled ODEs:
0 = ??2 ?″(??) ? ?? ?′(??) + ??2 ??(??)2 [1??(??)],
0 = ??2 ??″(??) + ?? ??'(??) ? ?? ??2 ??(??) [??(??)2 + ??(??)2 ? 2],
0 = ??2 ??″(??) + ?? ??′(??) ? (1/2) ??(??) [1??(??)]2 ? ?? ??2 ??(??) [??(??)2 + ??(??)2 ? 2].
(I'm sorry EQs do not look beautiful. I'm used to LaTeX syntax only). Well, besides the equations, I have the following Boundary Conditions:
f'(0) = 0, f'(x → ∞) = 0. I also know that f (x → ∞) = 1 ,
h(0) = 0, h(x → ∞) = 1 ,
g(0) = 0, g(x → ∞) = 1 .
Moreover, I also expect the first derivatives h'(x)
, f'(x)
, and g'(x)
to go to zero for some finite value of x
and then, just stay zero. That is, I know my solution must reach the asymptotic values and remain constant afterwards. In other words, I know the functions h(x)
, f(x)
and g(x)
must 'saturate'.
Using MATLAB, I have tried the following solution:
xmin=1e-3;
xmax=50;
guess = [ 1 1 1 0 0 0];
xmesh = linspace(xmin,xmax,1e5);
solinit = bvpinit(xmesh,guess);%The last vector is my guess.
options = bvpset('RelTol',1e-5,'NMax',5e6);
sol = bvp5c(@deriv, @bcs, solinit, options);
Sxint = deval(sol,xmesh);
figure
plot(sol.x(1,:),sol.y(1,:),'k-');
hold on
plot(sol.x(1,:),sol.y(2,:),'m-');
hold on
plot(sol.x(1,:),sol.y(3,:),'k-')
hold off
axis([0 xmax -0.2 1.5])
function dydx = deriv(x,y)
lambda=0.5;
dydx= [ y(4) %The vector y() was keeping the following results: y=(h, f, g, h', f', g')
y(5)
y(6)
(1/x)*y(4) - (y(3)^2)*(1-y(1))
-(1/x)*y(5) + (lambda)*y(2)*(y(2)^2 + y(3)^2 - 2)
-(1/x)*y(6) + (1/(2*x^2))*y(3)*((1-y(1))^2) + (lambda)*y(3)*(y(2)^2 + y(3)^2 - 2)];
end
% boundary conditions
function res = bcs(ya,yb)
res = [ya(1)
yb(1) - 1
yb(2) - 1
ya(3)
yb(3) - 1
ya(5)];
end
Well, up to some minor typos I could make while copying and pasting my code, this code gives me a solution that only takes the desired value (of 'infinity') at the boundary. I can use larger and larger values of my xmax
and even so, the solution never starts to saturate at its value for infinity.
I tried using a better guess, based on the analytical solution of these equations for a small value of x
, but nothing is giving me a good solution. And this is the reason I am asking for some advice here. What do you think? Is MATLAB incapable of solving this because of the 1/x2
in the third ODE?
Thanks!
question from:
https://stackoverflow.com/questions/65928938/lack-of-convergence-in-matlabs-bvp5c