I am solving two the first order ODEs ('=d/dz, all other variables are known constants):
p0 p0'=-32 beta/R^4
p0p1'=-((2-sigma_v)/sigma_v)*8*p0'/R
I have next conditions
p0(z=0)=p0i (I can choose value)
p0(z=1)=1
p1(z=0)=0
p1(z=1)=0
It is necessary to find p0'(z=0) and p1'(z=0) with shooting method (literature says like that), according to already mentioned p0(z=1)=1 and p1(z=1)=0. *How to connect this two conditions* and shoot p0'(z=0) for already known p1'(z=0)?
*Are that conditions p0'(z=0) and p1'(z=0) necessary*, because these are the first order equations, is there only one initial condition enough?
Instead of missing conditions, I also need to solve numerically two ODEs, from the beginning of text, with Runge Kutta method. How to connect that solving with shooting? Is it possible to find missing condition with bvp4c, as shooting method, and after that solve equation with ode45?

 Akzeptierte Antwort

Torsten
Torsten am 3 Mai 2018

1 Stimme

If you know $p_0|_{z=1}=1$ and $p_1|_{z=1}=0$ and you want to know $p_0'|_{z=0}$ and $p_1'|_{z=0}$, you don't need a shooting method.

Just use ODE45 as you already did and define tspan=[1 0]. This way, you integrate back in z-direction from z=1 to z=0. Once you have reached z=0,

$p_0'|_{z=0}=-\dfrac{32 \beta}{R^4}/p_0$ 

and

$p_1'|_{z=0}=(-\dfrac{2-\sigma_v}{\sigma_v}\dfrac{8}{R}p_0'-p_0'*p_1)/p_0$  

Best wishes

Torsten.

5 Kommentare

I G
I G am 3 Mai 2018
Do I need to run ode45 again after this first iteration, but second time with known conditions at z=0?
Do I need to say matlab, at first iteration, that my conditions are not both initial conditions? Because there is, according to help for ode45, in command line vector y0, which need to be contained of initial conditions?
Torsten
Torsten am 3 Mai 2018
Do I need to run ode45 again after this first iteration, but second time with known conditions at z=0?
No, the solution you get by integrating back from 1 to 0 is the solution of your ODEs with p_0(1)=1 and p_1(1)=0.
Do I need to say matlab, at first iteration, that my conditions are not both initial conditions? Because there is, according to help for ode45, in command line vector y0, which need to be contained of initial conditions?
p_0(1)=1 and p_1(1)=0 are your initial conditions (although they are set at the end of the z-interval of integration).
Why are you talking about "first iteration" ? There is no iteration process to solve your ODEs.
Best wishes
Torsten.
I G
I G am 3 Mai 2018
Bearbeitet: I G am 3 Mai 2018
Can you tell me please how Matlab know which initial value I gave to it?
If I defined y0=[1 0], does it mean that I gave it 1 for first equation, and 0 for the second equation? Or do I need to have, 4 initial conditions for two equations?
Does it recognize it as initial value for variable-p0 or as initial values for derivative of variable-dp0dz, if I defined equation like this: dp0dz=-32*beta/(p0*R^4)?
Torsten
Torsten am 3 Mai 2018
If I defined y0=[1 0], does it mean that I gave it 1 for first equation, and 0 for the second equation? Or do I need to have, 4 initial conditions for two equations?
It means that you gave p_0(@tspan(1))=1 and p_1(@tspan(1))=0 as initial conditions. And you need two initial conditions for two first-oder differential equations.
Does it recognize it as initial value for variable-p0 or as initial values for derivative of variable-dp0dz, if I defined equation like this: dp0dz=-32*beta/(p0*R^4)?
y0 is interpreted as initial value vector [p_0,p_1] at tspan(1).
I G
I G am 3 Mai 2018
I cannot find mistake in my equations, this is the last question I promise, but ode45 doesn`t work:
function f=fun(z,p)
R=2; sig=1; beta=1;
f(1)=-32*beta/(R^4*p(1));
f(2)=(-(2-sig)*8*f(1)/(sig*R)-f(1)*p(2))/p(1);
[zv,pv]=ode45('fun',[1 0],[1; 0])
Is it possible to call term on left side of the first equation in the second equation? What can be wrong here?

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Produkte

Gefragt:

I G
am 3 Mai 2018

Kommentiert:

I G
am 3 Mai 2018

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by