Skip to content

Commit

Permalink
Merge branch 'master' into issue147_moversRecord
Browse files Browse the repository at this point in the history
  • Loading branch information
mwetter committed Feb 27, 2015
2 parents 9762a26 + 20b2b34 commit a304e4d
Show file tree
Hide file tree
Showing 49 changed files with 709 additions and 208 deletions.
6 changes: 3 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ dsfinal.txt
dsin.txt
dslog.txt
dsmodel.c
dsmodelext[0-9].c
dsmodelext[0-9].obj
dsmodelext*.c
dsmodelext*.obj
dsres.txt
dymosim.exe
dymosim.exp
Expand All @@ -20,4 +20,4 @@ status
stop
# Ignore files created by the unit tests.
simulator.log
unitTests.log
unitTests.log
7 changes: 6 additions & 1 deletion Annex60/Experimental/Media/AirPTDecoupled.mo
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ package AirPTDecoupled
end ThermodynamicState;

redeclare replaceable model extends BaseProperties(
T(stateSelect=if preferredMediumStates then StateSelect.prefer else StateSelect.default),
p(stateSelect=if preferredMediumStates then StateSelect.prefer else StateSelect.default),
Xi(each stateSelect=if preferredMediumStates then StateSelect.prefer else StateSelect.default),
final standardOrderComponents=true) "Base properties"
Expand Down Expand Up @@ -778,6 +777,12 @@ The air is assumed to be not saturated.
</html>", revisions="<html>
<ul>
<li>
February 3, 2015, by Michael Wetter:<br/>
Removed <code>stateSelect.prefer</code> for temperature.
This is for
<a href=\"https://github.com/iea-annex60/modelica-annex60/issues/160\">#160</a>.
</li>
<li>
July 24, 2014, by Michael Wetter:<br/>
Changed implementation to use
<a href=\"modelica://Annex60.Utilities.Psychrometrics.Constants\">
Expand Down
16 changes: 13 additions & 3 deletions Annex60/Fluid/Actuators/BaseClasses/PartialDamperExponential.mo
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ partial model PartialDamperExponential
annotation(Dialog(tab="Damper coefficients"));
parameter Boolean use_constant_density=true
"Set to true to use constant density for flow friction"
annotation (Dialog(tab="Advanced"));
annotation (Evaluate=true, Dialog(tab="Advanced"));
Medium.Density rho "Medium density";
parameter Real kFixed(unit="")
"Flow coefficient of fixed resistance that may be in series with damper, k=m_flow/sqrt(dp), with unit=(kg.m)^(1/2).";
Expand Down Expand Up @@ -67,8 +67,9 @@ initial equation
assert(m_flow_turbulent > 0, "m_flow_turbulent must be bigger than zero.");
equation
rho = if use_constant_density then
rho_default else
Medium.density(Medium.setState_phX(port_a.p, inStream(port_a.h_outflow), inStream(port_a.Xi_outflow)));
rho_default
else
Medium.density(Medium.setState_phX(port_a.p, inStream(port_a.h_outflow), inStream(port_a.Xi_outflow)));
// flow coefficient, k=m_flow/sqrt(dp)
kDam=sqrt(2*rho)*area/Annex60.Fluid.Actuators.BaseClasses.exponentialDamper(
y=y_actual,
Expand Down Expand Up @@ -125,6 +126,15 @@ Exponential</a>.
revisions="<html>
<ul>
<li>
January 27, 2015 by Michael Wetter:<br/>
Set <code>Evaluate=true</code> for <code>use_constant_density</code>.
This is a structural parameter. Adding this annotation leads to fewer
numerical Jacobians for
<code>Buildings.Examples.VAVReheat.ClosedLoop</code>
with
<code>Buildings.Media.PerfectGases.MoistAirUnsaturated</code>.
</li>
<li>
December 14, 2012 by Michael Wetter:<br/>
Renamed protected parameters for consistency with the naming conventions.
</li>
Expand Down
53 changes: 11 additions & 42 deletions Annex60/Fluid/Actuators/BaseClasses/PartialTwoWayValve.mo
Original file line number Diff line number Diff line change
Expand Up @@ -29,39 +29,7 @@ protected
initial equation
assert(dpFixed_nominal > -Modelica.Constants.small, "Require dpFixed_nominal >= 0. Received dpFixed_nominal = "
+ String(dpFixed_nominal) + " Pa.");
equation
kVal = phi*Kv_SI;
if (dpFixed_nominal > Modelica.Constants.eps) then
k = sqrt(1/(1/kFixed^2 + 1/kVal^2));
else
k = kVal;
end if;

if linearized then
// This implementation yields m_flow_nominal = phi*kv_SI * sqrt(dp_nominal)
// if m_flow = m_flow_nominal and dp = dp_nominal
m_flow*m_flow_nominal_pos = k^2 * dp;
else
if homotopyInitialization then
if from_dp then
m_flow=homotopy(actual=Annex60.Fluid.BaseClasses.FlowModels.basicFlowFunction_dp(dp=dp, k=k,
m_flow_turbulent=m_flow_turbulent),
simplified=m_flow_nominal_pos*dp/dp_nominal_pos);
else
dp=homotopy(actual=Annex60.Fluid.BaseClasses.FlowModels.basicFlowFunction_m_flow(m_flow=m_flow, k=k,
m_flow_turbulent=m_flow_turbulent),
simplified=dp_nominal_pos*m_flow/m_flow_nominal_pos);
end if;
else // do not use homotopy
if from_dp then
m_flow=Annex60.Fluid.BaseClasses.FlowModels.basicFlowFunction_dp(dp=dp, k=k,
m_flow_turbulent=m_flow_turbulent);
else
dp=Annex60.Fluid.BaseClasses.FlowModels.basicFlowFunction_m_flow(m_flow=m_flow, k=k,
m_flow_turbulent=m_flow_turbulent);
end if;
end if; // homotopyInitialization
end if; // linearized
annotation (Icon(coordinateSystem(preserveAspectRatio=true, extent={{-100,-100},
{100,100}}), graphics={
Polygon(
Expand Down Expand Up @@ -98,8 +66,8 @@ equation
Documentation(info="<html>
<p>
Partial model for a two way valve. This is the base model for valves
with different opening characteristics, such as linear, equal percentage
or quick opening.
with different opening characteristics, such as linear, equal percentage,
quick opening or pressure-independent.
</p>
<p>
To prevent the derivative <code>d/dP (m_flow)</code> to be infinite near
Expand Down Expand Up @@ -134,18 +102,19 @@ The two way valve models are implemented using this partial model, as opposed to
different functions for the valve opening characteristics, because
each valve opening characteristics has different parameters.
</p>
<h4>Implementation</h4>
<p>
Models that extend this model need to provide a binding equation
for the flow function <code>phi</code>.
An example of such a code can be found in
<a href=\"modelica://Annex60.Fluid.Actuators.Valves.TwoWayLinear\">
Annex60.Fluid.Actuators.Valves.TwoWayLinear</a>.
</p>
</html>",
revisions="<html>
<ul>
<li>
January 29, 2015, by Filip Jorissen:<br/>
Moved the governing equations to
<a href=\"modelica://Annex60.Fluid.Actuators.BaseClasses.PartialTwoWayValveKv\">
PartialTwoWayValveKv</a>
in order to be able to extend from this partial in
<a href=\"modelica://Annex60.Fluid.Actuators.Valves.TwoWayPressureIndependent\">
TwoWayPressureIndependent</a>
</li>
<li>
August 8, 2014, by Michael Wetter:<br/>
Reformulated the computation of <code>k</code> to make the model
work in OpenModelica.
Expand Down
96 changes: 96 additions & 0 deletions Annex60/Fluid/Actuators/BaseClasses/PartialTwoWayValveKv.mo
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
within Annex60.Fluid.Actuators.BaseClasses;
partial model PartialTwoWayValveKv
"Partial model for a two way valve using a Kv characteristic"
extends Annex60.Fluid.Actuators.BaseClasses.PartialTwoWayValve;

equation
kVal = phi*Kv_SI;
if (dpFixed_nominal > Modelica.Constants.eps) then
k = sqrt(1/(1/kFixed^2 + 1/kVal^2));
else
k = kVal;
end if;

if linearized then
// This implementation yields m_flow_nominal = phi*kv_SI * sqrt(dp_nominal)
// if m_flow = m_flow_nominal and dp = dp_nominal
m_flow*m_flow_nominal_pos = k^2 * dp;
else
if homotopyInitialization then
if from_dp then
m_flow=homotopy(actual=Annex60.Fluid.BaseClasses.FlowModels.basicFlowFunction_dp(dp=dp, k=k,
m_flow_turbulent=m_flow_turbulent),
simplified=m_flow_nominal_pos*dp/dp_nominal_pos);
else
dp=homotopy(actual=Annex60.Fluid.BaseClasses.FlowModels.basicFlowFunction_m_flow(m_flow=m_flow, k=k,
m_flow_turbulent=m_flow_turbulent),
simplified=dp_nominal_pos*m_flow/m_flow_nominal_pos);
end if;
else // do not use homotopy
if from_dp then
m_flow=Annex60.Fluid.BaseClasses.FlowModels.basicFlowFunction_dp(dp=dp, k=k,
m_flow_turbulent=m_flow_turbulent);
else
dp=Annex60.Fluid.BaseClasses.FlowModels.basicFlowFunction_m_flow(m_flow=m_flow, k=k,
m_flow_turbulent=m_flow_turbulent);
end if;
end if; // homotopyInitialization
end if; // linearized
annotation (Icon(coordinateSystem(preserveAspectRatio=true, extent={{-100,-100},
{100,100}}), graphics={
Polygon(
points={{2,-2},{-76,60},{-76,-60},{2,-2}},
lineColor={0,0,0},
fillColor={0,0,0},
fillPattern=FillPattern.Solid),
Polygon(
points={{-50,40},{0,-2},{54,40},{54,40},{-50,40}},
lineColor={0,0,255},
pattern=LinePattern.None,
fillColor={255,255,255},
fillPattern=FillPattern.Solid),
Polygon(
points={{-52,-42},{0,-4},{60,40},{60,-42},{-52,-42}},
lineColor={0,0,255},
pattern=LinePattern.None,
fillColor={255,255,255},
fillPattern=FillPattern.Solid),
Polygon(
points={{0,-2},{82,60},{82,-60},{0,-2}},
lineColor={0,0,0},
fillColor={255,255,255},
fillPattern=FillPattern.Solid),
Line(
points={{0,40},{0,-4}},
color={0,0,0},
smooth=Smooth.None),
Line(
visible=not filteredOpening,
points={{0,100},{0,40}},
color={0,0,0},
smooth=Smooth.None)}),
Documentation(info="<html>
<p>
Partial model for valves with different opening characteristics,
such as linear, equal percentage or quick opening. This partial extends from
<a href=\"modelica://Annex60.Fluid.Actuators.BaseClasses.PartialTwoWayValve\">PartialTwoWayValve</a>
and also contains the governing equations for these three two way valve models.
</p>
<h4>Implementation</h4>
<p>
Models that extend this model need to provide a binding equation
for the flow function <code>phi</code>.
An example of such a code can be found in
<a href=\"modelica://Annex60.Fluid.Actuators.Valves.TwoWayLinear\">
Annex60.Fluid.Actuators.Valves.TwoWayLinear</a>.
</p>
</html>",
revisions="<html>
<ul>
<li>
January 29, 2015 by Filip Jorissen:<br/>
First implementation.
</li>
</ul>
</html>"));
end PartialTwoWayValveKv;
1 change: 1 addition & 0 deletions Annex60/Fluid/Actuators/BaseClasses/package.order
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ ActuatorSignal
PartialDamperExponential
PartialThreeWayValve
PartialTwoWayValve
PartialTwoWayValveKv
ValveParameters
der_equalPercentage
equalPercentage
Expand Down
57 changes: 29 additions & 28 deletions Annex60/Fluid/Actuators/Valves/Examples/ThreeWayValves.mo
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@ within Annex60.Fluid.Actuators.Valves.Examples;
model ThreeWayValves "Three way valves with different opening characteristics"
extends Modelica.Icons.Example;

package Medium = Annex60.Media.Water.Simple
"Medium in the component";
package Medium = Annex60.Media.Water.Simple "Medium in the component";

Annex60.Fluid.Actuators.Valves.ThreeWayLinear valLin(
redeclare package Medium = Medium,
Expand All @@ -13,28 +12,28 @@ model ThreeWayValves "Three way valves with different opening characteristics"
dpValve_nominal=6000,
energyDynamics=Modelica.Fluid.Types.Dynamics.FixedInitial)
"Valve model, linear opening characteristics"
annotation (Placement(transformation(extent={{0,-8},{20,12}})));
Modelica.Blocks.Sources.Ramp y(
annotation (Placement(transformation(extent={{0,-8},{20,12}})));
Modelica.Blocks.Sources.Ramp y(
height=1,
duration=1,
offset=0) "Control signal"
annotation (Placement(transformation(extent={{-40,30},{-20,50}})));
Annex60.Fluid.Sources.Boundary_pT sou( redeclare package Medium
= Medium,
annotation (Placement(transformation(extent={{-40,30},{-20,50}})));
Annex60.Fluid.Sources.Boundary_pT sou(
redeclare package Medium = Medium,
nPorts=2,
use_p_in=true,
T=313.15) annotation (Placement(
transformation(extent={{-50,-10},{-30,10}})));
Annex60.Fluid.Sources.Boundary_pT sin( redeclare package Medium
= Medium,
T=313.15) "Boundary condition for flow source"
annotation (Placement(transformation(extent={{-50,-10},{-30,10}})));
Annex60.Fluid.Sources.Boundary_pT sin(
redeclare package Medium = Medium,
nPorts=2,
use_p_in=true,
T=313.15) annotation (Placement(
transformation(extent={{70,-10},{50,10}})));
Modelica.Blocks.Sources.Constant PSin(k=3E5)
annotation (Placement(transformation(extent={{60,60},{80,80}})));
Modelica.Blocks.Sources.Constant PSou(k=306000)
annotation (Placement(transformation(extent={{-88,-2},{-68,18}})));
T=313.15) "Boundary condition for flow sink"
annotation (Placement(transformation(extent={{70,-10},{50,10}})));
Modelica.Blocks.Sources.Constant PSin(k=3E5)
annotation (Placement(transformation(extent={{60,60},{80,80}})));
Modelica.Blocks.Sources.Constant PSou(k=306000)
annotation (Placement(transformation(extent={{-88,-2},{-68,18}})));
Actuators.Valves.ThreeWayEqualPercentageLinear valEquPerLin(
l={0.05,0.05},
redeclare package Medium = Medium,
Expand All @@ -48,19 +47,18 @@ model ThreeWayValves "Three way valves with different opening characteristics"
redeclare package Medium = Medium,
nPorts=2,
use_p_in=true,
T=303.15) annotation (Placement(
transformation(extent={{10,-10},{-10,10}}, origin={64,-70})));
T=303.15) "Boundary condition for flow sink" annotation (Placement(
transformation(extent={{10,-10},{-10,10}}, origin={64,-70})));

equation
connect(y.y, valLin.y) annotation (Line(
points={{-19,40},{10,40},{10,14}},
color={0,0,127},
pattern=LinePattern.None));
connect(PSin.y, sin.p_in) annotation (Line(points={{81,70},{86,70},{86,8},{72,
8}}, color={0,0,127}));
connect(y.y, valEquPerLin.y) annotation (Line(points={{-19,40},{-12,40},{-12,
-28},{10,-28},{10,-38}},
color={0,0,127}));
connect(PSin.y, sin.p_in)
annotation (Line(points={{81,70},{86,70},{86,8},{72,8}}, color={0,0,127}));
connect(y.y, valEquPerLin.y) annotation (Line(points={{-19,40},{-12,40},{-12,-28},
{10,-28},{10,-38}}, color={0,0,127}));
connect(sou.ports[1], valLin.port_1) annotation (Line(
points={{-30,2},{-5.55112e-16,2}},
color={0,127,255},
Expand Down Expand Up @@ -90,11 +88,12 @@ equation
color={0,127,255},
smooth=Smooth.None));
connect(PSou.y, sou.p_in) annotation (Line(
points={{-67,8},{-59.5,8},{-59.5,8},{-52,8}},
points={{-67,8},{-52,8}},
color={0,0,127},
smooth=Smooth.None));
annotation (experiment(StopTime=1.0),
__Dymola_Commands(file="modelica://Annex60/Resources/Scripts/Dymola/Fluid/Actuators/Valves/Examples/ThreeWayValves.mos"
annotation (
experiment(StopTime=1.0),
__Dymola_Commands(file="modelica://Annex60/Resources/Scripts/Dymola/Fluid/Actuators/Valves/Examples/ThreeWayValves.mos"
"Simulate and plot"),
Documentation(info="<html>
<p>
Expand All @@ -115,5 +114,7 @@ June 16, 2008 by Michael Wetter:<br/>
First implementation.
</li>
</ul>
</html>"));
</html>"),
Diagram(coordinateSystem(preserveAspectRatio=false, extent={{-100,-100},{100,
100}}), graphics));
end ThreeWayValves;
Loading

0 comments on commit a304e4d

Please sign in to comment.