Skip to content

Commit

Permalink
get rid of NumberOfIntervals
Browse files Browse the repository at this point in the history
related to issue thorade#21
  • Loading branch information
thorade committed Oct 10, 2014
1 parent 205a063 commit b512e63
Show file tree
Hide file tree
Showing 18 changed files with 215 additions and 217 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,5 @@ equation

annotation (experiment(
StopTime=7,
NumberOfIntervals=10000,
Tolerance=1e-005));
end Ancillary_Saturation;
Original file line number Diff line number Diff line change
Expand Up @@ -53,5 +53,5 @@ equation
p_dT_Waals = Medium.Ancillary.pressure_dT_Waals(d=d, T=T);
T_pd_Waals = Medium.Ancillary.temperature_pd_Waals(p=p, d=d);

annotation (experiment(StopTime=12, NumberOfIntervals=10000));
annotation (experiment(StopTime=12));
end Ancillary_StartValues;
Original file line number Diff line number Diff line change
Expand Up @@ -44,5 +44,5 @@ equation
eta=Medium.dynamicViscosity(state);
lambda=Medium.thermalConductivity(state);

annotation (experiment(StopTime=12, NumberOfIntervals=10000));
annotation (experiment(StopTime=12));
end SinglePhase_Transport;
Original file line number Diff line number Diff line change
Expand Up @@ -56,5 +56,5 @@ equation
state_ps=Medium.setState_ps(p=Medium.pressure(state), s=Medium.specificEntropy(state), phase=0);
state_Ts=Medium.setState_Ts(T=Medium.temperature(state), s=Medium.specificEntropy(state), phase=0);

annotation (experiment(StopTime=12, NumberOfIntervals=1000));
annotation (experiment(StopTime=12));
end SinglePhase_setState_a;
Original file line number Diff line number Diff line change
Expand Up @@ -56,5 +56,5 @@ equation
state_ps=Medium.setState_ps(p=Medium.pressure(state), s=Medium.specificEntropy(state), phase=0);
state_Ts=Medium.setState_Ts(T=Medium.temperature(state), s=Medium.specificEntropy(state), phase=0);

annotation (experiment(StopTime=12, NumberOfIntervals=1000));
annotation (experiment(StopTime=12));
end SinglePhase_setState_b;
Original file line number Diff line number Diff line change
Expand Up @@ -54,5 +54,5 @@ equation
state_ps=Medium.setState_ps(p=Medium.pressure(state), s=Medium.specificEntropy(state), phase=0);
//state_Ts=Medium.setState_Ts(T=Medium.temperature(state), s=Medium.specificEntropy(state), phase=0);

annotation (experiment(StopTime=12, NumberOfIntervals=10000));
annotation (experiment(StopTime=12));
end SinglePhase_setState_b_Water;
Original file line number Diff line number Diff line change
Expand Up @@ -39,5 +39,5 @@ equation
state_ps=Medium.setState_ps(p=state.p, s=state.s, phase=0);
state_Ts=Medium.setState_Ts(T=state.T, s=state.s, phase=0);

annotation (experiment(StopTime=12, NumberOfIntervals=10000));
annotation (experiment(StopTime=12));
end TwoPhase_setState;
1 change: 0 additions & 1 deletion HelmholtzMedia/Examples/ConvergenceTest/setSat.mo
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,5 @@ equation

annotation (experiment(
StopTime=10,
NumberOfIntervals=10000,
Tolerance=1e-005));
end setSat;
2 changes: 1 addition & 1 deletion HelmholtzMedia/Examples/Parameter/SinglePhase_setState.mo
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,5 @@ equation
state_ps=Medium.setState_ps(p=state.p, s=state.s, phase=0);
state_Ts=Medium.setState_Ts(T=state.T, s=state.s, phase=0);

annotation (experiment(StopTime=12, NumberOfIntervals=10000));
annotation (experiment(StopTime=12));
end SinglePhase_setState;
1 change: 0 additions & 1 deletion HelmholtzMedia/Examples/Parameter/setSat_parameter.mo
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,4 @@ equation
sat_dl = Medium.setSat_d(d=sat.liq.d);
sat_dv = Medium.setSat_d(d=sat.vap.d);

annotation (experiment(NumberOfIntervals=1));
end setSat_parameter;
360 changes: 182 additions & 178 deletions HelmholtzMedia/Examples/Validation/Derivatives_Helmholtz.mo

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ model Derivatives_Helmholtz_Multiplied
parameter Medium.Temperature T=500;

protected
final constant Boolean appendToFile = false;
final constant String fileName = "HelmholtzDerivs_multiplied.csv";
final constant String Separator = ";";

Expand Down Expand Up @@ -56,11 +55,8 @@ algorithm
f_num.rdd := (Medium.EoS.f_rd(tau=tau, delta=delta+eps)-Medium.EoS.f_rd(tau=tau, delta=delta-eps))/(2*eps);
f_num.rddd := (Medium.EoS.f_rdd(tau=tau, delta=delta+eps)-Medium.EoS.f_rdd(tau=tau, delta=delta-eps))/(2*eps);

if (time<=0) then
if not appendToFile then
// remove old file
Modelica.Utilities.Files.remove(fileName);
end if;
when initial() then
if not Modelica.Utilities.Files.exist(fileName) then
// print headers
Modelica.Utilities.Streams.print("" +Separator
+ "" +Separator
Expand Down Expand Up @@ -216,7 +212,9 @@ algorithm
+ String(f_NBP.rttd*f_NBP.tau*f_NBP.tau*f_NBP.delta)+Separator,
fileName);
end if;
end when;

when terminal() then
// print non-fixed values
Modelica.Utilities.Streams.print(String(f.T) + Separator
+ String(f.d) + Separator
Expand Down Expand Up @@ -256,6 +254,7 @@ algorithm
+ String(f_num.rtdd*f_num.tau*f_num.delta*f_num.delta)+Separator
+ String(f_num.rttd*f_num.tau*f_num.tau*f_num.delta)+Separator,
fileName);
end when;

annotation (experiment(NumberOfIntervals=1));
annotation (experiment(Interval=1));
end Derivatives_Helmholtz_Multiplied;
Original file line number Diff line number Diff line change
Expand Up @@ -569,5 +569,5 @@ equation
Modelica.Utilities.Streams.print(" (d mu/dp)@h=const analytical2= " + String(dmuph_analytical2));
Modelica.Utilities.Streams.print(" (d mu/dp)@h=const numerical= " + String(dmuph_numerical));
annotation (experiment(NumberOfIntervals=1));
annotation (experiment(Interval=1));
end Derivatives_SinglePhase;
2 changes: 1 addition & 1 deletion HelmholtzMedia/Examples/Validation/Derivatives_TwoPhase.mo
Original file line number Diff line number Diff line change
Expand Up @@ -218,5 +218,5 @@ equation
Modelica.Utilities.Streams.print(" (dh/dT)@d=const analytical1= " + String(dhTd_analytical1));
Modelica.Utilities.Streams.print(" (dh/dT)@d=const analytical2= " + String(dhTd_analytical2));
annotation (experiment(NumberOfIntervals=1));
annotation (experiment(Interval=1));
end Derivatives_TwoPhase;
12 changes: 6 additions & 6 deletions HelmholtzMedia/Examples/Validation/ReferenceState.mo
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,11 @@ model ReferenceState

input String fileName = "ReferenceState_.csv";
input String separator = ";";
Medium.ReferenceState ref=Medium.ReferenceState.IIR;
Medium.ReferenceState ref=Medium.ReferenceState.NBP;
output Medium.SpecificEnthalpy h_ref;
output Medium.SpecificEntropy s_ref;

protected
Boolean hasBeenExecuted;
Medium.SaturationProperties sat;
final constant Medium.Temperature T_IIR = 273.15; // 0°C;
final constant Medium.Temperature T_ASHRAE = 233.15; // -40°C;
Expand All @@ -29,21 +28,22 @@ algorithm
s_ref := Medium.bubbleEntropy(sat);
h_ref := Medium.bubbleEnthalpy(sat);

if not hasBeenExecuted then
if not Modelica.Utilities.Files.exist(fileName) then
// if file doesn't exist, create file and print header
Modelica.Utilities.Streams.print("idealPower1" + separator
+"sref" + separator
+"idealPower2" + separator
+"href" + separator,
fileName);
end if;

when terminal() then
Modelica.Utilities.Streams.print( String(Medium.helmholtzCoefficients.idealPower[1,1],significantDigits=15) + separator
+String(s_ref,significantDigits=15) + separator
+String(Medium.helmholtzCoefficients.idealPower[2,1],significantDigits=15) + separator
+String(h_ref,significantDigits=15) + separator,
fileName);
hasBeenExecuted := true;
end if;
end when;

annotation (
Documentation(info="<html>
Expand All @@ -63,6 +63,6 @@ there are at least three standard reference states:

</dl>
</html>"),
experiment(NumberOfIntervals=1, Tolerance=1e-012),
experiment(Tolerance=1e-012),
__Dymola_experimentSetupOutput(doublePrecision=true));
end ReferenceState;
7 changes: 3 additions & 4 deletions HelmholtzMedia/Examples/Validation/ThermoSurface.mo
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ algorithm
T := T_sub.y + T_super.y;
p := min({p_melt, p_sub.y + p_super.y});

if (time<=0) then
when initial() then
if not appendToFile then
// remove old file
Modelica.Utilities.Files.remove(fileName);
Expand All @@ -77,7 +77,7 @@ algorithm
+ "dgdT" +Separator
+ "dgTd" +Separator,
fileName);
end if;
end when;

// print the actual values
Modelica.Utilities.Streams.print(String(f.d) + Separator
Expand All @@ -99,6 +99,5 @@ algorithm
+ String(Medium.EoS.dgTd(f))+Separator,
fileName);

annotation (experiment(StopTime=12, __Dymola_NumberOfIntervals=1000),
__Dymola_experimentSetupOutput);
annotation (experiment(StopTime=12));
end ThermoSurface;
15 changes: 7 additions & 8 deletions HelmholtzMedia/Examples/Validation/acentricFactor.mo
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,15 @@ model acentricFactor "validate acentric factor"
package Medium = HelmholtzFluids.Helium;

protected
Medium.Temperature T_crit = Medium.fluidConstants[1].criticalTemperature;
Medium.AbsolutePressure p_crit = Medium.fluidConstants[1].criticalPressure;
Real omega1 = Medium.fluidConstants[1].acentricFactor;
Medium.Temperature T_crit=Medium.fluidConstants[1].criticalTemperature;
Medium.AbsolutePressure p_crit=Medium.fluidConstants[1].criticalPressure;
Real omega1=Medium.fluidConstants[1].acentricFactor;
Real omega2;

algorithm
Modelica.Utilities.Streams.print("acentric Factor from parameter omega1=" + String(omega1), "printlog.txt");
omega2 := -log10(Medium.Ancillary.saturationPressure_T(0.7*T_crit)/p_crit) - 1;
Modelica.Utilities.Streams.print("acentric Factor from Wagner saturation pressure equation omega2=" + String(omega2), "printlog.txt");
annotation (experiment(NumberOfIntervals=1));
when terminal() then
Modelica.Utilities.Streams.print("acentric Factor from parameter omega1=" + String(omega1), "printlog.txt");
Modelica.Utilities.Streams.print("acentric Factor from Wagner saturation pressure equation omega2=" + String(omega2), "printlog.txt");
end when;
end acentricFactor;
4 changes: 2 additions & 2 deletions HelmholtzMedia/Examples/Validation/printCoefficients.mo
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ protected
final constant Real kilo = 1e3;

algorithm
when terminal() then
// if printing fails with error "Room to allocate string"
// go to $Dymola$/source/matrixop.h and increase the size of simplestring, e.g. by a factor of 10

Expand Down Expand Up @@ -56,6 +57,5 @@ algorithm
Modelica.Utilities.Streams.print(String(Medium.ancillaryCoefficients.densityVaporModel), fileName);
Modelica.Utilities.Streams.print(Modelica.Math.Matrices.toString(Medium.ancillaryCoefficients.densityVapor), fileName);
Modelica.Utilities.Streams.print("===============================================================================", fileName);
annotation (experiment(NumberOfIntervals=1));
end when;
end printCoefficients;

0 comments on commit b512e63

Please sign in to comment.