Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
niklwors committed Aug 11, 2015
2 parents c93a404 + fad22bf commit d093e95
Show file tree
Hide file tree
Showing 27 changed files with 474 additions and 184 deletions.
3 changes: 2 additions & 1 deletion openmodelica/cppruntime/Makefile
@@ -1,9 +1,10 @@
TEST = ../../rtest -v

TESTFILES = \
tearnonlin1.mos \
WhenStatement1.mos \
BouncingBall.mos \
tearnonlin1.mos
solveTest.mos

FAILINGTESTFILES=

Expand Down
6 changes: 3 additions & 3 deletions openmodelica/cppruntime/hpcom/Makefile
@@ -1,11 +1,11 @@
TEST = ../../../rtest -v

TESTFILES = \
Modelica.Electrical.Analog.Examples.CauerLowPassSC_levelfix_pthreads_memory.mos \
Modelica.Electrical.Analog.Examples.CauerLowPassSC_level_omp_measureTime.mos \
Modelica.Electrical.Spice3.Examples.CoupledInductors_level_omp.mos \
Modelica.Electrical.Spice3.Examples.CoupledInductors_list_pthreads_spin.mos \
Modelica.Electrical.Analog.Examples.CauerLowPassSC_levelfix_pthreads_memory.mos \
Modelica.Thermal.HeatTransfer.Examples.Motor_mcp_omp.mos \
Modelica.Electrical.Analog.Examples.CauerLowPassSC_level_omp_measureTime.mos
Modelica.Thermal.HeatTransfer.Examples.Motor_mcp_omp.mos

TESTFILES_ALL = $(TESTFILES_SERIAL) $(TESTFILES_LEVELFIX) $(TESTFILES_LEVEL) $(TESTFILES_METIS) $(TESTFILES_LIST) $(TESTFILES_LISTR) $(TESTFILES_TBB) $(TESTFILES_MCP)

Expand Down
38 changes: 38 additions & 0 deletions openmodelica/cppruntime/solveTest.mos
@@ -0,0 +1,38 @@
// name: solveTest
// keywords: external F77 LAPACK
// status: correct
// teardown_command: rm -f *SolveTest*

setCommandLineOptions("+simCodeTarget=Cpp");

loadModel(Modelica);
loadString("
model SolveTest
Real[:, :] A = [0, 1; 2, 3];
Real[:] b = {4, 5};
input Real u = 0; // prevent presolving during translation
output Real[2] x;
equation
x = Modelica.Math.Matrices.solve(A, (u + 1) * b);
end SolveTest;
");
getErrorString();

simulate(SolveTest);
val(x[1], 1);
val(x[2], 1);
getErrorString();

// Result:
// true
// true
// true
// ""
// record SimulationResult
// resultFile = "SolveTest_res.mat",
// simulationOptions = "startTime = 0.0, stopTime = 1.0, numberOfIntervals = 500, tolerance = 1e-06, method = 'dassl', fileNamePrefix = 'SolveTest', options = '', outputFormat = 'mat', variableFilter = '.*', cflags = '', simflags = ''",
// messages = ""
// end SimulationResult;
// -3.5
// 4.0
// ""
25 changes: 23 additions & 2 deletions openmodelica/fmi/ModelExchange/1.0/BooleanNetwork1.mos
Expand Up @@ -6,13 +6,22 @@

loadModel(Modelica); getErrorString();
loadFile("BooleanNetwork1.mo"); getErrorString();

simulate(BooleanNetwork1, stopTime=10, numberOfIntervals=150, variableFilter="y|y1|y2|y3|y4|Q|QI"); getErrorString();
val(y1, 2.2);
val(y2, 10);
val(y3, 10);
val(y4, 10);
val(Q, 10);
val(QI, 10);

translateModelFMU(BooleanNetwork1); getErrorString();

importFMU("BooleanNetwork1.fmu"); getErrorString();
loadFile("BooleanNetwork1_me_FMU.mo"); getErrorString();
simulate(BooleanNetwork1_me_FMU, stopTime=10, numberOfIntervals=150, variableFilter="y|y1|y2|y3|y4|Q|QI"); getErrorString();

val(y1, 2);
val(y1, 2.2);
val(y2, 10);
val(y3, 10);
val(y4, 10);
Expand All @@ -24,6 +33,18 @@ val(QI, 10);
// ""
// true
// ""
// record SimulationResult
// resultFile = "BooleanNetwork1_res.mat",
// simulationOptions = "startTime = 0.0, stopTime = 10.0, numberOfIntervals = 150, tolerance = 1e-06, method = 'dassl', fileNamePrefix = 'BooleanNetwork1', options = '', outputFormat = 'mat', variableFilter = 'y|y1|y2|y3|y4|Q|QI', cflags = '', simflags = ''",
// messages = ""
// end SimulationResult;
// ""
// 8.0
// 1.0
// 0.0
// 0.0
// 1.0
// 0.0
// "SimCode: The model BooleanNetwork1 has been translated to FMU"
// ""
// "BooleanNetwork1_me_FMU.mo"
Expand All @@ -36,7 +57,7 @@ val(QI, 10);
// messages = ""
// end SimulationResult;
// ""
// 6.0
// 8.0
// 1.0
// 0.0
// 0.0
Expand Down
16 changes: 9 additions & 7 deletions openmodelica/fmi/ModelExchange/1.0/Makefile
Expand Up @@ -13,12 +13,14 @@ Modelica_Mechanics_MultiBody_Examples_Elementary_DoublePendulum.mos \
Pendulum.mos \
SampleExample.mos \
testAssert.mos \
testChangeParam.mos \
TanksConnectedPI.mos \
CoupledClutches.mos \
BooleanNetwork1.mos \
IntegerNetwork1.mos \
StringParameters.mos

# test that currently fail. Move up when fixed.
# test that currently fail. Move up when fixed.
# Run make testfailing
FAILINGTESTFILES= \

Expand All @@ -41,8 +43,8 @@ test:
@echo
@echo OPENMODELICAHOME=" $(OPENMODELICAHOME) "
@$(TEST) $(TESTFILES)
# Cleans all files that are not listed as dependencies

# Cleans all files that are not listed as dependencies
clean :
@echo $(DEPENDENCIES) | sed 's/ /\\|/g' > deps.tmp
@rm -f $(CLEAN)
Expand All @@ -51,11 +53,11 @@ clean :
# do it after cleaning and updating the folder
# then you can get a list of file names (which must be dependencies
# since you got them from repository + your own new files)
# then add them to the DEPENDENCIES. You can find the
# list in deps.txt
getdeps:
# then add them to the DEPENDENCIES. You can find the
# list in deps.txt
getdeps:
@echo $(DEPENDENCIES) | sed 's/ /\\|/g' > deps.tmp
@echo $(CLEAN) | sed -r 's/deps.txt|deps.tmp//g' | sed 's/ / \\\n/g' > deps.txt
@echo $(CLEAN) | sed -r 's/deps.txt|deps.tmp//g' | sed 's/ / \\\n/g' > deps.txt
@echo Dependency list saved in deps.txt.
@echo Copy the list from deps.txt and add it to the Makefile @DEPENDENCIES

Expand Down
17 changes: 7 additions & 10 deletions openmodelica/fmi/ModelExchange/1.0/StringParameters.mos
Expand Up @@ -9,10 +9,7 @@ loadFile("StringParameters.mo"); getErrorString();
translateModelFMU(StringParameters); getErrorString();
importFMU("StringParameters.fmu"); getErrorString();
loadFile("StringParameters_me_FMU.mo"); getErrorString();
simulate(StringParameters_me_FMU, stopTime=3.0); getErrorString();
val(ball,0);
val(ball,1);
val(ball,3);
simulate(StringParameters_me_FMU, stopTime=3.0, simflags="-output=sball,eball"); getErrorString();

// Result:
// true
Expand All @@ -28,11 +25,11 @@ val(ball,3);
// ""
// record SimulationResult
// resultFile = "StringParameters_me_FMU_res.mat",
// simulationOptions = "startTime = 0.0, stopTime = 3.0, numberOfIntervals = 500, tolerance = 1e-06, method = 'dassl', fileNamePrefix = 'StringParameters_me_FMU', options = '', outputFormat = 'mat', variableFilter = '.*', cflags = '', simflags = ''",
// messages = ""
// simulationOptions = "startTime = 0.0, stopTime = 3.0, numberOfIntervals = 500, tolerance = 1e-06, method = 'dassl', fileNamePrefix = 'StringParameters_me_FMU', options = '', outputFormat = 'mat', variableFilter = '.*', cflags = '', simflags = '-output=sball,eball'",
// messages = "time=3,sball=\"RedBall\",eball=\"BlueBall\"
// "
// end SimulationResult;
// ""
// 1.0
// 0.2250205572103477
// -0.9555203906613871
// "[openmodelica/fmi/ModelExchange/1.0/StringParameters_me_FMU.mo:14:3-14:55:writable] Warning: Parameter eball has no value, and is fixed during initialization (fixed=true), using available start value (start="BlueBall") as default value.
// [openmodelica/fmi/ModelExchange/1.0/StringParameters_me_FMU.mo:15:3-15:54:writable] Warning: Parameter sball has no value, and is fixed during initialization (fixed=true), using available start value (start="RedBall") as default value.
// "
// endResult
76 changes: 76 additions & 0 deletions openmodelica/fmi/ModelExchange/1.0/testChangeParam.mos
@@ -0,0 +1,76 @@
// name: testChangeParam
// keywords: FMI 2.0 export
// status: correct
// teardown_command: rm -rf binaries sources modelDescription.xml modelDescription.tmp.xml test_ChangeParam* output.log
//


loadString("
model test_ChangeParam
parameter Real a = 2.0;
parameter Integer i = 1;
parameter Boolean b = true;
parameter String s = \"foo\";
Real x(start=1);
input Real u;
output Real y;
equation
der(x) = x*a+u;
y = if b then der(x)-x-i else der(x)+x+i;
when time>1 then
terminate(\"Simulation done by \" + s);
end when;
annotation(experiment(StopTime=2));
end test_ChangeParam;
");
getErrorString();
loadModel(Modelica);


translateModelFMU(test_ChangeParam, version="2.0");
getErrorString();
importFMU("test_ChangeParam.fmu");

loadFile("test_ChangeParam_me_FMU.mo");
getErrorString();

simulate(test_ChangeParam_me_FMU, numberOfIntervals=1);
val(x, 1);
val(a, 1);
val(y, 1);
getErrorString();

system("./test_ChangeParam_me_FMU -override a=-2,i=-10,b=false,s=\"bar\" -r test_ChangeParam.mat");
readSimulationResult("test_ChangeParam.mat", {x,a,y}, 6);
getErrorString();


// Result:
// true
// ""
// true
// "SimCode: The model test_ChangeParam has been translated to FMU"
// "Warning: The initial conditions are not fully specified. Use +d=initialization for more information.
// "
// "test_ChangeParam_me_FMU.mo"
// true
// ""
// record SimulationResult
// resultFile = "test_ChangeParam_me_FMU_res.mat",
// simulationOptions = "startTime = 0.0, stopTime = 2.0, numberOfIntervals = 1, tolerance = 1e-06, method = 'dassl', fileNamePrefix = 'test_ChangeParam_me_FMU', options = '', outputFormat = 'mat', variableFilter = '.*', cflags = '', simflags = ''",
// messages = "[<interactive>:14:7-14:43:writable]
// stdout | info | Simulation call terminate() at time 1.000000
// | | | | Message : Simulation done by foo
// "
// end SimulationResult;
// 7.389089930122227
// 2.0
// 6.389089930122227
// ""
// [<interactive>:14:7-14:43:writable]
// stdout | info | Simulation call terminate() at time 1.000000
// | | | | Message : Simulation done by bar
// 0
// {{1.0,1.0,1.0,0.1353363211567342,0.1353363211567342,0.1353363211567342},{-2.0,-2.0,-2.0,-2.0,-2.0,-2.0},{-11.0,-11.0,-11.0,-10.13533632115674,-10.13533632115674,-10.13533632115674}}
// ""
// endResult
26 changes: 24 additions & 2 deletions openmodelica/fmi/ModelExchange/2.0/BooleanNetwork1.mos
Expand Up @@ -6,13 +6,23 @@

loadModel(Modelica); getErrorString();
loadFile("BooleanNetwork1.mo"); getErrorString();

simulate(BooleanNetwork1, stopTime=10, numberOfIntervals=150, variableFilter="y|y1|y2|y3|y4|Q|QI"); getErrorString();

val(y1, 2.2);
val(y2, 10);
val(y3, 10);
val(y4, 10);
val(Q, 10);
val(QI, 10);

translateModelFMU(BooleanNetwork1, version="2.0"); getErrorString();

importFMU("BooleanNetwork1.fmu"); getErrorString();
loadFile("BooleanNetwork1_me_FMU.mo"); getErrorString();
simulate(BooleanNetwork1_me_FMU, stopTime=10, numberOfIntervals=150, variableFilter="y|y1|y2|y3|y4|Q|QI"); getErrorString();

val(y1, 2);
val(y1, 2.2);
val(y2, 10);
val(y3, 10);
val(y4, 10);
Expand All @@ -24,6 +34,18 @@ val(QI, 10);
// ""
// true
// ""
// record SimulationResult
// resultFile = "BooleanNetwork1_res.mat",
// simulationOptions = "startTime = 0.0, stopTime = 10.0, numberOfIntervals = 150, tolerance = 1e-06, method = 'dassl', fileNamePrefix = 'BooleanNetwork1', options = '', outputFormat = 'mat', variableFilter = 'y|y1|y2|y3|y4|Q|QI', cflags = '', simflags = ''",
// messages = ""
// end SimulationResult;
// ""
// 8.0
// 1.0
// 0.0
// 0.0
// 1.0
// 0.0
// "SimCode: The model BooleanNetwork1 has been translated to FMU"
// ""
// "BooleanNetwork1_me_FMU.mo"
Expand All @@ -36,7 +58,7 @@ val(QI, 10);
// messages = ""
// end SimulationResult;
// ""
// 6.0
// 8.0
// 1.0
// 0.0
// 0.0
Expand Down
5 changes: 3 additions & 2 deletions openmodelica/fmi/ModelExchange/2.0/Makefile
Expand Up @@ -7,6 +7,7 @@ HelloFMIWorld.mos \
HelloFMIWorldEvent.mos \
IntegerNetwork1.mos \
testAssert.mos \
testChangeParam.mos \
testBug2764.mos \
testBug3034.mos \
testBug3049.mos \
Expand All @@ -15,12 +16,12 @@ ZeroStates.mos \
EnumerationTest.mos \
Modelica.Blocks.Sources.BooleanPulse.mos \
Modelica.Electrical.Analog.Examples.ChuaCircuit.mos \
Modelica_Mechanics_MultiBody_Examples_Elementary_Pendulum.mos \
Modelica_Mechanics_MultiBody_Examples_Elementary_DoublePendulum.mos \

# test that currently fail. Move up when fixed.
# Run make testfailing
FAILINGTESTFILES= \
Modelica_Mechanics_MultiBody_Examples_Elementary_Pendulum.mos \
Modelica_Mechanics_MultiBody_Examples_Elementary_DoublePendulum.mos \

# Dependency files that are not .mo .mos or Makefile
# Add them here or they will be cleaned.
Expand Down

0 comments on commit d093e95

Please sign in to comment.