BVP5C multipoint boundary conditions sequence
Show older comments
Hello everyone,
I'm trying to solve a system of two coupled second order matrix (2x2) differential equations with multiple boundaries; 4 to be exact. While my code is working, the output is wrong from a physical perspective. I am using bvp5c and I'm wondering how to correctly write the residual vector. As my solution vector has 16 components and I have three regions, the solutions passed to bcfun (YL and YR) are 3x16 matrices; therefore the residual vector should have 48 components.
I have 12 boundary conditions; 2 at each outer boundary and 4 at each inner interface. Currently I stack them in the residual vector as follows:
% at -G
res(1:4) = reshape(u1_L + so1, [4, 1]);
res(5:8) = reshape(tu1_L + tso1 , [4, 1]);
% at -L/2
res(9:12) = reshape(gamma1_R - gamma2_L, [4, 1]);
res(13:16) = reshape(tgamma1_R - tgamma2_L, [4, 1]);
res(17:20) = reshape(u1_R - u2_L + so2 , [4, 1]);
res(21:24) = reshape(tu1_R - tu2_L + tso2, [4, 1]);
% at L/2
res(25:28) = reshape(gamma2_R - gamma3_L, [4, 1]);
res(29:32) = reshape(tgamma2_R - tgamma3_L, [4, 1]);
res(33:36) = reshape(u3_L - u2_R + so3, [4, 1]);
res(37:40) = reshape(tu3_L - tu2_R + tso3, [4, 1]);
% at G
res(41:44) = reshape(u3_R + so4, [4, 1]);
res(45:48) = reshape(tu3_R + tso4, [4, 1]);
where gamma and tgamma are the functions I'm looking for and u, tu are their derivatives respectively. So my question is if the order matters at all; I assumed I should go from left to right in the x coordinate and also first write the functions bc and then derivatives bc. To reiterate, is there a general rule when writing down the residual vector?
2 Comments
We need a mathematical description of the problem (equations, boundary conditions) and the complete code in order to help.
Did you study this page and transfer it to your problem:
?
If you have 4 first-order differential equations and 3 regions, the matrices YL and YR will be of size 4x3.
kristjan
on 25 Oct 2024
Answers (0)
Categories
Find more on Boundary Value Problems in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
