Skip to content

Commit

Permalink
- added measureTime-test to cppruntime-hpcom
Browse files Browse the repository at this point in the history
- fmu 1.0 modelExchange tests are now simulated after export
  • Loading branch information
Marcus Walther authored and OpenModelica-Hudson committed Jul 10, 2015
1 parent bee07d6 commit d243ca3
Show file tree
Hide file tree
Showing 7 changed files with 158 additions and 20 deletions.
1 change: 1 addition & 0 deletions openmodelica/cppruntime/Makefile
Expand Up @@ -40,6 +40,7 @@ staticLinking \
genDebugSymbols \
outputFormat \
ReferenceFiles \
outputFormat \
libraries

CLEAN = `ls | grep -w -v -f deps.tmp`
Expand Down
28 changes: 21 additions & 7 deletions openmodelica/cppruntime/fmu/modelExchange/1.0/CoupledClutches.mos
Expand Up @@ -9,14 +9,14 @@ setCommandLineOptions("+simCodeTarget=Cpp"); getErrorString();
loadFile("CoupledClutches.mo"); getErrorString();
translateModelFMU(CoupledClutches); getErrorString();

//importFMU("CoupledClutches.fmu", "<default>", 6); getErrorString();
//loadFile("CoupledClutches_me_FMU.mo"); getErrorString();
//simulate(CoupledClutches_me_FMU, numberOfIntervals=150, variableFilter="J1_w1|J2_w1|J3_w1|J4_w1"); getErrorString();
importFMU("CoupledClutches.fmu"); getErrorString();
loadFile("CoupledClutches_me_FMU.mo"); getErrorString();
simulate(CoupledClutches_me_FMU, numberOfIntervals=150, variableFilter="J1_w1|J2_w1|J3_w1|J4_w1"); getErrorString();

//val(J1_w1, 1);
//val(J2_w1, 1);
//val(J3_w1, 1);
//val(J4_w1, 1);
val(J1_w1, 1);
val(J2_w1, 1);
val(J3_w1, 1);
val(J4_w1, 1);

// Result:
// true
Expand All @@ -28,4 +28,18 @@ translateModelFMU(CoupledClutches); getErrorString();
// "SimCode: The model CoupledClutches has been translated to FMU"
// "Warning: There are iteration variables with default zero start attribute. Use +d=initialization for more information.
// "
// "CoupledClutches_me_FMU.mo"
// ""
// true
// ""
// record SimulationResult
// resultFile = "CoupledClutches_me_FMU_res.mat",
// simulationOptions = "startTime = 0.0, stopTime = 1.5, numberOfIntervals = 150, tolerance = 1e-06, method = 'dassl', fileNamePrefix = 'CoupledClutches_me_FMU', options = '', outputFormat = 'mat', variableFilter = 'J1_w1|J2_w1|J3_w1|J4_w1', cflags = '', simflags = ''",
// messages = ""
// end SimulationResult;
// ""
// 3.235409814452836
// 3.382195820527042
// 3.382195822575476
// -5.144123568889825e-06
// endResult
2 changes: 1 addition & 1 deletion openmodelica/cppruntime/fmu/modelExchange/1.0/Makefile
Expand Up @@ -26,7 +26,7 @@ test:

clean :
@echo $(DEPENDENCIES) | sed 's/ /\\|/g' > deps.tmp
@rm -f $(CLEAN)
@rm -rf $(CLEAN)

getdeps:
@echo $(DEPENDENCIES) | sed 's/ /\\|/g' > deps.tmp
Expand Down
20 changes: 20 additions & 0 deletions openmodelica/cppruntime/fmu/modelExchange/1.0/crane.mos
Expand Up @@ -8,6 +8,14 @@ setCommandLineOptions("+simCodeTarget=Cpp"); getErrorString();
loadFile("cranes.mo"); getErrorString();
translateModelFMU(cranes.crane); getErrorString();

//importFMU("cranes_crane.fmu", "<default>", 6, false, true); getErrorString();
importFMU("cranes_crane.fmu", "<default>"); getErrorString();
loadFile("cranes_crane_me_FMU.mo"); getErrorString();
simulate(cranes_crane_me_FMU, numberOfIntervals=150); getErrorString();

val(position_s, 1);
val(prismatic_v, 1);

// Result:
// true
// ""
Expand All @@ -17,4 +25,16 @@ translateModelFMU(cranes.crane); getErrorString();
// ""
// "SimCode: The model cranes.crane has been translated to FMU"
// ""
// "cranes_crane_me_FMU.mo"
// ""
// true
// ""
// record SimulationResult
// resultFile = "cranes_crane_me_FMU_res.mat",
// simulationOptions = "startTime = 0.0, stopTime = 1.0, numberOfIntervals = 150, tolerance = 1e-06, method = 'dassl', fileNamePrefix = 'cranes_crane_me_FMU', options = '', outputFormat = 'mat', variableFilter = '.*', cflags = '', simflags = ''",
// messages = ""
// end SimulationResult;
// ""
// 0.9493545677180384
// 0.3948240973756043
// endResult
7 changes: 4 additions & 3 deletions openmodelica/cppruntime/hpcom/Makefile
Expand Up @@ -4,7 +4,8 @@ TESTFILES = \
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.Thermal.HeatTransfer.Examples.Motor_mcp_omp.mos \
Modelica.Electrical.Analog.Examples.CauerLowPassSC_level_omp_measureTime.mos

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

Expand All @@ -19,7 +20,8 @@ Modelica.Fluid.Examples.BranchingDynamicPipes_levelfix_pthreads.mos

TESTFILES_LEVEL = \
Modelica.Electrical.Spice3.Examples.CoupledInductors_level_omp.mos \
Modelica.Electrical.Analog.Examples.CauerLowPassSC_level_omp.mos
Modelica.Electrical.Analog.Examples.CauerLowPassSC_level_omp.mos \
Modelica.Electrical.Analog.Examples.CauerLowPassSC_level_omp_measureTime.mos

TESTFILES_METIS = \
Modelica.Electrical.Analog.Examples.CauerLowPassSC_metis_pthreads.mos
Expand Down Expand Up @@ -52,7 +54,6 @@ Modelica.Electrical.Analog.Examples.CauerLowPassSC_level_omp_memory.mos
DEPENDENCIES = \
*.mo \
*.mos \
*.json \
Makefile \
ReferenceFiles \
ReferenceGraphs \
Expand Down
@@ -0,0 +1,88 @@
// name: Modelica.Electrical.Analog.Examples.CauerLowPassSC_HPCOM_Level_OMP_measureTime
// keywords: simulation MSL Examples
// status: correct
//
// Simulation Results
// Modelica Standard Library
//

loadModel(Modelica,{"3.2.1"}); getErrorString();

runScript("ModelTestingDefaults.mos");getErrorString();
modelTestingType := OpenModelicaModelTesting.Kind.VerifiedSimulation;
modelName := $TypeName(Modelica.Electrical.Analog.Examples.CauerLowPassSC);
timeout := 600;

compareVars :=
{
"R4.Capacitor1.v",
"R5.Capacitor1.v",
"R8.Capacitor1.v",
"R9.Capacitor1.v",
"R1.Capacitor1.v",
"R2.Capacitor1.v",
"R3.Capacitor1.v",
"Rp1.Capacitor1.v",
"R7.Capacitor1.v",
"R10.Capacitor1.v",
"R11.Capacitor1.v",
"C3.v",
"C7.v",
"C1.v",
"C4.v",
"C8.v"
};

setCommandLineOptions("+profiling=all +simCodeTarget=Cpp"); getErrorString();
simulate(modelName, stopTime=10.0);
echo(false);
profilingContent := readFile("Modelica.Electrical.Analog.Examples.CauerLowPassSC_prof.json"); getErrorString();
writeFile("Modelica.Electrical.Analog.Examples.CauerLowPassSC_eqs_prof.json", profilingContent); getErrorString();
echo(true);

setDebugFlags("hpcom"); getErrorString();
setCommandLineOptions("+n=2 +hpcomScheduler=level +hpcomCode=openmp"); getErrorString();

runScript(modelTesting);getErrorString();

// Result:
// true
// ""
// "\"true
// \"
// OpenModelicaModelTesting.SimulationRuntime.Cpp
// \"mat\"
// true
// "
// ""
// OpenModelicaModelTesting.Kind.VerifiedSimulation
// Modelica.Electrical.Analog.Examples.CauerLowPassSC
// 600
// {"R4.Capacitor1.v","R5.Capacitor1.v","R8.Capacitor1.v","R9.Capacitor1.v","R1.Capacitor1.v","R2.Capacitor1.v","R3.Capacitor1.v","Rp1.Capacitor1.v","R7.Capacitor1.v","R10.Capacitor1.v","R11.Capacitor1.v","C3.v","C7.v","C1.v","C4.v","C8.v"}
// true
// ""
// record SimulationResult
// resultFile = "Modelica.Electrical.Analog.Examples.CauerLowPassSC_res.mat",
// simulationOptions = "startTime = 0.0, stopTime = 10.0, numberOfIntervals = 1500, tolerance = 1e-06, method = 'dassl', fileNamePrefix = 'Modelica.Electrical.Analog.Examples.CauerLowPassSC', options = '', outputFormat = 'mat', variableFilter = '.*', cflags = '', simflags = ''",
// messages = "Profiling results written to Modelica.Electrical.Analog.Examples.CauerLowPassSC_prof.json
// "
// end SimulationResult;
// true
// true
// ""
// true
// ""
// Using json-file
// Using level Scheduler for the DAE system
// Using level Scheduler for the ODE system
// Using level Scheduler for the ZeroFunc system
// HpcOm is still under construction.
// Simulation options: startTime = 0.0, stopTime = 60.0, numberOfIntervals = 1500, tolerance = 1e-06, method = 'dassl', fileNamePrefix = 'Modelica.Electrical.Analog.Examples.CauerLowPassSC', options = '', outputFormat = 'mat', variableFilter = '.*', cflags = '', simflags = ''
// Result file: Modelica.Electrical.Analog.Examples.CauerLowPassSC_res.mat
// Messages: Profiling results written to Modelica.Electrical.Analog.Examples.CauerLowPassSC_prof.json
//
// Files Equal!
// "true
// "
// ""
// endResult
Expand Up @@ -6,19 +6,19 @@

loadModel(Modelica); getErrorString();
setDebugFlags("hpcom"); getErrorString();
setCommandLineOptions("+simCodeTarget=Cpp +n=2 +hpcomCode=openmp +hpcomScheduler=level"); getErrorString();
setCommandLineOptions("+simCodeTarget=Cpp +n=2 +hpcomCode=openmp +hpcomScheduler=list"); getErrorString();
loadFile("CoupledClutches.mo"); getErrorString();
translateModelFMU(CoupledClutches); getErrorString();

//importFMU("CoupledClutches.fmu", "<default>", 6); getErrorString();
//importFMU("CoupledClutches.fmu"); getErrorString();
//loadFile("CoupledClutches_me_FMU.mo"); getErrorString();
//simulate(CoupledClutches_me_FMU, numberOfIntervals=150, variableFilter="J1_w1|J2_w1|J3_w1|J4_w1"); getErrorString();
//importFMU("CoupledClutches.fmu", "<default>", 6, true, true); getErrorString();
importFMU("CoupledClutches.fmu"); getErrorString();
loadFile("CoupledClutches_me_FMU.mo"); getErrorString();
simulate(CoupledClutches_me_FMU, numberOfIntervals=150, variableFilter="J1_w1|J2_w1|J3_w1|J4_w1"); getErrorString();

//val(J1_w1, 1);
//val(J2_w1, 1);
//val(J3_w1, 1);
//val(J4_w1, 1);
val(J1_w1, 1);
val(J2_w1, 1);
val(J3_w1, 1);
val(J4_w1, 1);

// Result:
// true
Expand All @@ -38,4 +38,18 @@ translateModelFMU(CoupledClutches); getErrorString();
// "SimCode: The model CoupledClutches has been translated to FMU"
// "Warning: There are iteration variables with default zero start attribute. Use +d=initialization for more information.
// "
// "CoupledClutches_me_FMU.mo"
// ""
// true
// ""
// record SimulationResult
// resultFile = "CoupledClutches_me_FMU_res.mat",
// simulationOptions = "startTime = 0.0, stopTime = 1.5, numberOfIntervals = 150, tolerance = 1e-06, method = 'dassl', fileNamePrefix = 'CoupledClutches_me_FMU', options = '', outputFormat = 'mat', variableFilter = 'J1_w1|J2_w1|J3_w1|J4_w1', cflags = '', simflags = ''",
// messages = ""
// end SimulationResult;
// ""
// 3.235409814452836
// 3.382195820527042
// 3.382195822575476
// -5.144123568889825e-06
// endResult

0 comments on commit d243ca3

Please sign in to comment.