feat : add initialization T of the thermal capacity

This commit is contained in:
2026-02-12 12:12:24 +01:00
parent b81a6d443b
commit 288758e467
2 changed files with 17 additions and 15 deletions

View File

@@ -1,7 +1,10 @@
within OTRERA_formation.Components;
model ThermalCapacity
import Modelica.Fluid.Types.Dynamics ;
//USER DEFINED PARAMETERS
parameter Dynamics energyDynamics = Dynamics.FixedInitial ;
parameter Modelica.Units.SI.Mass m = 10 "Object mass";
parameter Modelica.Units.SI.SpecificHeatCapacity cp(min=0) = 1000 ;
parameter Modelica.Units.SI.Temperature T_start = 283.15 ;
@@ -14,12 +17,18 @@ model ThermalCapacity
Modelica.Thermal.HeatTransfer.Interfaces.HeatPort_a port annotation(
Placement(transformation(extent = {{-10, -10}, {10, 10}}), iconTransformation(origin = {-2, -4}, extent = {{-10, -10}, {10, 10}})));
initial equation
T = T_start ;
if energyDynamics == Dynamics.SteadyStateInitial then
der(T) = 0 ;
elseif energyDynamics == Dynamics.FixedInitial then
T = T_start ;
end if ;
equation
Q_flow = m * cp * der(T) ;
if energyDynamics == Dynamics.SteadyState then
Q_flow = 0 ;
else
Q_flow = m * cp * der(T) ;
end if ;
//PORT HANDOVER
Q_flow = port.Q_flow ;

View File

@@ -3,19 +3,12 @@ within OTRERA_formation.Models;
model Coupled_model
Components.ThermalCapacity thermalCapacity(m = 30, cp = 2000) annotation(
Placement(transformation(origin = {-10, 10}, extent = {{-10, -10}, {10, 10}})));
Placement(transformation(origin = {-30, 30}, extent = {{-10, -10}, {10, 10}})));
Components.Heatflow heatflow(Q_flow = 1000) annotation(
Placement(transformation(origin = {-46, 10}, extent = {{-10, -10}, {10, 10}})));
Components.Heatflow heatflow1(Q_flow = 2000) annotation(
Placement(transformation(origin = {-46, -20}, extent = {{-10, -10}, {10, 10}})));
Modelica.Thermal.HeatTransfer.Components.ThermalConductor thermalConductor annotation(
Placement(transformation(origin = {22, 58}, extent = {{-10, -10}, {10, 10}})));
Placement(transformation(origin = {-66, 30}, extent = {{-10, -10}, {10, 10}})));
equation
connect(heatflow.port, thermalCapacity.port) annotation(
Line(points = {{-46, 10}, {-10, 10}}, color = {191, 0, 0}));
connect(heatflow1.port, heatflow.port) annotation(
Line(points = {{-46, -20}, {-30, -20}, {-30, 10}, {-46, 10}}, color = {191, 0, 0}));
annotation(
Line(points = {{-66, 30}, {-30, 30}}, color = {191, 0, 0}));
annotation(
Diagram(coordinateSystem(extent = {{-100, -100}, {100, 100}})));
end Coupled_model;