Why does "Temperature" rises instantly in this solution with ode45? Also, I could not figure out why integration time interval "t_interval" gives no solution i started at "0"?

1 visualizzazione (ultimi 30 giorni)
%% Clean the Workspace
clc
clear all
%% Variables
global mS Ts_in
Vceo = 102.687; % m3
Ts_in = 104.8; % C, inlet steam temp
mS = 85.3; % kg/sec
T0 = 57.2; % Initial temp
t_interval = [0.01 10]; % Time interval
IC = T0; % Initial Condition
%% Solve the DE
[t,Tsol] = ode45(@(t,T) cfunc(t,T) , t_interval , IC);
%% From Tsat to Psat
for i=1:size(Tsol)
Psol(i) = XSteam('psat_T',Tsol(i));
i = i + 1;
end
%% Plotting
figure;
subplot(1,2,1)
plot(t,Tsol)
xlabel('Time (s)')
ylabel('Temperature (C)')
subplot(1,2,2)
plot(t,Psol)
xlabel('Time (s)')
ylabel('Pressure (bar)')
function dTdt = cfunc(t,T)
global mS Ts_in
A = 3300; % m2, heat transfer area
U = 9.9616; % kW/m2.K, heat transfer coefficient
T_hi = 104.8;
T_ho = T;
T_ci = 52.2;
T_co = 97.8;
LMTD = (abs(T_hi-T_co)-abs(T_ho-T_ci))/(log(abs(T_hi-T_co)/abs(T_ho-T_ci)));
Q = LMTD*U*A;
deltaHcond = (XSteam('hL_T',T) - XSteam('hV_T',T));
cvS = XSteam('CvV_T',T);
cpW = XSteam('CpL_T',T);
mCond = abs(Q/deltaHcond);
dTdt = ((Ts_in*XSteam('CpV_T',Ts_in)*mS-mCond*deltaHcond-mCond*T*cpW) / (cvS*(abs(mS-mCond))) - T)/t ;
end

Risposta accettata

Oguz Kaan Hancioglu
Oguz Kaan Hancioglu il 15 Feb 2023
If you change the format to long you can see that t and Tsol values change. The differential equation settles the last value in 0.001 seconds. The ode45 function seems working correctly. However, if you think the output of the ode45 is not correct, you can check your dTdt = cfunc(t,T) function.
t_interval is the time step of the ode45. Since it solves differential equations, the interval should be bigger than 0. In your function, you are dividing your calculation by t_interval. When you entered 0 time interval the output of the Tsol equals NaN. That's why you see an empty plot.

Più risposte (0)

Categorie

Scopri di più su Programming in Help Center e File Exchange

Prodotti


Release

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by