Skip to content

Commit

Permalink
code refactors in IDEAS/Buildings/Components/ZoneAirModels/WellMixedA…
Browse files Browse the repository at this point in the history
…ir.mo for #1066
  • Loading branch information
Mathadon committed Jun 7, 2021
1 parent 2a3628d commit 477b781
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions IDEAS/Buildings/Components/ZoneAirModels/WellMixedAir.mo
Original file line number Diff line number Diff line change
Expand Up @@ -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=
Expand Down Expand Up @@ -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
Expand All @@ -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.
Expand Down

0 comments on commit 477b781

Please sign in to comment.