Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Source sink flow asserts #132

Merged
merged 8 commits into from
Oct 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion ThermofluidStream/Boundaries/Sink.mo
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ the outlet the sink is connected to.
annotation(Dialog(enable = not pressureFromInput));
parameter Utilities.Units.Inertance L=dropOfCommons.L "Inertance of pressure"
annotation (Dialog(tab="Advanced"));
parameter SI.MassFlowRate m_flow_assert(max=0) = -dropOfCommons.m_flow_reg "Assertion threshold for negative mass flow"
annotation(Dialog(tab="Advanced"));

Interfaces.Inlet inlet(redeclare package Medium = Medium)
annotation (Placement(transformation(extent={{-120,-20},{-80,20}})));
Expand All @@ -36,7 +38,8 @@ protected
SI.Pressure p = Medium.pressure(inlet.state);

equation

assert(inlet.m_flow > m_flow_assert, "Negative mass flow at sink inlet", dropOfCommons.assertionLevel);

connect(p0_var, p0);
if not pressureFromInput then
p0 = p0_par;
Expand Down
3 changes: 3 additions & 0 deletions ThermofluidStream/Boundaries/Source.mo
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ the inlet the source is connected to.
annotation(Dialog(enable = not xiFromInput));
parameter Utilities.Units.Inertance L=dropOfCommons.L "Inertance"
annotation (Dialog(tab="Advanced"));
parameter SI.MassFlowRate m_flow_assert(max=0) = -dropOfCommons.m_flow_reg "Assertion threshold for negative mass flow"
annotation(Dialog(tab="Advanced"));

Modelica.Blocks.Interfaces.RealInput p0_var(unit="Pa") if pressureFromInput "Pressure input connector [Pa]"
annotation (Placement(transformation(extent={{-40,40},{0,80}}), iconTransformation(extent={{-40,40},{0,80}})));
Expand All @@ -48,6 +50,7 @@ protected
Modelica.Blocks.Interfaces.RealInput Xi0[Medium.nXi](each unit = "kg/kg") "Internal mass fraction connector";

equation
assert(-outlet.m_flow > m_flow_assert, "Positive mass flow at source outlet", dropOfCommons.assertionLevel);

connect(T0_var, T0);
if not temperatureFromInput or setEnthalpy then
Expand Down
3 changes: 2 additions & 1 deletion ThermofluidStream/Examples/EspressoMachine.mo
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,8 @@ Medium model for water.
Boundaries.Source source1(
redeclare package Medium = Water,
T0_par=298.15,
p0_par=100000)
p0_par=100000,
m_flow_assert=-3*dropOfCommons.m_flow_reg)
annotation (Placement(transformation(extent={{-10,-10},{10,10}},
rotation=0,
origin={-140,-120})));
Expand Down