Skip to content

Commit

Permalink
Merge branch 'master' into issues1935_unprotectdhDiscretizedDoor
Browse files Browse the repository at this point in the history
  • Loading branch information
mwetter committed Oct 17, 2024
2 parents 82250ce + 5136ecf commit 6701fab
Show file tree
Hide file tree
Showing 102 changed files with 1,924 additions and 720 deletions.
4 changes: 2 additions & 2 deletions IBPSA/Examples/SimpleHouse.mo
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ model SimpleHouse

Fluid.Movers.FlowControlled_m_flow pum(
redeclare package Medium = MediumWater,
use_inputFilter=false,
use_riseTime=false,
m_flow_nominal=mWat_flow_nominal,
energyDynamics=Modelica.Fluid.Types.Dynamics.SteadyState,
allowFlowReversal=allowFlowReversal,
Expand All @@ -109,7 +109,7 @@ model SimpleHouse
Fluid.Movers.FlowControlled_dp fan(
redeclare package Medium = MediumAir,
dp_nominal=dpAir_nominal,
use_inputFilter=false,
use_riseTime=false,
energyDynamics=Modelica.Fluid.Types.Dynamics.SteadyState,
nominalValuesDefineDefaultPressureCurve=true,
m_flow_nominal=mAir_flow_nominal,
Expand Down
2 changes: 1 addition & 1 deletion IBPSA/Examples/Tutorial/SimpleHouse/SimpleHouse4.mo
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ model SimpleHouse4 "Heating model"

Fluid.Movers.Preconfigured.FlowControlled_m_flow pum(
redeclare package Medium = MediumWater,
use_inputFilter=false,
use_riseTime=false,
m_flow_nominal=mWat_flow_nominal,
energyDynamics=Modelica.Fluid.Types.Dynamics.SteadyState,
allowFlowReversal=false) "Pump"
Expand Down
8 changes: 3 additions & 5 deletions IBPSA/Examples/Tutorial/SimpleHouse/SimpleHouse6.mo
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,10 @@ model SimpleHouse6 "Free cooling model"
redeclare package Medium = MediumAir,
show_T=true,
dp_nominal=dpAir_nominal,
use_inputFilter=false,
use_riseTime=false,
energyDynamics=Modelica.Fluid.Types.Dynamics.SteadyState,
m_flow_nominal=mAir_flow_nominal)
"Constant head fan" annotation (Placement(transformation(
extent={{-10,10},{10,-10}},
origin={0,130})));
m_flow_nominal=mAir_flow_nominal) "Constant head fan" annotation (Placement(
transformation(extent={{-10,10},{10,-10}}, origin={0,130})));

IBPSA.Fluid.HeatExchangers.ConstantEffectiveness hexRec(
redeclare package Medium1 = MediumAir,
Expand Down
73 changes: 40 additions & 33 deletions IBPSA/Fluid/Actuators/BaseClasses/ActuatorSignal.mo
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,23 @@ within IBPSA.Fluid.Actuators.BaseClasses;
model ActuatorSignal
"Partial model that implements the filtered opening for valves and dampers"

constant Integer order(min=1) = 2 "Order of filter";
parameter Boolean use_strokeTime=true
"Set to true to continuously open and close valve using strokeTime"
annotation(Dialog(tab="Dynamics", group="Actuator position"));

parameter Boolean use_inputFilter=true
"= true, if opening is filtered with a 2nd order CriticalDamping filter"
annotation(Dialog(tab="Dynamics", group="Filtered opening"));
parameter Modelica.Units.SI.Time riseTime=120
"Rise time of the filter (time to reach 99.6 % of an opening step)"
parameter Modelica.Units.SI.Time strokeTime=120
"Time needed to fully open or close actuator"
annotation (Dialog(
tab="Dynamics",
group="Filtered opening",
enable=use_inputFilter));
group="Actuator position",
enable=use_strokeTime));
parameter Modelica.Blocks.Types.Init init=Modelica.Blocks.Types.Init.InitialOutput
"Type of initialization (no init/steady state/initial state/initial output)"
annotation(Dialog(tab="Dynamics", group="Filtered opening",enable=use_inputFilter));
annotation(Dialog(tab="Dynamics", group="Actuator position",
enable=use_strokeTime));
parameter Real y_start=1 "Initial position of actuator"
annotation(Dialog(tab="Dynamics", group="Filtered opening",enable=use_inputFilter));
annotation(Dialog(tab="Dynamics", group="Actuator position",
enable=use_strokeTime));

Modelica.Blocks.Interfaces.RealInput y(min=0, max=1)
"Actuator position (0: closed, 1: open)"
Expand All @@ -33,37 +34,36 @@ model ActuatorSignal
annotation (Placement(transformation(extent={{40,60},{60,80}})));

// Classes used to implement the filtered opening
protected
final parameter Modelica.Units.SI.Frequency fCut=5/(2*Modelica.Constants.pi*
riseTime) "Cut-off frequency of filter";

protected
parameter Boolean casePreInd = false
"In case of PressureIndependent the model I/O is modified"
annotation(Evaluate=true);
Modelica.Blocks.Interfaces.RealOutput y_internal(unit="1")
"Output connector for internal use (= y_actual if not casePreInd)";
Modelica.Blocks.Interfaces.RealOutput y_filtered if use_inputFilter
Modelica.Blocks.Interfaces.RealOutput y_filtered if use_strokeTime
"Filtered valve position in the range 0..1"
annotation (Placement(transformation(extent={{40,78},{60,98}}),
iconTransformation(extent={{60,50},{80,70}})));

IBPSA.Fluid.BaseClasses.ActuatorFilter filter(
final n=order,
final f=fCut,
final normalized=true,
final initType=init,
final y_start=y_start) if use_inputFilter
"Second order filter to approximate actuator opening time, and to improve numerics"
annotation (Placement(transformation(extent={{6,81},{20,95}})));

Modelica.Blocks.Nonlinear.SlewRateLimiter actPos(
Rising=1/strokeTime,
Falling=-1/strokeTime,
Td=0.001*strokeTime,
initType=init,
y_start=y_start,
strict=true) if use_strokeTime "Actuator position"
annotation (Placement(transformation(extent={{14,82},{26,94}})));
equation
connect(filter.y, y_filtered)
annotation (Line(points={{20.7,88},{50,88}}, color={0,0,127}));
if use_inputFilter then
connect(y, filter.u) annotation (Line(points={{1.11022e-15,120},{1.11022e-15,
88},{4.6,88}}, color={0,0,127}));
connect(filter.y, y_internal) annotation (Line(points={{20.7,88},{30,88},{30,
70},{50,70}}, color={0,0,127}));
connect(actPos.y, y_filtered)
annotation (Line(points={{26.6,88},{50,88}},
color={0,0,127}));

if use_strokeTime then
connect(actPos.u, y)
annotation (Line(points={{12.8,88},{0,88},{0,120}}, color={0,0,127}));

connect(y_filtered, y_internal);
else
connect(y, y_internal) annotation (Line(
points={{1.11022e-15,120},{0,120},{0,70},{50,70}},
Expand All @@ -72,26 +72,27 @@ equation
if not casePreInd then
connect(y_internal, y_actual);
end if;

annotation (Icon(coordinateSystem(preserveAspectRatio=false, extent={{-100,
-100},{100,100}}), graphics={
Line(
points={{0,48},{0,108}}),
Line(
points={{0,70},{40,70}}),
Rectangle(
visible=use_inputFilter,
visible=use_strokeTime,
extent={{-32,40},{34,100}},
lineColor={0,0,0},
fillColor={135,135,135},
fillPattern=FillPattern.Solid),
Ellipse(
visible=use_inputFilter,
visible=use_strokeTime,
extent={{-32,100},{34,40}},
lineColor={0,0,0},
fillColor={135,135,135},
fillPattern=FillPattern.Solid),
Text(
visible=use_inputFilter,
visible=use_strokeTime,
extent={{-20,94},{22,48}},
textColor={0,0,0},
fillColor={135,135,135},
Expand Down Expand Up @@ -119,6 +120,12 @@ for a description of the filter.
</html>", revisions="<html>
<ul>
<li>
August 26, 2024, by Michael Wetter:<br/>
Implemented linear actuator travel dynamics.<br/>
This is for <a href=\"https://github.com/lbl-srg/modelica-buildings/issues/3965\">Buildings, #3965</a> and
for <a href=\"https://github.com/ibpsa/modelica-ibpsa/issues/1926\">IBPSA, #1926</a>.
</li>
<li>
June 10, 2021, by Michael Wetter:<br/>
Changed implementation of the filter and changed the parameter <code>order</code> to a constant
as most users need not change this value.<br/>
Expand Down
61 changes: 29 additions & 32 deletions IBPSA/Fluid/Actuators/BaseClasses/PartialThreeWayValve.mo
Original file line number Diff line number Diff line change
@@ -1,36 +1,33 @@
within IBPSA.Fluid.Actuators.BaseClasses;
partial model PartialThreeWayValve "Partial three way valve"
extends IBPSA.Fluid.BaseClasses.PartialThreeWayResistance(
m_flow_small = m_flow_nominal*1e-4,
final mDyn_flow_nominal = m_flow_nominal,
redeclare replaceable
IBPSA.Fluid.Actuators.BaseClasses.PartialTwoWayValve res1
constrainedby IBPSA.Fluid.Actuators.BaseClasses.PartialTwoWayValve(
deltaM=deltaM,
from_dp=from_dp,
final linearized=linearized[1],
final homotopyInitialization=homotopyInitialization,
final CvData=IBPSA.Fluid.Types.CvTypes.OpPoint,
final m_flow_nominal=m_flow_nominal,
final dpValve_nominal=dpValve_nominal,
final dpFixed_nominal=dpFixed_nominal[1],
final use_inputFilter=false,
final riseTime=riseTime),
redeclare FixedResistances.LosslessPipe res2(
m_flow_nominal=m_flow_nominal),
redeclare replaceable
IBPSA.Fluid.Actuators.BaseClasses.PartialTwoWayValve res3
constrainedby IBPSA.Fluid.Actuators.BaseClasses.PartialTwoWayValve(
deltaM=deltaM,
from_dp=from_dp,
final linearized=linearized[2],
final homotopyInitialization=homotopyInitialization,
final CvData=IBPSA.Fluid.Types.CvTypes.OpPoint,
final m_flow_nominal=m_flow_nominal,
final dpValve_nominal=dpValve_nominal/fraK^2,
final dpFixed_nominal=dpFixed_nominal[2],
final use_inputFilter=false,
final riseTime=riseTime));
m_flow_small=m_flow_nominal*1e-4,
final mDyn_flow_nominal=m_flow_nominal,
redeclare replaceable IBPSA.Fluid.Actuators.BaseClasses.PartialTwoWayValve res1
constrainedby IBPSA.Fluid.Actuators.BaseClasses.PartialTwoWayValve(
deltaM=deltaM,
from_dp=from_dp,
final linearized=linearized[1],
final homotopyInitialization=homotopyInitialization,
final CvData=IBPSA.Fluid.Types.CvTypes.OpPoint,
final m_flow_nominal=m_flow_nominal,
final dpValve_nominal=dpValve_nominal,
final dpFixed_nominal=dpFixed_nominal[1],
final use_strokeTime=false,
final strokeTime=strokeTime),
redeclare FixedResistances.LosslessPipe res2(m_flow_nominal=m_flow_nominal),
redeclare replaceable IBPSA.Fluid.Actuators.BaseClasses.PartialTwoWayValve res3
constrainedby IBPSA.Fluid.Actuators.BaseClasses.PartialTwoWayValve(
deltaM=deltaM,
from_dp=from_dp,
final linearized=linearized[2],
final homotopyInitialization=homotopyInitialization,
final CvData=IBPSA.Fluid.Types.CvTypes.OpPoint,
final m_flow_nominal=m_flow_nominal,
final dpValve_nominal=dpValve_nominal/fraK^2,
final dpFixed_nominal=dpFixed_nominal[2],
final use_strokeTime=false,
final strokeTime=strokeTime));
extends IBPSA.Fluid.Actuators.BaseClasses.ActuatorSignal;
extends IBPSA.Fluid.Actuators.BaseClasses.ValveParameters(
rhoStd=Medium.density_pTX(101325, 273.15+4, Medium.X_default));
Expand Down Expand Up @@ -115,12 +112,12 @@ equation
fillColor=DynamicSelect({0,0,0}, (1-y)*{255,255,255}),
fillPattern=FillPattern.Solid),
Line(
visible=use_inputFilter,
visible=use_strokeTime,
points={{-30,40},{30,40}}),
Line(
points={{0,40},{0,0}}),
Line(
visible=not use_inputFilter,
visible=not use_strokeTime,
points={{0,100},{0,40}})}),
Documentation(info="<html>
<p>
Expand Down
4 changes: 2 additions & 2 deletions IBPSA/Fluid/Actuators/BaseClasses/PartialTwoWayValve.mo
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,12 @@ initial equation
fillColor={255,255,255},
fillPattern=FillPattern.Solid),
Line(
visible=use_inputFilter,
visible=use_strokeTime,
points={{-30,40},{30,40}}),
Line(
points={{0,40},{0,0}}),
Line(
visible=not use_inputFilter,
visible=not use_strokeTime,
points={{0,100},{0,40}})}),
Documentation(info="<html>
<p>
Expand Down
8 changes: 4 additions & 4 deletions IBPSA/Fluid/Actuators/Dampers/Examples/Damper.mo
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ model Damper

IBPSA.Fluid.Actuators.Dampers.Exponential res(
redeclare package Medium = Medium,
use_inputFilter=false,
use_strokeTime=false,
dpDamper_nominal=10,
m_flow_nominal=1,
k1=0.45) "A damper with quadratic relationship between m_flow and dp"
Expand All @@ -33,7 +33,7 @@ model Damper
transformation(extent={{94,-10},{74,10}})));

IBPSA.Fluid.Actuators.Dampers.PressureIndependent preIndDpFixed_nominal(
use_inputFilter=false,
use_strokeTime=false,
redeclare package Medium = Medium,
m_flow_nominal=1,
dpFixed_nominal=5,
Expand All @@ -42,7 +42,7 @@ model Damper
annotation (Placement(transformation(extent={{0,-90},{20,-70}})));

IBPSA.Fluid.Actuators.Dampers.PressureIndependent preIndFrom_dp(
use_inputFilter=false,
use_strokeTime=false,
redeclare package Medium = Medium,
m_flow_nominal=1,
dpFixed_nominal=0,
Expand All @@ -55,7 +55,7 @@ model Damper
redeclare package Medium = Medium,
m_flow_nominal=1,
dpDamper_nominal=10,
use_inputFilter=false)
use_strokeTime=false)
"A damper with a mass flow proportional to the input signal"
annotation (Placement(transformation(extent={{0,-10},{20,10}})));

Expand Down
6 changes: 3 additions & 3 deletions IBPSA/Fluid/Actuators/Dampers/MixingBox.mo
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ model MixingBox "Outside air mixing box with interlocked air dampers"
final k1=k1,
final use_constant_density=use_constant_density,
final allowFlowReversal=allowFlowReversal,
final use_inputFilter=false)
final use_strokeTime=false)
"Outdoor air damper"
annotation (Placement(transformation(extent={{-40,20},{-20,40}})));
IBPSA.Fluid.Actuators.Dampers.Exponential damExh(
Expand All @@ -143,7 +143,7 @@ model MixingBox "Outside air mixing box with interlocked air dampers"
final k1=k1,
final use_constant_density=use_constant_density,
final allowFlowReversal=allowFlowReversal,
final use_inputFilter=false)
final use_strokeTime=false)
"Exhaust air damper"
annotation (Placement(transformation(extent={{-20,-70},{-40,-50}})));
IBPSA.Fluid.Actuators.Dampers.Exponential damRec(
Expand All @@ -165,7 +165,7 @@ model MixingBox "Outside air mixing box with interlocked air dampers"
final k1=k1,
final use_constant_density=use_constant_density,
final allowFlowReversal=allowFlowReversal,
final use_inputFilter=false)
final use_strokeTime=false)
"Recirculation air damper"
annotation (
Placement(transformation(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ model PressureIndependent
"Damper nominal mass flow rate";
IBPSA.Fluid.Actuators.Dampers.Exponential damExp(
redeclare final package Medium = Medium,
use_inputFilter=false,
use_strokeTime=false,
final dpDamper_nominal=dp_nominal,
final m_flow_nominal=m_flow_nominal)
"Damper with exponential opening characteristics"
Expand All @@ -36,12 +36,12 @@ model PressureIndependent
redeclare final package Medium = Medium,
final m_flow_nominal=m_flow_nominal,
final dpDamper_nominal=dp_nominal,
use_inputFilter=false)
use_strokeTime=false)
"Pressure independent damper"
annotation (Placement(transformation(extent={{0,-10},{20,10}})));
Exponential damExpPI(
redeclare final package Medium = Medium,
use_inputFilter=false,
use_strokeTime=false,
final dpDamper_nominal=dp_nominal,
final m_flow_nominal=m_flow_nominal)
"Damper with exponential opening characteristics"
Expand Down
2 changes: 1 addition & 1 deletion IBPSA/Fluid/Actuators/Motors/IdealMotor.mo
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ The output <code>y</code> is bounded between <code>0</code> and <code>1</code>.
<p>
<b>Note:</b> This model can introduce state events which increase the computation time.
For a more efficient implementation that approximates a motor, set in
the valve or damper model the parameter <code>use_inputFilter=true</code>
the valve or damper model the parameter <code>use_strokeTime=true</code>
instead of using this motor model.
See also
<a href=\"modelica://IBPSA.Fluid.Actuators.UsersGuide\">
Expand Down
6 changes: 3 additions & 3 deletions IBPSA/Fluid/Actuators/Valves/Examples/ThreeWayValves.mo
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ model ThreeWayValves "Three way valves with different opening characteristics"
redeclare package Medium = Medium,
l={0.05,0.05},
m_flow_nominal=2,
use_inputFilter=false,
use_strokeTime=false,
dpValve_nominal=6000,
energyDynamics=Modelica.Fluid.Types.Dynamics.FixedInitial)
"Valve model, linear opening characteristics"
Expand Down Expand Up @@ -39,7 +39,7 @@ model ThreeWayValves "Three way valves with different opening characteristics"
redeclare package Medium = Medium,
R=10,
m_flow_nominal=2,
use_inputFilter=false,
use_strokeTime=false,
dpValve_nominal=6000,
energyDynamics=Modelica.Fluid.Types.Dynamics.FixedInitial)
annotation (Placement(transformation(extent={{0,-10},{20,10}})));
Expand All @@ -53,7 +53,7 @@ model ThreeWayValves "Three way valves with different opening characteristics"
IBPSA.Fluid.Actuators.Valves.ThreeWayTable valTab(
redeclare package Medium = Medium,
m_flow_nominal=2,
use_inputFilter=false,
use_strokeTime=false,
dpValve_nominal=6000,
energyDynamics=Modelica.Fluid.Types.Dynamics.FixedInitial,
flowCharacteristics1=IBPSA.Fluid.Actuators.Valves.Data.Linear(),
Expand Down
Loading

0 comments on commit 6701fab

Please sign in to comment.