Coupeling of three equations BVP

3 次查看(过去 30 天)
Thanh Hoang
Thanh Hoang 2024-6-17
评论: Torsten 2024-6-17
Dear all,
I have a maths understanding problem with the following code. I tried to couple three ode equations with another and solved them with a bvp solver. As for the boundary conditions I applied all (just as an example) to the second derivative since in my problem I want to set Newmann boundary conditions.
However, what I noticed is that I am not able to give the third equation a dependence on C. The system is only solvable with Eq. dydx(6) decoupled from C.
How would I be able to solve the system with including a dependence of Eq. dydx(6) with C. Is a boundary condition to dydx(1), dydx(3) or dydx(5) nessecary in all cases if I want to solve this kind of system? I hope somebody more gifted in maths can help me with that.
Thanks for you help!
clear all;
close all;
clc;
xmesh = linspace(0, 1, 100);
sol_init = bvpinit(xmesh, [0 0 1 0 0 1]);
sol = bvp4c(@ode, @bcfun, sol_init);
plot(sol.x, sol.y)
function dydx = ode(x,y)
A = y(1);
B = y(3);
C = y(5);
S = exp(A*B)-C;
dydx(1) = y(2);
dydx(2) = S;
dydx(3) = y(4);
dydx(4) = -S;
dydx(5) = y(6);
dydx(6) = exp(A+B);
% dydx(6) = C;
end
function res = bcfun(ya, yb);
res(1) = ya(2);
res(2) = yb(2);
res(3) = ya(4);
res(4) = yb(4);
res(5) = ya(6);
res(6) = yb(6);
end

回答(1 个)

James Blanchard
James Blanchard 2024-6-17
I get errors with both choices for dydx(6). They seem to result from your initial guesses (sol_init). Try something different.
  2 个评论
Thanh Hoang
Thanh Hoang 2024-6-17
Hey sorry, yes you are right! I had a different expresion for dydx(6) originally:
dydx(6) = exp(A+B)
Here the corrected code
clear all;
close all;
clc;
xmesh = linspace(0, 1, 100);
sol_init = bvpinit(xmesh, [0 0 1 0 0 1]);
sol = bvp4c(@ode, @bcfun, sol_init);
Warning: Unable to meet the tolerance without using more than 1666 mesh points.
The last mesh of 892 points and the solution are available in the output argument.
The maximum residual is 0.0520983, while requested accuracy is 0.001.
plot(sol.x, sol.y)
function dydx = ode(x,y)
A = y(1);
B = y(3);
C = y(5);
S = exp(A*B)-C;
dydx(1) = y(2);
dydx(2) = S;
dydx(3) = y(4);
dydx(4) = -S;
dydx(5) = y(6);
dydx(6) = exp(A+B);
% dydx(6) = C;
end
function res = bcfun(ya, yb);
res(1) = ya(2);
res(2) = yb(2);
res(3) = ya(4);
res(4) = yb(4);
res(5) = ya(6);
res(6) = yb(6);
end
Torsten
Torsten 2024-6-17
There is no solution from bvp4c for
dydx(6) = exp(A+B);
either (see above).
The reason is that your equations only fix the derivative of y(5). So in my opinion, y(5) is only fixed by your equations up to an additive constant.

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Boundary Value Problems 的更多信息

产品


版本

R2023b

Community Treasure Hunt

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

Start Hunting!

Translated by