banner



How To Find Sign Change In Matlab

Airplane Poiseuille menstruum - BVP solve by shooting method

In Post 878 learned how to use the BVP solver in Matlab to solve a boundary value trouble. Another arroyo is to use the shooting method. The reason we can't use an initial value solver for a BVP is that in that location is not plenty information at the initial value to start. In the shooting method, we take the function value at the initial point, and guess what the office derivatives are so that we can do an integration. If our guess was good, then the solution will go through the known 2d boundary point. If not, nosotros gauge again, until nosotros become the reply we demand. In this instance we repeat the pressure level driven flow example, but illustrate the shooting method.

In the pressure driven flow of a fluid with viscosity $\mu$ between two stationary plates separated by altitude $d$ and driven by a pressure level driblet $\Delta P/\Delta x$, the governing equations on the velocity $u$ of the fluid are (assuming flow in the x-direction with the velocity varying only in the y-management):

Contents

  • Outset judge
  • 2nd approximate
  • Using a solver
  • Plot final solution
  • Known analytical solution

$$\frac{\Delta P}{\Delta x} = \mu \frac{d^2u}{dy^2}$$

with purlieus conditions $u(y=0) = 0$ and $u(y=d) = 0$, i.due east. the no-slip condition at the edges of the plate.

nosotros convert this second order BVP to a arrangement of ODEs by letting $u_1 = u$, $u_2 = u_1'$ and so $u_2' = u_1''$. This leads to:

$\frac{d u_1}{dy} = u_2$

$\frac{d u_2}{dy} = \frac{1}{\mu}\frac{\Delta P}{\Delta x}$

with boundary conditions $u_1(y=0) = 0$ and $u_1(y=d) = 0$.

for this trouble we let the plate separation exist d=0.1, the viscosity $\mu = 1$, and $\frac{\Delta P}{\Delta x} = -100$.

          function          main        
clc; close          all; clear          all;  d = 0.i;         

Starting time guess

we need u_1(0) and u_2(0), but we merely have u_1(0). Nosotros need to guess a value for u_2(0) and see if the solution goes through the u_2(d)=0 boundary value.

u1_0 = 0;  u2_0 = one;   init = [u1_0 u2_0]; dspan = [0 d]; [y,U] = ode45(@odefun,dspan,init); plot(y,U(:,1),[d],[0],'ro') fable          'solution #1'          'u_2(d)=0'          xlabel('y') ylabel('u_1')          

2d guess

u1_0 = 0;  u2_0 = 10;   init = [u1_0 u2_0]; dspan = [0 d]; [y,U] = ode45(@odefun,dspan,init); plot(y,U(:,i),[d],[0],'ro') fable          'solution #2'          'u_2(d)=0'          xlabel('y') ylabel('u_1')            

Using a solver

we accept to make a function that is equal to zero when u_2(d) = 0.

u2_guess = 2; u2_0_solved = fsolve(@myfunc,u2_guess)        
Equation solved.  fsolve completed considering the vector of function values is most naught equally measured by the default value of the function tolerance, and the problem appears regular as measured by the gradient.     u2_0_solved =      5.0000        

Plot terminal solution

init = [u1_0 u2_0_solved]; dspan = [0 d]; [y,U] = ode45(@odefun,dspan,init);  figure plot(y,U(:,1),d,0,'ro') xlabel('y') ylabel('u_1')        

Known analytical solution

the analytical solution to this problem is known, and nosotros tin plot it on acme of the numerical solution

mu = 1; Pdrop = -100;  u = -(Pdrop)*d^2/ii/mu*(y/d-(y/d).^ii); concord          all          plot(y,u,'r--') legend          'solution'          'u_2(d)=0'          'belittling solution'        

          'washed'        
ans =  washed        

Finally, the solutions agree, and evidence that the velocity profile is parabolic, with a maximum in the heart of the two plates. Yous can also see that the velocity at each boundary is zero, as required by the purlieus conditions

          function          dUdy = odefun(y,U)  u1 = U(1); u2 = U(2);  mu = 1; Pdrop = -100;  du1dy = u2; du2dy = ane/mu*Pdrop; dUdy = [du1dy; du2dy];          function          Z = myfunc(u2_guess)  u1_0 = 0;  u2_0 = u2_guess;  d = 0.1;  init = [u1_0 u2_0]; dspan = [0 d]; sol = ode45(@odefun,dspan,init);  u = deval(sol,d);  u1_d = u(1); Z = u1_d;              

Source: http://matlab.cheme.cmu.edu/category/odes/3/

Posted by: reesewousing.blogspot.com

0 Response to "How To Find Sign Change In Matlab"

Post a Comment

Iklan Atas Artikel

Iklan Tengah Artikel 1

Iklan Tengah Artikel 2

Iklan Bawah Artikel