Non linear BVP using a shooting algoritm with MATLAB?

In summary: i just tried to change m =1 in the ulbound algorithm to m = 7*10^5 to get me closer to the other solution as you said and it worked 😀 🥳
  • #1
patric44
296
39
Homework Statement
solve the following non linear BVP using shooting method in Matlab ?
Relevant Equations
in the picture
hi guys
i was trying to use this shooting algorithm from Xue and Chen Scientific Computing with MATLAB book :
1611949334990.png

1611949377160.png

to solve this non linear temperature distribution problem :
1611949447141.png

i checked my Matlab function multiple times but i am keep getting a nonsense graph for the temperature , can someone cheak what's wrong with my algorithm :
Matlab:
function [t,y] = nlbound(func,funcv,tspan,xof,tol,varargin)
t0 = tspan(1); tf = tspan(2) ; you = xof(1); yb = xof(2);
m=1 ; m0=0;
while(norm(m-m0)>tol), m0=m ;
    [t,v] = ode45(funcv,tspan,[ya;m;0;1],varargin{:});
    m = m0-(v(end,1)-yb)/v(end,3);
end
[t,y] = ode45(func,tspan,[ya;m],varargin{:});
end
the script for the problem :
Matlab:
k = 72;
h = 2000;
epsilon = 0.1;
sigma = 5.67e-8;
i = 2;
rho = 32e-8;
Tinf = 300;
D = 7.62e-5;
L = 4*10^-3;
a1 = (4*h)/(k*D);
a2 = (4*epsilon*sigma)/(k*D);
k = -(i^2*rho)/(k*((pi/4)*D^2)^2);
zeta = k-a1*Tinf-a2*Tinf^4;
% the problem was transformed to a simple form T'' = a1*T+a2*T^4+zeta
f1 = @(t,v)[v(2);a1*v(1)+(a2*v(1)^4)+zeta;v(4);(a1+(4*a2*v(1)^3))*v(3)];
f2 = @(t,x)[x(2);a1*x(1)+a2*x(1)^4+zeta];
x0f = [300,300];
xspan = [0,L];
opts = odeset;
opts.RelTol = 1e-10;
tol = 1e-8;
[t,y] = nlbound(f2,f1,[0,L],[300,300],tol,opts);
plot(t,y(:,1))
i will appreciate any help , thanks
 
Physics news on Phys.org
  • #2
I think the fact that the boundary condition at [itex]x = L/2[/itex] is on [itex]T'[/itex] rather than [itex]T[/itex] may be the problem; the algorithm given is for solving subject to [itex]y(b) = \gamma_b[/itex] rather than [itex]y'(b) = \gamma_b[/itex]. So you need to adapt the iteration in (7-6-14) accordingly.
 
  • #3
i assumed that since the temperature distribution is symmetric about x= L/2 , i would have T(0) = 300 and T(L) = 300 , isn't that right 🤔
 
  • #4
Does the solution you get satisfy the symmetry constraint?

The only way to enforce that constraint is, as the question suggests. to solve the problem on half of the wire.

You appear to have correctly implemented the algorithm, so if you're not getting the answer you expect then it must be some feature of the particular problem which is to blame. One possibility is that there are multiple solutions to the BVP on the whole rod and you are converging to one which is not the one you expect.
 
Last edited:
  • Like
Likes patric44
  • #5
pasmith said:
Does the solution you get satisfy the symmetry constraint?

The only way to enforce that constraint is, as the question suggests. to solve the problem on half of the wire.
the solution is symmetric ,but as you can see its nonsense :
plot.jpg
 
  • #6
I implemented this method in Python (using scipy.iintegrate.solve_ivp) and got the same result as you (below left, solid line). However I then solved the problem on the half-rod subject to [itex]T'(L/2) = 0[/itex], and got a more sensible result (below left, dashed line, and below right).

bvp.png


Plotting [itex]T(L|m)[/itex] against [itex]m[/itex] yields the following graph:

bvp2.png


From this, we can see that starting the iteration at [itex]m = 1[/itex] is the problem: it puts you to the left of the turning point, and takes you to the wrong solution. Starting with [itex]m \approx 7 \times 10^5[/itex] puts you on the right track. Unfortunately your text's implementation of nlbound doesn't provide a parameter to set an initial guess other than 1.
 
Last edited:
  • Like
  • Love
Likes PhDeezNutz and patric44
  • #7
pasmith said:
I implemented this method in Python (using scipy.iintegrate.solve_ivp) and got the same result as you (below left, solid line). However I then solved the problem on the half-rod subject to [itex]T'(L/2) = 0[/itex], and got a more sensible result (below left, dashed line, and below right).

View attachment 277141

Plotting [itex]T(L|m)[/itex] against [itex]m[/itex] yields the following graph:

View attachment 277147

From this, we can see that starting the iteration at [itex]m = 1[/itex] is the problem: it puts you to the left of the turning point, and takes you to the wrong solution. Starting with [itex]m \approx 7 \times 10^5[/itex] puts you on the right track. Unfortunately your text's implementation of nlbound doesn't provide a parameter to set an initial guess other than 1.
thank you so much i just tried to change m =1 in the ulbound algorithm to m = 7*10^5 to get me closer to the other solution as you said and it worked 😀 🥳
plot2.jpg

thank you so much you just made my day 🙂
 
Last edited:
  • Like
Likes PhDeezNutz

1. What is a shooting algorithm in MATLAB?

A shooting algorithm is a numerical method used to solve non-linear boundary value problems (BVPs) in MATLAB. It involves breaking down the BVP into a system of first-order ordinary differential equations, which can then be solved using an iterative process.

2. How does a shooting algorithm work?

A shooting algorithm works by guessing the initial conditions for the system of differential equations and then solving them numerically. The solution is then checked against the boundary conditions, and if they are not satisfied, the initial conditions are adjusted and the process is repeated until a satisfactory solution is found.

3. What are the advantages of using a shooting algorithm in MATLAB?

Using a shooting algorithm in MATLAB allows for the solution of non-linear BVPs, which cannot be solved analytically. It also provides a more accurate solution compared to other numerical methods, such as finite difference methods.

4. What are the limitations of a shooting algorithm in MATLAB?

One limitation of a shooting algorithm in MATLAB is that it can be computationally expensive, especially for complex BVPs. It also requires a good initial guess for the solution, which can be difficult to obtain in some cases.

5. Can a shooting algorithm in MATLAB be used for any type of BVP?

No, a shooting algorithm in MATLAB is specifically designed for solving non-linear BVPs. It may not be suitable for other types of BVPs, such as linear BVPs, which can be solved using other numerical methods like the finite difference method.

Similar threads

  • Introductory Physics Homework Help
Replies
1
Views
993
  • Engineering and Comp Sci Homework Help
Replies
1
Views
881
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
1K
  • Advanced Physics Homework Help
Replies
10
Views
6K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
8
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
6
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
29
Views
3K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
3K
  • Engineering and Comp Sci Homework Help
Replies
1
Views
1K
Back
Top