From 477b781f94828b3d4f8bac94b196ae5f9a9d7267 Mon Sep 17 00:00:00 2001 From: Filip Jorissen Date: Mon, 7 Jun 2021 13:01:36 +0200 Subject: [PATCH] code refactors in IDEAS/Buildings/Components/ZoneAirModels/WellMixedAir.mo for #1066 --- .../Components/ZoneAirModels/WellMixedAir.mo | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/IDEAS/Buildings/Components/ZoneAirModels/WellMixedAir.mo b/IDEAS/Buildings/Components/ZoneAirModels/WellMixedAir.mo index 96f2c7273d..704a27c304 100644 --- a/IDEAS/Buildings/Components/ZoneAirModels/WellMixedAir.mo +++ b/IDEAS/Buildings/Components/ZoneAirModels/WellMixedAir.mo @@ -9,7 +9,8 @@ model WellMixedAir "Zone air model assuming perfectly mixed air" parameter StateSelect stateSelectTVol = if sim.linearise then StateSelect.prefer else StateSelect.default "Set to .prefer to use temperature as a state in mixing volume"; - Real ACH( unit="1/h") "Air Change Rate"; + Real ACH(unit="1/h") = (sum(m_flow_pos)*3600/rho_default)/Vtot + "Air change rate per hour"; protected final parameter Modelica.SIunits.MolarMass MM= @@ -67,12 +68,14 @@ protected origin={64,22}))); protected constant Real s[:]= { - if ( Modelica.Utilities.Strings.isEqual(string1=Medium.extraPropertiesNames[i], + if ( Modelica.Utilities.Strings.isEqual(string1=Medium.extraPropertiesNames[i], string2="CO2", caseSensitive=false)) - then 1 else 0 for i in 1:Medium.nC} + then 1 else 0 for i in 1:Medium.nC} "Vector with zero everywhere except where species is"; + Modelica.SIunits.MassFlowRate m_flow_pos[nPorts+2] + "Truncated mass flow rate"; IDEAS.Fluid.Sensors.RelativeHumidity senRelHum( redeclare package Medium = Medium, final warnAboutOnePortConnection=false) if hasVap @@ -98,17 +101,15 @@ protected "CO2 sensor" annotation (Placement(transformation(extent={{50,-10},{70,-30}}))); - Modelica.SIunits.MassFlowRate m_flow_pos[nPorts+2]; + equation for i in 1:nPorts+2 loop - m_flow_pos[i]= noEvent(if vol.ports[i].m_flow>0 then vol.ports[i].m_flow else 0); + m_flow_pos[i]= max(vol.ports[i].m_flow,0); end for; - ACH=(sum(m_flow_pos)*3600/rho_default)/Vtot; - if hasVap then assert(vol.ports[1].Xi_outflow[1] <= 0.1, "The water content of the zone air model is very high.