ode45 or bvp4c? Which one suits this scenario? Please anyone reply

I have a set of differential equations (dPi/dz) for power say for P1 to P7. I have initial power values for P1 to P4 at z=0 and initial power values for P5 to P7 at z= 8. Can I solve this as ode45 or bvp4c?
Because the initial power values I have are not really like boundary conditions. But then how can I use ode45 by using the same P vector definition to have intial values defined for P1 to P4 at one z and for P5 to P7 at another z, as stated above?

4 Kommentare

What does this mean: "the initial power values I have are not really like boundary conditions"?
Initial values are boundary conditions by definition.
Jaya
Jaya am 17 Mai 2021
Bearbeitet: Jaya am 17 Mai 2021
Of course, they are defined at boundaries but what I mean is (in the following code) isn't it like I define all P1 to P7 at z=0 whereas what I want is signal powers P1 to P4 defined at z=0 but pump powers P5 to P7 alone defined at z=80. But how to let the ode45 know that?
I use the same p vector to do the function definition in lorenz i.e. p(1) to refers to signal 1 power and p(5) refers to pump 1 power. OR is there any totally different way to do this?
zspan = [0:80]
p0= -3.5* ones(4,1) %for P1,P2,P3,P4
pp1=-300e-3 ; pp2=-310e-3 ; pp3=-320e-3 ; %for P5, P6, P7
p_in=[p0;pp1;pp2] %to form the intial p vector for ode45
[z,p]= ode45(@lorenz,zspan,p_in)
Please don't keep asking the same question.
Use a boundary value solver, NOT ODE45. However, using a shooting method, as Jan points out, you can use ODE45.
Jaya
Jaya am 22 Mai 2021
Bearbeitet: Jaya am 22 Mai 2021
OK, thanks. But I hope you have observed the no. of days elapsed between my two questions. I read other stuff too and wanted to ask more specifically since I had implemented and again faced problems. I did not ask repetitively without trying. And I myself wrote why I am asking again in my second question. Thanks.

Melden Sie sich an, um zu kommentieren.

 Akzeptierte Antwort

Jan
Jan am 17 Mai 2021

1 Stimme

If some conditions are defined at different time points, the problem is not an "initial value problem", which can be solved by ODE45, but a boundary value problem, for which BVP4C or BVP5C is a suitable solver.
An alternative is to write your own boundary value solver:
Start with a smart guess of the missing components of the initial value and integrate with ODE45. You get a difference between the final values and the boundary values at this time point. Then vary the initial conditions to find out the sensitivity. This can be applied with a Newton method to modify the initial values until the final values are matched. This is the "single shooting method".

Weitere Antworten (0)

Gefragt:

am 17 Mai 2021

Bearbeitet:

am 22 Mai 2021

Community Treasure Hunt

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

Start Hunting!

Translated by