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

Issue302 inverse x #304

Merged
merged 24 commits into from
Aug 12, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
4903dff
Improved implementation for #301
mwetter Jul 28, 2015
73db3de
Updated reference results for new implementation of flow function
mwetter Jul 29, 2015
9daa91e
Added derivative of flow functions and examples
mwetter Jul 29, 2015
aa15648
Added derivative of flow functions and examples
mwetter Jul 29, 2015
6757a5d
Implemented derivative function for #301
mwetter Jul 30, 2015
7087c0b
Added 2nd order derivative function and revised implementation
mwetter Jul 31, 2015
2d3e94d
Revised implementation for #301
mwetter Aug 5, 2015
c46685f
Updated reference results for #301
mwetter Aug 5, 2015
293fdec
Removed comment as the test is correct
mwetter Aug 5, 2015
33ef9fd
Added validation case for inverse function
mwetter Aug 5, 2015
f445244
Added validation case for inverse function
mwetter Aug 5, 2015
a9b544f
Updated documentation and graphics
mwetter Aug 6, 2015
c905272
Run ttws --clean FlowModels
mwetter Aug 6, 2015
22fb7bf
Reimplemented function and improved unit test
mwetter Aug 11, 2015
dacae17
Updated regression tests for #302
mwetter Aug 11, 2015
4539571
Optimized implementation for #302
mwetter Aug 11, 2015
1046bee
Optimized implementation of inverseXRegularized
mwetter Aug 11, 2015
8178396
Added reference results
mwetter Aug 11, 2015
241a4ef
Updated info section for #302
mwetter Aug 11, 2015
b973890
Improved implementation for #302
mwetter Aug 11, 2015
9ac4201
Delete validation examples as suggested in #301
Aug 12, 2015
95ce999
Merge branch 'master' of https://github.com/iea-annex60/modelica-anne…
Aug 12, 2015
03b81a0
Corrected wrong merge conflict of 95ce999009ad39965b5f00ad8114bbcbfba…
mwetter Aug 12, 2015
8cffd18
Deleted old scripts and reference results for #302
mwetter Aug 12, 2015
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
within Annex60.Fluid.BaseClasses.FlowModels.Validation;
model BasicFlowFunction_dp_DerivativeCheck
"Model that checks the correct implementation of the 1st order derivative of the flow function"
extends Modelica.Icons.Example;

constant Real gain = 2 "Gain for computing the mass flow rate";

parameter Real k = 0.35 "Flow coefficient";
parameter Modelica.SIunits.MassFlowRate m_flow_turbulent = 0.36
"Mass flow rate where transition to turbulent flow occurs";
Modelica.SIunits.MassFlowRate m_flow "Mass flow rate";
Modelica.SIunits.MassFlowRate m_flow_comp "Comparison value for m_flow";
Modelica.SIunits.Pressure dp "Pressure drop";
Modelica.SIunits.MassFlowRate err "Integration error";
initial equation
m_flow = m_flow_comp;
equation
dp = time*gain;
m_flow = Annex60.Fluid.BaseClasses.FlowModels.basicFlowFunction_dp(
dp=dp,
k= k,
m_flow_turbulent=m_flow_turbulent);
der(m_flow) = der(m_flow_comp);
err = m_flow-m_flow_comp;
assert(abs(err) < 1E-3, "Error in implementation.");
annotation (
experiment(
StartTime=-2,
StopTime=2,
Tolerance=1e-08),
__Dymola_Commands(file="modelica://Annex60/Resources/Scripts/Dymola/Fluid/BaseClasses/FlowModels/Validation/BasicFlowFunction_dp_DerivativeCheck.mos"
"Simulate and plot"),
Documentation(info="<html>
<p>
This model validates the implementation of
<a href=\"modelica://Annex60.Fluid.BaseClasses.FlowModels.basicFlowFunction_dp\">
Annex60.Fluid.BaseClasses.FlowModels.basicFlowFunction_dp</a>
and its first order derivative
<a href=\"modelica://Annex60.Fluid.BaseClasses.FlowModels.basicFlowFunction_dp_der\">
Annex60.Fluid.BaseClasses.FlowModels.basicFlowFunction_dp_der</a>.
If the derivative implementation is wrong, the simulation will stop with an error.
</p>
</html>",
revisions="<html>
<ul>
<li>
July 29, 2015, by Michael Wetter:<br/>
First implementation.
</li>
</ul>
</html>"));
end BasicFlowFunction_dp_DerivativeCheck;
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
within Annex60.Fluid.BaseClasses.FlowModels.Validation;
model BasicFlowFunction_dp_DerivativeCheck2
"Model that checks the correct implementation of the 2nd order derivative of the flow function"
extends Modelica.Icons.Example;

parameter Real k = 0.35 "Flow coefficient";
parameter Modelica.SIunits.MassFlowRate m_flow_turbulent = 0.36
"Mass flow rate where transition to turbulent flow occurs";
Modelica.SIunits.MassFlowRate m_flow "Mass flow rate";
Modelica.SIunits.MassFlowRate m_flow_comp "Comparison value for m_flow";
Real der_m_flow(unit="kg/s2") "1st order derivative of mass flow rate";
Real der_m_flow_comp(unit="kg/s2")
"2nd order derivative of comparison value for m_flow";

Modelica.SIunits.Pressure dp "Pressure drop";
Modelica.SIunits.MassFlowRate err_m_flow "Integration error for m_flow";
Real err_der_m_flow(unit="kg/s2") "Integration error for der_m_flow";
initial equation
m_flow = m_flow_comp;
der_m_flow = der_m_flow_comp;
equation
// Multiply by 1 to avoid a warning due to unit mismatch,
// and raise to third power so that dp_der2 has positive and negative sign
// in Annex60.Fluid.BaseClasses.FlowModels.basicFlowFunction_dp_der2
dp = 1*time^3;

m_flow = Annex60.Fluid.BaseClasses.FlowModels.basicFlowFunction_dp(
dp=dp,
k= k,
m_flow_turbulent=m_flow_turbulent);

// Equate first and second order derivatives
der_m_flow = der(m_flow);
der_m_flow_comp = der(m_flow_comp);
der(der_m_flow) = der(der_m_flow_comp);

// Error control
err_m_flow = m_flow-m_flow_comp;
assert(abs(err_m_flow) < 1E-3, "Error in implementation.");
err_der_m_flow = der_m_flow-der_m_flow_comp;
assert(abs(err_der_m_flow) < 1E-3, "Error in implementation.");
annotation (
experiment(
StartTime=-2,
StopTime=2,
Tolerance=1e-08),
__Dymola_Commands(file="modelica://Annex60/Resources/Scripts/Dymola/Fluid/BaseClasses/FlowModels/Validation/BasicFlowFunction_dp_DerivativeCheck2.mos"
"Simulate and plot"),
Documentation(info="<html>
<p>
This model validates the implementation of
<a href=\"modelica://Annex60.Fluid.BaseClasses.FlowModels.basicFlowFunction_dp\">
Annex60.Fluid.BaseClasses.FlowModels.basicFlowFunction_dp</a>
and its second order derivative
<a href=\"modelica://Annex60.Fluid.BaseClasses.FlowModels.basicFlowFunction_dp_der2\">
Annex60.Fluid.BaseClasses.FlowModels.basicFlowFunction_dp_der2</a>.
If the derivative implementation is wrong, the simulation will stop with an error.
</p>
<h4>Implementation</h4>
<p>
The pressure drop <code>dp</code> is increased non-linearly in order
for the first and second derivatives in
<a href=\"modelica://Annex60.Fluid.BaseClasses.FlowModels.basicFlowFunction_dp_der2\">
Annex60.Fluid.BaseClasses.FlowModels.basicFlowFunction_dp_der2</a>
to be non-zero during part of the simulation. This will ensure
full code coverage of this function.
</p>
</html>",
revisions="<html>
<ul>
<li>
July 29, 2015, by Michael Wetter:<br/>
First implementation.
</li>
</ul>
</html>"));
end BasicFlowFunction_dp_DerivativeCheck2;
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
within Annex60.Fluid.BaseClasses.FlowModels.Validation;
model BasicFlowFunction_m_flow_DerivativeCheck
"Model that checks the correct implementation of the 1st order derivative of the flow function"
extends Modelica.Icons.Example;

constant Real gain = 0.5 "Gain for computing the mass flow rate";

parameter Real k = 0.35 "Flow coefficient";
parameter Modelica.SIunits.MassFlowRate m_flow_turbulent = 0.36
"Mass flow rate where transition to turbulent flow occurs";
Modelica.SIunits.MassFlowRate m_flow "Mass flow rate";
Modelica.SIunits.Pressure dp "Pressure drop";
Modelica.SIunits.Pressure dp_comp "Comparison value for dp";
Modelica.SIunits.PressureDifference err "Integration error";
initial equation
dp = dp_comp;
equation
m_flow = time*gain;
dp = Annex60.Fluid.BaseClasses.FlowModels.basicFlowFunction_m_flow(
m_flow=m_flow,
k= k,
m_flow_turbulent=m_flow_turbulent);
der(dp) = der(dp_comp);
err = dp-dp_comp;
assert(abs(err) < 1E-3, "Error in implementation.");
annotation (
experiment(StartTime=-1,
StopTime=1.0,
Tolerance=1e-08),
__Dymola_Commands(file="modelica://Annex60/Resources/Scripts/Dymola/Fluid/BaseClasses/FlowModels/Validation/BasicFlowFunction_m_flow_DerivativeCheck.mos"
"Simulate and plot"),
Documentation(info="<html>
<p>
This model validates the implementation of
<a href=\"modelica://Annex60.Fluid.BaseClasses.FlowModels.basicFlowFunction_m_flow\">
Annex60.Fluid.BaseClasses.FlowModels.basicFlowFunction_m_flow</a>
and its first order derivative
<a href=\"modelica://Annex60.Fluid.BaseClasses.FlowModels.basicFlowFunction_m_flow_der\">
Annex60.Fluid.BaseClasses.FlowModels.basicFlowFunction_m_flow_der</a>.
If the derivative implementation is wrong, the simulation will stop with an error.
</p>
</html>",
revisions="<html>
<ul>
<li>
July 29, 2015, by Michael Wetter:<br/>
First implementation.
</li>
</ul>
</html>"));
end BasicFlowFunction_m_flow_DerivativeCheck;
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
within Annex60.Fluid.BaseClasses.FlowModels.Validation;
model BasicFlowFunction_m_flow_DerivativeCheck2
"Model that checks the correct implementation of the 2nd order derivative of the flow function"
extends Modelica.Icons.Example;

parameter Real k = 0.35 "Flow coefficient";
parameter Modelica.SIunits.MassFlowRate m_flow_turbulent = 0.36
"Mass flow rate where transition to turbulent flow occurs";
Modelica.SIunits.PressureDifference dp "Pressure drop";
Modelica.SIunits.PressureDifference dp_comp "Comparison value for dp";
Real der_dp(unit="Pa/s") "1st order derivative of pressure drop";
Real der_dp_comp(unit="Pa/s")
"2nd order derivative of comparison value for pressure drop";

Modelica.SIunits.MassFlowRate m_flow "Mass flow rate";

Modelica.SIunits.PressureDifference err_dp "Integration error for dp";
Real err_der_dp(unit="Pa/s") "Integration error for der_dp";
initial equation
dp = dp_comp;
der_dp = der_dp_comp;
equation
// Divide by 8 to avoid a warning due to unit mismatch, and
// and raise to third power so that m_flow_der2 has positive and negative sign
// in Annex60.Fluid.BaseClasses.FlowModels.basicFlowFunction_m_flow_der2
m_flow = time^3/8;

dp = Annex60.Fluid.BaseClasses.FlowModels.basicFlowFunction_m_flow(
m_flow=m_flow,
k= k,
m_flow_turbulent=m_flow_turbulent);

// Equate first and second order derivatives
der_dp = der(dp);
der_dp_comp = der(dp_comp);
der(der_dp) = der(der_dp_comp);

// Error control
err_dp = dp-dp_comp;
assert(abs(err_dp) < 1E-3, "Error in implementation.");
err_der_dp = der_dp-der_dp_comp;
assert(abs(err_der_dp) < 1E-3, "Error in implementation.");
annotation (
experiment(
StartTime=-2,
StopTime=2,
Tolerance=1e-08),
__Dymola_Commands(file="modelica://Annex60/Resources/Scripts/Dymola/Fluid/BaseClasses/FlowModels/Validation/BasicFlowFunction_m_flow_DerivativeCheck2.mos"
"Simulate and plot"),
Documentation(info="<html>
<p>
This model validates the implementation of
<a href=\"modelica://Annex60.Fluid.BaseClasses.FlowModels.basicFlowFunction_m_flow\">
Annex60.Fluid.BaseClasses.FlowModels.basicFlowFunction_m_flow</a>
and its second order derivative
<a href=\"modelica://Annex60.Fluid.BaseClasses.FlowModels.basicFlowFunction_m_flow_der2\">
Annex60.Fluid.BaseClasses.FlowModels.basicFlowFunction_m_flow_der2</a>.
If the derivative implementation is wrong, the simulation will stop with an error.
</p>
<h4>Implementation</h4>
<p>
The mass flow rate <code>m_flow</code> is increased non-linearly in order
for the first and second derivatives in
<a href=\"modelica://Annex60.Fluid.BaseClasses.FlowModels.basicFlowFunction_m_flow_der2\">
Annex60.Fluid.BaseClasses.FlowModels.basicFlowFunction_m_flow_der2</a>
to be non-zero during part of the simulation. This will ensure
full code coverage of this function.
</p>
</html>",
revisions="<html>
<ul>
<li>
July 29, 2015, by Michael Wetter:<br/>
First implementation.
</li>
</ul>
</html>"));
end BasicFlowFunction_m_flow_DerivativeCheck2;
71 changes: 0 additions & 71 deletions Annex60/Fluid/BaseClasses/FlowModels/Validation/FirstDerivative.mo

This file was deleted.

36 changes: 0 additions & 36 deletions Annex60/Fluid/BaseClasses/FlowModels/Validation/FlowFunctions.mo

This file was deleted.