From 2b11da7dc7e6b9c8344601cbc923c16d5670648c Mon Sep 17 00:00:00 2001 From: Matthieu Descombes Date: Fri, 13 Feb 2026 10:41:59 +0100 Subject: [PATCH] refactor : correction fan --- Formation/OTRERA_formation/Components/Fan.mo | 18 ++++++++++-------- Formation/OTRERA_formation/Models/Test_fan.mo | 15 +++++++++++++++ .../OTRERA_formation/Models/package.order | 2 ++ Formation/OTRERA_formation/package.mo | 2 +- 4 files changed, 28 insertions(+), 9 deletions(-) create mode 100644 Formation/OTRERA_formation/Models/Test_fan.mo diff --git a/Formation/OTRERA_formation/Components/Fan.mo b/Formation/OTRERA_formation/Components/Fan.mo index 3846c5c..cabc6b8 100644 --- a/Formation/OTRERA_formation/Components/Fan.mo +++ b/Formation/OTRERA_formation/Components/Fan.mo @@ -3,19 +3,21 @@ within OTRERA_formation.Components; model Fan replaceable package Medium = Modelica.Media.Air.ReferenceAir.Air_pT constrainedby Modelica.Media.Interfaces.PartialMedium annotation(choicesAllMatching = true) ; -extends Modelica.Thermal.HeatTransfer.Interfaces.Element1D ; - //USER DEFINED PARAMETERS - parameter Modelica.Units.SI.MassFlowRate m_flow ; + parameter Modelica.Units.SI.MassFlowRate m_flow = 10 ; //INTERNAL VARIABLES Medium.ThermodynamicState state ; Modelica.Units.SI.SpecificHeatCapacity cp ; - -//IMPORTED COMPONENTS - - + Modelica.Units.SI.HeatFlowRate Q_flow ; + //IMPORTED COMPONENTS + Modelica.Thermal.HeatTransfer.Interfaces.HeatPort_a port_a annotation( + Placement(transformation(origin = {-96, 0}, extent = {{-10, -10}, {10, 10}}), iconTransformation(origin = {-88, 6}, extent = {{-10, -10}, {10, 10}}))); + Modelica.Thermal.HeatTransfer.Interfaces.HeatPort_b port_b annotation( + Placement(transformation(origin = {96, 0}, extent = {{-10, -10}, {10, 10}}), iconTransformation(origin = {90, 2}, extent = {{-10, -10}, {10, 10}}))); equation state = Medium.setState_pT(p=Medium.p_default,T=port_a.T); cp = Medium.specificHeatCapacityCp(state) ; - Q_flow = m_flow * cp * (-dT) ; + Q_flow = m_flow * cp * (port_b.T - port_a.T) ; + port_b.Q_flow = Q_flow; + port_a.Q_flow = 0 ; end Fan; \ No newline at end of file diff --git a/Formation/OTRERA_formation/Models/Test_fan.mo b/Formation/OTRERA_formation/Models/Test_fan.mo new file mode 100644 index 0000000..da3d8a6 --- /dev/null +++ b/Formation/OTRERA_formation/Models/Test_fan.mo @@ -0,0 +1,15 @@ +within OTRERA_formation.Models; + +model Test_fan + Components.Fan fan(m_flow = 10) annotation( + Placement(transformation(origin = {2, 10}, extent = {{-10, -10}, {10, 10}}))); + Components.ThermalCapacity thermalCapacity(T_start = 293.15) annotation( + Placement(transformation(origin = {50, 10}, extent = {{-10, -10}, {10, 10}}))); + Components.Temperature temperature(T = 303.15) annotation( + Placement(transformation(origin = {-46, 10}, extent = {{-10, -10}, {10, 10}}))); +equation + connect(temperature.port, fan.port_a) annotation( + Line(points = {{-46, 10}, {-8, 10}}, color = {191, 0, 0})); + connect(fan.port_b, thermalCapacity.port) annotation( + Line(points = {{12, 10}, {50, 10}}, color = {191, 0, 0})); +end Test_fan; \ No newline at end of file diff --git a/Formation/OTRERA_formation/Models/package.order b/Formation/OTRERA_formation/Models/package.order index 1e6027b..6b0a60b 100644 --- a/Formation/OTRERA_formation/Models/package.order +++ b/Formation/OTRERA_formation/Models/package.order @@ -3,3 +3,5 @@ Coupled_model_prescribed Coupled_model_prescribed_variable Test_Media Test_replaceable_media +Test_fan +Test_wall diff --git a/Formation/OTRERA_formation/package.mo b/Formation/OTRERA_formation/package.mo index bf52e60..2958882 100644 --- a/Formation/OTRERA_formation/package.mo +++ b/Formation/OTRERA_formation/package.mo @@ -5,5 +5,5 @@ package OTRERA_formation annotation( - uses(Modelica(version = "4.1.0"))); + uses(Modelica(version = "4.1.0"), TAeZoSysPro(version = "4.0-main"))); end OTRERA_formation; \ No newline at end of file