Originally Posted by

**kdineshkumar** Hi all,

I am using matalb to solve my problem. It is a first order non linear two ode system. I solved by initial value problem. But I dont how to solve for BVP.

One important thing is that I have used a constant value for Q. But it can be changed to achieve the other end of BCS. I have pasted my code also.

Could anyone give me a helping hand to solve this problem?

BCs

X = 1, Pb = 0, A = 0.441.

X = 0, Pb =0.

Matlab code

function dPbA_dX = odefun(X,PbA)

global S Q theta_a R Z

Pb = PbA(1,1);

A = PbA(2,1);

Y = 1-R+R*X^2;

Ht = sqrt(3)*(1-A)^2;

dPbA_dX(1,1) = (-(Y+Z*(1-R))/(2*Y)*Ht-Q)*(6*S)/(sqrt(3)*Ht^2);

Pa = (2-(1-A)*Pb)/A;

f1_A = -0.86*A^2+0.345*A+0.515;

f2_A = 1/(2.571-A-A*log(1-A));

dPbA_dX(2,1) = -(2*R*X*(Pa-Pb)*f1_A)/(theta_a*Y*(2-(Pa-Pb)*f2_A));

end

% Key In Inputs to solve this problem

%global S Q theta_a R Z;S = 0.05;Q = 0.0545;theta_a = 0.1;R = 0.2;Z = 1;

%[X Y]=ode45(@odefun,[1 0],[0 0.441]);

%figure;plot(X,Y(1:size(X),1));xlabel('X');ylabel( 'P');

% The parameter Q has to be changed to achieve the other end of BCs. Here

% I have used a constant value(0.0545) to solve by this procedure.

The method of solving these is the "shooting method", where you define a function:

Code:

function endV=gash(Dy0, yFinal)
[X Y]=ode45(@odefun,[0 1],[0 Dy0]);
endV=Y(length(Y))-yFinal;

Where yFinal is the required value at x=1. Note the second argumant of ode45 is the tspan and the third the initial conditions. So here we are solving the BVP y'=f(x,y) subject to y(0)=0, y(1)=yFinal.

Now find a couple of intial values of y'(0) so that the product of the corresponding endV's is negative, then use the bisection method to find y'(0) such that endV is 0, and that is it.

(You solve the IVP with varying initial derivatives untill you find an IVP that matches the required end value)

CB