using ode solver or bvp4c for a 4th order two point boundary value problem with time-varying coefficients

3 visualizaciones (últimos 30 días)
Hello,
I am attempting to solve a two point boundary value problem for a set of 4 simultaneous differential equations with coefficients that are a function of the state(s):
x1dot = x2
x2dot = -(2*(a(x1))* x2^2 + λ2)/(2*b(x1))
λ1dot = -2*{c(x1)*u^2 + d(x1)*x2^4*(e(x1) + f(x1))*x2^2*u}
λ2dot = -4*(g(x1)*x2^3 + h(x1)*x2*u) - λ1
Again, the coefficients of the states in the above system (a,b,c,d,e,f,g,h) are all functions of the state x1 (indirectly functions of the other states) which are of course functions of time...my problem is essentially that i don't know how to handle these coefficients using ode23 (or bvp4c).
I have expressions for all needed initial conditions except λ1. My problem amounts to a shooting problem where a value is chosen for λ1 such that the final conditions for x1 and x2 are met. If the coefficients (a,b,c,d,e,f,g,h) are constant the problem is easy - i can just iterate over different values of λ1 by putting the ode solver in a loop and setting ode23 to stop when the desired final conditions are met until i find the right λ1.
But what do i do when i need to vary the coefficients over time and as a function of the states that are being solved?
My first idea was to start with the λ1 for the constant coefficients case and then take the state outputs for the first iteration of the numerical solution and use those as the initial states for a new ode23 call with updated coefficients.....is this approach flawed?
pseudocode:
for i=1:num
a=f(beta,theta,p,q) b=f(beta,theta,p,q) c=f(beta,theta,p,q) ....
x1_zero=0; x2_zero=0; lambda1_zero=num2; lambda2_zero=num3;
tspan=[0,10]
[t,y,te,ye,ie] = ode23(@twoptbdry,tspan,[x1_zero,x2_zero,lambda1_zero,lambda2_zero],options);
%evolve state beta=f(x1(@ the first time instant after 0)) theta=f(x1(@ the first time instant after 0)) p=f(x1(@ the first time instant after 0)) q=f(x1(@ the first time instant after 0))
%set new initial conditions x1_zero=y(2,1);% y(2,1) is the first value for x1 @ the first time instant after 0 x2_zero=y(2,2); lambda1_zero=y(2,3); lambda2_zero=y(2,4);
tspan=[t(2),10]
end
If i implement this loop such that the coefficients evaluate the same for every loop iteration, the results are not the same as when i just let ode23 run through which tells me that there is something flawed either theoretically (with regard to how these numerical approximation are reached and the assumptions involved) in my approach or there is something ode23 does that i am not perceiving and there is some trick i need to employ.
Can anyone help me with this? It's a pretty standard problem i just can't seem to find the right examples....

Respuesta aceptada

Andrew Newell
Andrew Newell el 19 de Jun. de 2011
The MATLAB solvers don't care whether your ODE's have constant coefficients or not. Just include the functions defining your coefficients as subfunctions in your file twoptbdry.m.

Más respuestas (0)

Categorías

Más información sobre Programming en Help Center y File Exchange.

Productos

Community Treasure Hunt

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

Start Hunting!

Translated by