Solving System of two Differential Equations with one initial and one end condition
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
Daniel Schuhmacehr
el 9 de Nov. de 2020
This is a code for the heat transfer in a heat exchanger. It solves the system of the two ODEs T_h_dx = ... and T_c_dx = ... for two initial conditions T_hot_in and T_cold_in.
How can this be solved, if T_cold_in should be the temperature at the end of the heat ecxhanger (x = length / end condition) and T_hot_in still the temperature at x = 0 (initial condition)?
Thank you!
% Functions for heat transfer to be solved by ode
function T_calc = heat_transfer(~,T)
T_h = T(1,1);
T_c = T(2,1);
T_h_dx = -1 / ((m_hot_plate / 2) * c_water * R_width) * (T_h - T_c);
T_c_dx = 1 / ((m_cold_plate / 2) * c_water * R_width) * (T_h - T_c);
T_calc = [T_h_dx ; T_c_dx];
end
%__________________________________________________________________________
% solve ODE System
[X, T_tot] = ode23(@(x,T) heat_transfer(x,T), [0 length],[T_hot_in T_cold_in]);
0 comentarios
Respuesta aceptada
Stephan
el 17 de Nov. de 2020
Editada: Stephan
el 17 de Nov. de 2020
Symbolic appears to work:
syms Th(x) Tc(x)
m_hp = 20;
m_cp = 5;
cw = 1;
Rw = 1;
eq(1) = diff(Th,x) == -1 / ((m_hp / 2) * cw * Rw) * (Th - Tc);
eq(2) = diff(Tc,x) == 1 / ((m_cp / 2) * cw * Rw) * (Th - Tc);
conds = [Tc(10) == 20, Th(0) == 50];
sol = dsolve(eq,conds);
fplot(sol.Tc,[0 10])
hold on
fplot(sol.Th,[0 10])
hold off
5 comentarios
Stephan
el 18 de Nov. de 2020
Editada: Stephan
el 19 de Nov. de 2020
syms Th(x) Tc(x)
m_hp = 20;
m_cp = 5;
cw = 1;
Rw = 1;
eq(1) = diff(Th,x) == -1 / ((m_hp / 2) * cw * Rw) * (Th - Tc);
eq(2) = diff(Tc,x) == 1 / ((m_cp / 2) * cw * Rw) * (Th - Tc);
conds = [Tc(10) == (20), Th(0) == 50];
sol = dsolve(eq,conds);
% You can make symbolic functions from the solutions
Th_sol(x) = sol.Th
Tc_sol(x) = sol.Tc
% and use them like you would use functions to write results into an array
x_vals = 0:0.1:10;
Th_vals = double(Th_sol(x_vals)); % double is not needed - but you want non symbolic...
Tc_vals = double(Tc_sol(x_vals));
% plot the array values
plot(x_vals,Tc_vals,x_vals,Th_vals)
Más respuestas (0)
Ver también
Categorías
Más información sobre Equation Solving 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!