SOLVING SYSTEM OF ODEs

3 views (last 30 days)
Diego Mondaray Muñoz
Diego Mondaray Muñoz on 7 May 2023
Edited: Torsten on 8 May 2023
Hello,
I have this system of differential equations:
where these two are being differentiated respect an adimensional time defined as:
also all other variables are defined as:
but I also have a third differential equation which is:
Is there any way of solving these equations in the same ODE45 solver? Later I want to couple this system with another two ODEs that are going to be diferrentiated respect to 't' and I need to solve all of them together.
Thanks in advance.
  4 Comments
Diego Mondaray Muñoz
Diego Mondaray Muñoz on 7 May 2023
Edited: Diego Mondaray Muñoz on 8 May 2023
The problem is about making a thermohydraulic model that models the temperature of the moderator/coolant, the cladding and the nuclear fuel. I have accomplished having the two first equations solved in one system (using dsolve) and later pass the answer to the third equation and solved it separately; however I would like to solve them all at the same time so I can have them all together in one function and solve with ode45.
Diego Mondaray Muñoz
Diego Mondaray Muñoz on 7 May 2023
I get my data from datos_TH and solve the equations this way:
%%SIMPLIFIED THERMOHYDRAULIC MODEL%%
clear all
datos_TH;
syms Tfav(t) Tcav(t) Tm(t)
cond1=Tfav(0)==(Tf0-Tm0)/(Tf0-Tm0);
cond2=Tcav(0)==(Tc0-Tm0)/(Tf0-Tm0);
conds=[cond1; cond2];
ode1=diff(Tfav)==-2*Bigf*(Tfav-Tcav)/Rf0 + G;
ode2=diff(Tcav)==2*K*(10*Rci*(Tfav-Tcav)-Bi(1)*Tcav)/(1-Rci^2); %Bigc%Definir mejor los parámetros, el modelo está bien. Los resultados no.
odes=[ode1;ode2];
[TcavSol(t), TfavSol(t)]=dsolve(odes, conds);
Tf=[];
Tc=[];
n=1;
t_0=50;
time_ad=t_0*kf/(Rhof*cf*rc0^2);
for i=0:0.01:time_ad
Tf(n)=double(TfavSol(i))*(Tf0-Tm0) + Tm0;
Tc(n)=double(TcavSol(i))*(Tf0-Tm0) + Tm0;
n=n+1;
m=n+1;
end
%Moderator Temperature ODE
t1=linspace(0,t_0,m-2);
t1=transpose(t1);
Tc=transpose(Tc);
Tc_p=fit(t1,Tc,'poly8');
Tc_p=subs(str2sym(formula(Tc_p)),coeffnames(Tc_p),num2cell(coeffvalues(Tc_p).'));
Tc_p=subs(Tc_p,t);
cond3=Tm(0)==Tm0;
ode3=diff(Tm,t)==(Sc*hi(1)*(Tc_p-Tm)-2*m*cp*(Tm-Tm0))/(Mc*cp);
TmSol(t)=dsolve(ode3,cond3);
%Plot functions of Adimensional Temperatures%
tspan=[0 time_ad];
figure
grid on
fplot(TfavSol,tspan)
hold on
fplot(TcavSol,tspan)
legend({'Adimesional fuel Temperature','Adimensional Cladding Temperature'},'Location','east')
xlabel('Adimensional Time')
ylabel('Adimensional Temperature')
title('Adimensional Temperature evolution for B1')
%Plot Temperatures °C%
t=linspace(0,t_0,m-2);
figure
plot(t,Tf)
hold on
plot(t,Tc)
legend({'Fuel Temperature','Cladding Temperature'}, 'Location','east')
xlabel('Time (s)')
ylabel('Temperature °C')
title('Dimensional Temperature evolution for B1')
%Plot Moderator Temperature °C%
tspan=[0 t_0];
figure
grid on
fplot(TmSol,tspan)
legend('Moderator Temperature','Location','east')
xlabel('Time (s)')
ylabel('Moderator Temperature °C')
title('Moderator Temperature evolution for h1')
But I this takes quite the time and I don´t know how to couple this system with other equations, so I want to solve this only using one ode45.

Sign in to comment.

Answers (1)

Torsten
Torsten on 8 May 2023
Edited: Torsten on 8 May 2023
Write your three equations in the same independent variable (thus either t or tau).
I assume all three equations are written in t.
Then your call to ODE45 would be
tspan = [tstart tend]
y0 = [Tf0;Tc0;T0];
dTf_dt = @(t,y)...
dTc_dt = @(t,y)...
dT_dt = @(t,y)...
fun = @(t,y)[dTf_dt(t,y);dTc_dt(t,y);dT_dt(t,y)];
[Time,Y] = ode45(fun,tspan,y0)

Community Treasure Hunt

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

Start Hunting!