ode inside ode ; coupled ode ?

2 Ansichten (letzte 30 Tage)
Moritz
Moritz am 13 Aug. 2013
Beantwortet: Torsten am 30 Jun. 2015
Hi,
my ode requires a solution of another ode. The therm diff(sol.y)/diff(sol.x)/sol.y(end) is needed in the second ode.
for example
function dvdt=myfun(t,v,...)
% Calculating the height of the liquid and its derivative
sol = ode45(f,TSPAN,h,OPTIONS,v,v0,uclose,Au,dw);
h_nm1=h_n;
h_n=sol.y(end);
dh=diff(sol.y)./diff(sol.y);
% my ode MOL discretization calculating the concentration of particles
i=1
dvdt=...
i=2:N-1
dvdt=...
i=N
dvdt=...
Two Questions:
I do not need to solve the first ode always from zero. So i could use the old solution as initial conditions and the old time like TSPAN=[told t] ?
The way i am solving it makes me somehow uncomfortable. I am sure there is a better way. Could i solve both odes at once? But still the second one needs the solution of the first one. So it would be better to set them up as coupled ODES ?
I know you could answer those questions with "yes" or "no", but please comment an that.
Moritz
  2 Kommentare
Moritz
Moritz am 13 Aug. 2013
well i should say, that the first ode is a simple ode. The second one is a pde discretized with MOL.
I need to calculate the height of the interface h(t) and use diff(h(t)/h(t) in the pde. Since my discretization is different for both odes i do not know how to code that the best way.
The first ode needs only the last point of the pde. This point is updated with every timestep. So do i need to use global variables here ? Or can i pass the solution of the pde to the ode as an argument ? While calling the ode at the every call of the pde ?
RahulTandon
RahulTandon am 30 Jun. 2015
Could you please provide the two basic equations, to start with. The approach here is different!

Melden Sie sich an, um zu kommentieren.

Antworten (1)

Torsten
Torsten am 30 Jun. 2015
Solve the (N+1) ODEs simultaneously in one call to ODE15s:
dv(1)/dt = ...
dv(2)/dt = ...
...
dv(N)/dt = ...
+
dh/dt = ...
Best wishes
Torsten.

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by