Results 1 to 3 of 3

Math Help - How to solve 2 point BVP in matalb for First order 2 ODES

  1. #1
    Newbie
    Joined
    Apr 2010
    Posts
    2

    How to solve 2 point BVP in matalb for First order 2 ODES

    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.
    Follow Math Help Forum on Facebook and Google+

  2. #2
    Grand Panjandrum
    Joined
    Nov 2005
    From
    someplace
    Posts
    14,972
    Thanks
    4
    Quote Originally Posted by kdineshkumar View Post
    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
    Follow Math Help Forum on Facebook and Google+

  3. #3
    Newbie
    Joined
    Apr 2010
    Posts
    2

    Thumbs up Thanks for your reply!!!

    I have already done in a similar fashion as you have said using root finding.
    Regards
    Dinesh
    Follow Math Help Forum on Facebook and Google+

Similar Math Help Forum Discussions

  1. First order ODEs
    Posted in the Differential Equations Forum
    Replies: 4
    Last Post: October 2nd 2011, 09:20 AM
  2. Convert 2nd order ode to first order ODES
    Posted in the Differential Equations Forum
    Replies: 5
    Last Post: June 1st 2010, 06:43 AM
  3. ODEs - what is the point of this?
    Posted in the Differential Equations Forum
    Replies: 0
    Last Post: March 7th 2010, 11:25 AM
  4. second order odes
    Posted in the Differential Equations Forum
    Replies: 5
    Last Post: August 22nd 2009, 07:09 AM
  5. n-th order ODEs as n-th dimensional system of first order ODEs
    Posted in the Differential Equations Forum
    Replies: 0
    Last Post: May 6th 2009, 08:32 PM

Search Tags


/mathhelpforum @mathhelpforum