Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Willi Braun
committed
Apr 27, 2016
1 parent
ee21b31
commit e517882
Showing
8 changed files
with
576 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
// | ||
// Package that defines a set of testcases | ||
// to test for DAE integration method. | ||
// | ||
// | ||
|
||
package testDAE | ||
|
||
// problem1: simple dae | ||
model p1 | ||
Real x,y(start=1); | ||
equation | ||
der(x) = sin(time); | ||
der(y) = x^2-y; | ||
end p1; | ||
|
||
// problem2: simple dae with algebraic equations | ||
model p2 | ||
Real v = cos(time)*x; | ||
Real w = der(x)+x*y; | ||
Real x,y(start=1); | ||
equation | ||
der(x) = sin(time)+v; | ||
der(y) = x^2-y*w; | ||
end p2; | ||
|
||
// problem3: simple dae with algebraic loops, dynamicState selection | ||
model p3 | ||
Real x(start = 0.9,fixed=true); | ||
Real y(fixed=false); | ||
equation | ||
(1 + 0.5*sin(y))*der(x) + der(y) = 2*sin(time); | ||
x-y = exp(-0.9*x)*cos(y); | ||
end p3; | ||
|
||
// problem4: simple dae with algebraic loop with states and algebraic equations | ||
model p4 | ||
Real x(start = 0.9,fixed=true); | ||
Real y(fixed=false); | ||
Real v = cos(time)*der(y); | ||
Real w = der(x)+x*y; | ||
equation | ||
(1 + 0.5*sin(y))*der(x) + y = 2*sin(v+w); | ||
x-der(y) = exp(-0.9*x)*cos(y)+v*w; | ||
end p4; | ||
|
||
// problem5: simple dae with when equation | ||
model p5 | ||
Real v = cos(time)*x; | ||
Real w = der(x)+x*y; | ||
Real z(start=-3); | ||
Real x,y(start=1); | ||
equation | ||
when x > 1.2 then | ||
z = cos(y); | ||
end when; | ||
der(x) = sin(time)+v*z; | ||
der(y) = x^2-y*w; | ||
end p5; | ||
|
||
|
||
|
||
end testDAE; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
// name: testDAEDrumBoiler | ||
// status: correct | ||
// teardown_command: rm -f testDAEDrumBoiler output.log | ||
|
||
|
||
loadModel(Modelica,{"3.2.1"}); | ||
getErrorString(); | ||
|
||
setCommandLineOptions("+daeMode"); | ||
simulate(Modelica.Fluid.Examples.DrumBoiler.DrumBoiler, method="ida", simflags="-daeMode"); | ||
getErrorString(); | ||
|
||
res := OpenModelica.Scripting.compareSimulationResults("Modelica.Fluid.Examples.DrumBoiler.DrumBoiler_res.mat", | ||
getEnvironmentVar("REFERENCEFILES")+"/msl32/Modelica.Fluid.Examples.DrumBoiler.DrumBoiler.mat", | ||
"NPendulum_diff.csv",0.01,0.0001, | ||
{ "evaporator.p", "evaporator.V_l", "controller.x", "temperature.T"}); | ||
|
||
|
||
// Result: | ||
// true | ||
// "" | ||
// true | ||
// record SimulationResult | ||
// resultFile = "Modelica.Fluid.Examples.DrumBoiler.DrumBoiler_res.mat", | ||
// simulationOptions = "startTime = 0.0, stopTime = 5400.0, numberOfIntervals = 500, tolerance = 1e-06, method = 'ida', fileNamePrefix = 'Modelica.Fluid.Examples.DrumBoiler.DrumBoiler', options = '', outputFormat = 'mat', variableFilter = '.*', cflags = '', simflags = '-daeMode'", | ||
// messages = "assert | warning | The following assertion has been violated at time 950.400000 | ||
// | | | | SteamValve.opening >= 0.0 and SteamValve.opening <= 1.0 | ||
// assert | warning | Variable SteamValve.opening out of [min, max] interval: SteamValve.opening >= 0.0 and SteamValve.opening <= 1.0 has value: 1 | ||
// " | ||
// end SimulationResult; | ||
// "Warning: Alias set with several free start values | ||
// * candidate: evaporator.p(start = evaporator.p_start) | ||
// * candidate: evaporator.port_b.p(start = 5000000.0) | ||
// * candidate: temperature.port.p(start = 5000000.0) | ||
// * candidate: pressure.port.p(start = 5000000.0) | ||
// * candidate: massFlowRate.port_a.p(start = 5000000.0) | ||
// * candidate: massFlowRate.port_b.p(start = 5000000.0) | ||
// * candidate: SteamValve.port_a.p(start = 5000000.0) | ||
// * candidate: SteamValve.state_a.p(start = 5000000.0) | ||
// * candidate: evaporator.port_a.p(start = 5000000.0) | ||
// * candidate: pump.ports[1].p(start = 5000000.0) | ||
// * candidate: pump.medium.state.p(start = 5000000.0) | ||
// * candidate: pump.medium.sat.psat(start = 5000000.0) | ||
// * candidate: evaporator.sat.psat(start = 5000000.0) | ||
// => select value from evaporator.p(start = evaporator.p_start) for variable: evaporator.p | ||
// Warning: Alias set with different nominal values | ||
// * candidate: evaporator.sat.psat(nominal = 1000000.0) | ||
// * candidate: pump.medium.sat.psat(nominal = 1000000.0) | ||
// * candidate: pump.medium.state.p(nominal = 1000000.0) | ||
// * candidate: pump.medium.p(nominal = 100000.0) | ||
// * candidate: pump.ports[1].p(nominal = 1000000.0) | ||
// * candidate: evaporator.port_a.p(nominal = 1000000.0) | ||
// * candidate: SteamValve.state_a.p(nominal = 1000000.0) | ||
// * candidate: SteamValve.port_a.p(nominal = 1000000.0) | ||
// * candidate: massFlowRate.port_b.p(nominal = 1000000.0) | ||
// * candidate: massFlowRate.port_a.p(nominal = 1000000.0) | ||
// * candidate: pressure.port.p(nominal = 1000000.0) | ||
// * candidate: temperature.port.p(nominal = 1000000.0) | ||
// * candidate: evaporator.port_b.p(nominal = 1000000.0) | ||
// * candidate: evaporator.p(nominal = 1000000.0) | ||
// => select value from evaporator.p(nominal = 1000000.0) for variable: evaporator.p | ||
// Warning: Alias set with different nominal values | ||
// * candidate: furnace.port.T(nominal = 300.0) | ||
// * candidate: evaporator.heatPort.T(nominal = 300.0) | ||
// * candidate: evaporator.sat.Tsat(nominal = 500.0) | ||
// * candidate: evaporator.T(nominal = 500.0) | ||
// * candidate: evaporator.T_D(nominal = 500.0) | ||
// => select value from evaporator.T_D(nominal = 500.0) for variable: evaporator.T_D | ||
// " | ||
// {"Files Equal!"} | ||
// endResult |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
// name: testDAE.p1 | ||
// status: correct | ||
// teardown_command: rm -f testDAE.p1* output.log | ||
|
||
|
||
loadFile("./testDAEPackage.mo"); | ||
getErrorString(); | ||
|
||
simulate(testDAE.p1); | ||
getErrorString(); | ||
|
||
val(x,0.0); | ||
val(y,0.0); | ||
|
||
val(x,1.0); | ||
val(y,1.0); | ||
|
||
setCommandLineOptions("+daeMode"); | ||
simulate(testDAE.p1, simflags="-daeMode"); | ||
getErrorString(); | ||
|
||
val(x,0.0); | ||
val(y,0.0); | ||
|
||
val(x,1.0); | ||
val(y,1.0); | ||
|
||
simulate(testDAE.p1, simflags="-daeMode", method="ida"); | ||
getErrorString(); | ||
|
||
val(x,0.0); | ||
val(y,0.0); | ||
|
||
val(x,1.0); | ||
val(y,1.0); | ||
|
||
|
||
|
||
// Result: | ||
// true | ||
// "" | ||
// record SimulationResult | ||
// resultFile = "testDAE.p1_res.mat", | ||
// simulationOptions = "startTime = 0.0, stopTime = 1.0, numberOfIntervals = 500, tolerance = 1e-06, method = 'dassl', fileNamePrefix = 'testDAE.p1', options = '', outputFormat = 'mat', variableFilter = '.*', cflags = '', simflags = ''", | ||
// messages = "" | ||
// end SimulationResult; | ||
// "Warning: The initial conditions are not fully specified. Use +d=initialization for more information. | ||
// " | ||
// 0.0 | ||
// 1.0 | ||
// 0.4596999465126458 | ||
// 0.4056181325701173 | ||
// true | ||
// record SimulationResult | ||
// resultFile = "testDAE.p1_res.mat", | ||
// simulationOptions = "startTime = 0.0, stopTime = 1.0, numberOfIntervals = 500, tolerance = 1e-06, method = 'dassl', fileNamePrefix = 'testDAE.p1', options = '', outputFormat = 'mat', variableFilter = '.*', cflags = '', simflags = '-daeMode'", | ||
// messages = "" | ||
// end SimulationResult; | ||
// "Warning: The initial conditions are not fully specified. Use +d=initialization for more information. | ||
// " | ||
// 0.0 | ||
// 1.0 | ||
// 0.4596999465126551 | ||
// 0.4056181325701388 | ||
// record SimulationResult | ||
// resultFile = "testDAE.p1_res.mat", | ||
// simulationOptions = "startTime = 0.0, stopTime = 1.0, numberOfIntervals = 500, tolerance = 1e-06, method = 'ida', fileNamePrefix = 'testDAE.p1', options = '', outputFormat = 'mat', variableFilter = '.*', cflags = '', simflags = '-daeMode'", | ||
// messages = "" | ||
// end SimulationResult; | ||
// "Warning: The initial conditions are not fully specified. Use +d=initialization for more information. | ||
// " | ||
// 0.0 | ||
// 1.0 | ||
// 0.459699946509931 | ||
// 0.4056181325368085 | ||
// endResult |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,100 @@ | ||
// name: testDAE.p2 | ||
// status: correct | ||
// teardown_command: rm -f testDAE.p2* output.log | ||
|
||
|
||
loadFile("./testDAEPackage.mo"); | ||
getErrorString(); | ||
|
||
simulate(testDAE.p2, tolerance = 1e-10); | ||
getErrorString(); | ||
|
||
val(v,0.0); | ||
val(w,0.0); | ||
val(x,0.0); | ||
val(y,0.0); | ||
|
||
val(v,1.0); | ||
val(w,1.0); | ||
val(x,1.0); | ||
val(y,1.0); | ||
|
||
setCommandLineOptions("+daeMode"); | ||
simulate(testDAE.p2, simflags="-daeMode", tolerance = 1e-10); | ||
getErrorString(); | ||
|
||
val(v,0.0); | ||
val(w,0.0); | ||
val(x,0.0); | ||
val(y,0.0); | ||
|
||
val(v,1.0); | ||
val(w,1.0); | ||
val(x,1.0); | ||
val(y,1.0); | ||
|
||
simulate(testDAE.p2, simflags="-daeMode", tolerance = 1e-10, method="ida"); | ||
getErrorString(); | ||
|
||
val(v,0.0); | ||
val(w,0.0); | ||
val(x,0.0); | ||
val(y,0.0); | ||
|
||
val(v,1.0); | ||
val(w,1.0); | ||
val(x,1.0); | ||
val(y,1.0); | ||
|
||
|
||
|
||
// Result: | ||
// true | ||
// "" | ||
// record SimulationResult | ||
// resultFile = "testDAE.p2_res.mat", | ||
// simulationOptions = "startTime = 0.0, stopTime = 1.0, numberOfIntervals = 500, tolerance = 1e-10, method = 'dassl', fileNamePrefix = 'testDAE.p2', options = '', outputFormat = 'mat', variableFilter = '.*', cflags = '', simflags = ''", | ||
// messages = "" | ||
// end SimulationResult; | ||
// "Warning: The initial conditions are not fully specified. Use +d=initialization for more information. | ||
// " | ||
// 0.0 | ||
// 0.0 | ||
// 0.0 | ||
// 1.0 | ||
// 0.3246821983309646 | ||
// 1.48928993244441 | ||
// 0.6009269159221448 | ||
// 0.5377305305249699 | ||
// true | ||
// record SimulationResult | ||
// resultFile = "testDAE.p2_res.mat", | ||
// simulationOptions = "startTime = 0.0, stopTime = 1.0, numberOfIntervals = 500, tolerance = 1e-10, method = 'dassl', fileNamePrefix = 'testDAE.p2', options = '', outputFormat = 'mat', variableFilter = '.*', cflags = '', simflags = '-daeMode'", | ||
// messages = "" | ||
// end SimulationResult; | ||
// "Warning: The initial conditions are not fully specified. Use +d=initialization for more information. | ||
// " | ||
// 0.0 | ||
// 0.0 | ||
// 0.0 | ||
// 1.0 | ||
// 0.3246821977551893 | ||
// 1.489289931964678 | ||
// 0.6009269148564909 | ||
// 0.53773053163838 | ||
// record SimulationResult | ||
// resultFile = "testDAE.p2_res.mat", | ||
// simulationOptions = "startTime = 0.0, stopTime = 1.0, numberOfIntervals = 500, tolerance = 1e-10, method = 'ida', fileNamePrefix = 'testDAE.p2', options = '', outputFormat = 'mat', variableFilter = '.*', cflags = '', simflags = '-daeMode'", | ||
// messages = "" | ||
// end SimulationResult; | ||
// "Warning: The initial conditions are not fully specified. Use +d=initialization for more information. | ||
// " | ||
// 0.0 | ||
// 0.0 | ||
// 0.0 | ||
// 1.0 | ||
// 0.3246821977577873 | ||
// 1.489289931968621 | ||
// 0.6009269148612993 | ||
// 0.5377305316363151 | ||
// endResult |
Oops, something went wrong.