Skip to content

Commit

Permalink
Add test cases for ticket:4359
Browse files Browse the repository at this point in the history
  • Loading branch information
lochel authored and OpenModelica-Hudson committed Apr 3, 2017
1 parent 1936e9d commit e69beac
Show file tree
Hide file tree
Showing 5 changed files with 110 additions and 2 deletions.
5 changes: 4 additions & 1 deletion simulation/modelica/initialization/Makefile
Expand Up @@ -30,6 +30,7 @@ eventTest2.mos \
filterBlock1.mos \
fullRobot.mos \
gaspropreties.mos \
homotopy1.mos \
initial_equation.mos \
parameters.mos \
parameterWithoutBinding.mos \
Expand All @@ -41,6 +42,9 @@ scaling2.mos \
SingularInitial.mos \
singularJacobian.mos \
startValue.mos \
startValue1.mos \
startValue2.mos \
startValue3.mos \
underdeterminedTest1.mos \
underdeterminedTest2.mos \
underdeterminedTest3.mos \
Expand Down Expand Up @@ -73,7 +77,6 @@ OverdeterminedInitialization.Fluid.TwoVolumesFullSteadyStatePressureAndTemperatu
# Run make failingtest
FAILINGTESTFILES = \
discreteTest07.mos \
homotopy1.mos \


# Dependency files that are not .mo .mos or Makefile
Expand Down
2 changes: 1 addition & 1 deletion simulation/modelica/initialization/homotopy1.mos
Expand Up @@ -32,7 +32,7 @@ res := OpenModelica.Scripting.readSimulationResult("initializationTests.homotopy
// simulationOptions = "startTime = 0.0, stopTime = 0.0, numberOfIntervals = 500, tolerance = 1e-06, method = 'dassl', fileNamePrefix = 'initializationTests.homotopy1', options = '', outputFormat = 'mat', variableFilter = '.*', cflags = '', simflags = '-ils=2'",
// messages = ""
// end SimulationResult;
// "Warning: There are iteration variables with default zero start attribute. For more information set +d=initialization. In OMEdit Tools->Options->Simulation->OMCFlags, in OMNotebook call setCommandLineOptions("+d=initialization").
// "Warning: There are iteration variables with default zero start attribute. For more information set -d=initialization. In OMEdit Tools->Options->Simulation->OMCFlags, in OMNotebook call setCommandLineOptions("-d=initialization").
// "
// {{0.0,0.0},{3.0,3.0},{-3.0,-3.0}}
// ""
Expand Down
36 changes: 36 additions & 0 deletions simulation/modelica/initialization/startValue1.mos
@@ -0,0 +1,36 @@
// name: startValue1
// keywords: initialization, start-value, states
// status: correct

loadString("
model startValue1
parameter Real p1(fixed=false);
parameter Real p2 = 2.0;
Real x(start=p1, fixed=true);
Real y(start=p2, fixed=true);
initial equation
p1 = 1.0;
equation
der(x)=0;
der(y)=0;
end startValue1;
"); getErrorString();

simulate(startValue1, stopTime=0.2); getErrorString();
val(x, 0.0); getErrorString();
val(y, 0.0); getErrorString();

// Result:
// true
// ""
// record SimulationResult
// resultFile = "startValue1_res.mat",
// simulationOptions = "startTime = 0.0, stopTime = 0.2, numberOfIntervals = 500, tolerance = 1e-06, method = 'dassl', fileNamePrefix = 'startValue1', options = '', outputFormat = 'mat', variableFilter = '.*', cflags = '', simflags = ''",
// messages = ""
// end SimulationResult;
// ""
// 1.0
// ""
// 2.0
// ""
// endResult
37 changes: 37 additions & 0 deletions simulation/modelica/initialization/startValue2.mos
@@ -0,0 +1,37 @@
// name: startValue2
// keywords: initialization, start-value, algebraic variables
// status: correct

loadString("
model startValue2
parameter Real a(fixed=false);
parameter Real b(fixed=false);
Real w(start=a);
Real y(start=b);
initial equation
a=4;
b=6;
equation
sin(w*y)+cos(w)*y=time;
sin(w*y)+sin(y)+w=(a+b)*time;
end startValue2;
"); getErrorString();

simulate(startValue2, startTime=0.1, stopTime=0.2); getErrorString();
val(w, 0.1); getErrorString();
val(y, 0.1); getErrorString();

// Result:
// true
// ""
// record SimulationResult
// resultFile = "startValue2_res.mat",
// simulationOptions = "startTime = 0.1, stopTime = 0.2, numberOfIntervals = 500, tolerance = 1e-06, method = 'dassl', fileNamePrefix = 'startValue2', options = '', outputFormat = 'mat', variableFilter = '.*', cflags = '', simflags = ''",
// messages = ""
// end SimulationResult;
// ""
// 2.492275940961305
// ""
// -0.9661771347533339
// ""
// endResult
32 changes: 32 additions & 0 deletions simulation/modelica/initialization/startValue3.mos
@@ -0,0 +1,32 @@
// name: startValue3
// keywords: initialization, start-value, parameter
// status: correct

loadString("
model startValue3
parameter Real a(fixed=false);
parameter Real b(fixed=false);
Real c(start=a/b, fixed=true);
initial equation
a=4;
b=6;
equation
der(c) = 0;
end startValue3;
"); getErrorString();

simulate(startValue3, stopTime=0.2); getErrorString();
val(c, 0.0); getErrorString();

// Result:
// true
// ""
// record SimulationResult
// resultFile = "startValue3_res.mat",
// simulationOptions = "startTime = 0.0, stopTime = 0.2, numberOfIntervals = 500, tolerance = 1e-06, method = 'dassl', fileNamePrefix = 'startValue3', options = '', outputFormat = 'mat', variableFilter = '.*', cflags = '', simflags = ''",
// messages = ""
// end SimulationResult;
// ""
// 0.6666666666666666
// ""
// endResult

0 comments on commit e69beac

Please sign in to comment.