필터 지우기
필터 지우기

SOLVING SYSTEM OF ODEs

조회 수: 6 (최근 30일)
Diego Mondaray Muñoz
Diego Mondaray Muñoz 2023년 5월 7일
편집: Torsten 2023년 5월 8일
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
Diego Mondaray Muñoz
Diego Mondaray Muñoz 2023년 5월 7일
편집: Diego Mondaray Muñoz 2023년 5월 8일
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 2023년 5월 7일
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.

댓글을 달려면 로그인하십시오.

답변 (1개)

Torsten
Torsten 2023년 5월 8일
편집: Torsten 2023년 5월 8일
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)

카테고리

Help CenterFile Exchange에서 Ordinary Differential Equations에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by