Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 12 additions & 8 deletions src/OMSimulatorLib/OMSimulator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1206,28 +1206,32 @@ oms_status_enu_t SimulateSingleFMU(const filesystem::path& path)
if(oms_status_ok != oms_setResultFile(modelName.c_str(), oms::Flags::ResultFile().value.c_str(), 1))
return logError("oms_setResultFile failed");

if (oms::Flags::StartTime().given)
if (oms::Flags::StartTime().given)
status = oms_setStartTime(modelName.c_str(), oms::Flags::StartTime());
else
status = oms_setStartTime(modelName.c_str(), defaultExperiment.startTime);
if(oms_status_ok != status) return logError("oms_setStartTime failed");

if (oms::Flags::StopTime().given)
status = oms_setStopTime(modelName.c_str(), oms::Flags::StopTime());
else
status = oms_setStopTime(modelName.c_str(), defaultExperiment.stopTime);
if(oms_status_ok != status) return logError("oms_setStopTime failed");

if (oms::Flags::Tolerance().given)
status = oms_setTolerance(modelName.c_str(), oms::Flags::Tolerance(), oms::Flags::Tolerance());
else
status = oms_setTolerance(modelName.c_str(), defaultExperiment.tolerance, defaultExperiment.tolerance);
if(oms_status_ok != status) return logError("oms_setTolerance failed");

// set the maximum stepSize
double initialStepSize = oms::Flags::InitialStepSize().given ? oms::Flags::InitialStepSize().value : defaultExperiment.stepSize;
double minimumStepSize = oms::Flags::MinimumStepSize().given ? oms::Flags::MinimumStepSize().value : defaultExperiment.stepSize;
status = oms_setVariableStepSize(modelName.c_str(), initialStepSize, minimumStepSize, defaultExperiment.stepSize);

// set the initial, minimum and maximum stepSize
double initialStepSize = oms::Flags::InitialStepSize().value;
double minimumStepSize = oms::Flags::MinimumStepSize().value;

if (oms::Flags::MaximumStepSize().given)
status = oms_setVariableStepSize(modelName.c_str(), initialStepSize, minimumStepSize, oms::Flags::MaximumStepSize().value);
else
status = oms_setVariableStepSize(modelName.c_str(), initialStepSize, minimumStepSize, defaultExperiment.stepSize);
if(oms_status_ok != status) return logError("oms_setVariableStepSize failed");

if (oms::Flags::Intervals().given)
Expand Down
4 changes: 4 additions & 0 deletions testsuite/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,10 @@ reference-fmus.log: difftool
@$(MAKE) -C reference-fmus -f Makefile test > $@
@grep == reference-fmus.log

regression.log: difftool
@$(MAKE) -C regression -f Makefile test > $@
@grep == regression.log

validate.log: difftool
@$(MAKE) -C validate -f Makefile test > $@
@grep == validate.log
40 changes: 40 additions & 0 deletions testsuite/regression/AbsoluteClocks.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
-- status: correct
-- teardown_command: rm -rf Absolute_clock-lua/ Absolute_clock_res.mat
-- linux: no
-- ucrt64: yes
-- win: yes
-- mac: no

oms_setCommandLineOption("--suppressPath=true")
oms_setTempDirectory("./Absolute_clock-lua/")


oms_newModel("model")

oms_addSystem("model.root", oms_system_sc)

oms_addSubModel("model.root.A", "../resources/Modelica.Clocked.Examples.CascadeControlledDrive.AbsoluteClocks.fmu")

oms_setVariableStepSize("model", 1e-6, 1e-12, 0.002);
oms_setResultFile("model", "Absolute_clock_res.mat")

oms_instantiate("model")

oms_initialize("model")

oms_simulate("model")

oms_terminate("model")

oms_delete("model")


-- Result:
-- info: maximum step size for 'model.root': 0.002000
-- info: Result file: Absolute_clock_res.mat (bufferSize=1)
-- info: Parameter model.root.A.fastClock.solverMethod will not be stored in the result file, because the signal type is not supported
-- info: Parameter model.root.A.slowClock.solverMethod will not be stored in the result file, because the signal type is not supported
-- info: Final Statistics for 'model.root':
-- NumSteps = 2 NumRhsEvals = 3 NumLinSolvSetups = 2
-- NumNonlinSolvIters = 2 NumNonlinSolvConvFails = 0 NumErrTestFails = 0
-- endResult
54 changes: 54 additions & 0 deletions testsuite/regression/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
TEST = ../rtest -v

TESTFILES = \
AbsoluteClocks.lua \
Pendulum.lua \
simpleLoop.lua \
setStartTime.lua \

# Run make failingtest
FAILINGTESTFILES = \

# Dependency files that are not .lua or Makefile
# Add them here or they will be cleaned.
DEPENDENCIES = \
*.lua \
*.py \
Makefile \

CLEAN = `ls | grep -w -v -f deps.tmp`

.PHONY : test clean getdeps failingtest

test:
@echo
@echo Running tests...
@$(TEST) $(TESTFILES)

baseline:
@echo
@echo Updating badelines...
@$(TEST) -b $(TESTFILES)

# Cleans all files that are not listed as dependencies
clean:
@echo $(DEPENDENCIES) | sed 's/ /\\\|/g' > deps.tmp
@rm -rf $(CLEAN)

# Run this if you want to list out the files (dependencies).
# 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:
@echo $(DEPENDENCIES) | sed 's/ /\\\|/g' > deps.tmp
@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

failingtest:
@echo
@echo Running failing tests...
@echo
@$(TEST) $(FAILINGTESTFILES)
40 changes: 40 additions & 0 deletions testsuite/regression/Pendulum.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
-- status: correct
-- teardown_command: rm -rf Pendulum-lua/ pendulum_res.mat
-- linux: no
-- ucrt64: yes
-- win: yes
-- mac: no

oms_setCommandLineOption("--suppressPath=true")
oms_setTempDirectory("./Pendulum-lua/")


oms_newModel("model")

oms_addSystem("model.root", oms_system_sc)

oms_addSubModel("model.root.A", "../resources/Modelica.Mechanics.MultiBody.Examples.Elementary.Pendulum.fmu")

oms_setVariableStepSize("model", 1e-6, 1e-12, 0.01);
oms_setResultFile("model", "pendulum_res.mat")

oms_instantiate("model")

oms_initialize("model")

oms_simulate("model")

oms_terminate("model")

oms_delete("model")


-- Result:
-- info: maximum step size for 'model.root': 0.010000
-- info: Result file: pendulum_res.mat (bufferSize=1)
-- info: Parameter model.root.A.world.label1 will not be stored in the result file, because the signal type is not supported
-- info: Parameter model.root.A.world.label2 will not be stored in the result file, because the signal type is not supported
-- info: Final Statistics for 'model.root':
-- NumSteps = 118 NumRhsEvals = 134 NumLinSolvSetups = 17
-- NumNonlinSolvIters = 133 NumNonlinSolvConvFails = 0 NumErrTestFails = 2
-- endResult
42 changes: 42 additions & 0 deletions testsuite/regression/setStartTime.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
-- status: correct
-- teardown_command: rm -rf start_time-lua/ start_time_res.mat
-- linux: no
-- ucrt64: yes
-- win: yes
-- mac: no

oms_setCommandLineOption("--suppressPath=true")
oms_setTempDirectory("./start_time-lua/")


oms_newModel("model")

oms_addSystem("model.root", oms_system_sc)

oms_addSubModel("model.root.A", "../resources/setstartTime.fmu")

oms_setStartTime("model", 2.5)
oms_setStopTime("model", 5.0)
oms_setVariableStepSize("model", 1e-6, 1e-12, 0.002);
oms_setResultFile("model", "start_time_res.mat")

oms_instantiate("model")

oms_initialize("model")

oms_simulate("model")

oms_terminate("model")

oms_delete("model")


-- Result:
-- info: maximum step size for 'model.root': 0.002000
-- info: Result file: start_time_res.mat (bufferSize=1)
-- info: Parameter model.root.A.scheme.fileName will not be stored in the result file, because the signal type is not supported
-- info: Parameter model.root.A.scheme.tableName will not be stored in the result file, because the signal type is not supported
-- info: Final Statistics for 'model.root':
-- NumSteps = 1251 NumRhsEvals = 1252 NumLinSolvSetups = 65
-- NumNonlinSolvIters = 1251 NumNonlinSolvConvFails = 0 NumErrTestFails = 0
-- endResult
38 changes: 38 additions & 0 deletions testsuite/regression/simpleLoop.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
-- status: correct
-- teardown_command: rm -rf simple_loop-lua/ simple_loop_res.mat
-- linux: no
-- ucrt64: yes
-- win: yes
-- mac: no

oms_setCommandLineOption("--suppressPath=true")
oms_setTempDirectory("./simple_loop-lua/")


oms_newModel("model")

oms_addSystem("model.root", oms_system_sc)

oms_addSubModel("model.root.A", "../resources/simpleLoop.fmu")

oms_setVariableStepSize("model", 1e-6, 1e-12, 0.002);
oms_setResultFile("model", "simple_loop_res.mat")

oms_instantiate("model")

oms_initialize("model")

oms_simulate("model")

oms_terminate("model")

oms_delete("model")


-- Result:
-- info: maximum step size for 'model.root': 0.002000
-- info: Result file: simple_loop_res.mat (bufferSize=1)
-- info: Final Statistics for 'model.root':
-- NumSteps = 501 NumRhsEvals = 502 NumLinSolvSetups = 27
-- NumNonlinSolvIters = 501 NumNonlinSolvConvFails = 0 NumErrTestFails = 0
-- endResult
4 changes: 4 additions & 0 deletions testsuite/resources/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,10 @@ set(OM_OMS_TESTSUITE_RESOURCES_FMUS
${CMAKE_CURRENT_SOURCE_DIR}/Modelica.Blocks.Sources.Sine
${CMAKE_CURRENT_SOURCE_DIR}/Modelica.Blocks.Sources.Step
${CMAKE_CURRENT_SOURCE_DIR}/Modelica.Electrical.Analog.Examples.CauerLowPassAnalog
${CMAKE_CURRENT_SOURCE_DIR}/Modelica.Mechanics.MultiBody.Examples.Elementary.Pendulum
${CMAKE_CURRENT_SOURCE_DIR}/Modelica.Clocked.Examples.CascadeControlledDrive.AbsoluteClocks
${CMAKE_CURRENT_SOURCE_DIR}/setstartTime
${CMAKE_CURRENT_SOURCE_DIR}/simpleLoop
${CMAKE_CURRENT_SOURCE_DIR}/nls.cs
${CMAKE_CURRENT_SOURCE_DIR}/nls.me
${CMAKE_CURRENT_SOURCE_DIR}/QuarterCarModel.DisplacementDisplacement.Chassis
Expand Down
4 changes: 4 additions & 0 deletions testsuite/resources/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,10 @@ Modelica.Blocks.Sources.Constant \
Modelica.Blocks.Sources.Sine \
Modelica.Blocks.Sources.Step \
Modelica.Electrical.Analog.Examples.CauerLowPassAnalog \
Modelica.Mechanics.MultiBody.Examples.Elementary.Pendulum \
Modelica.Clocked.Examples.CascadeControlledDrive.AbsoluteClocks \
setstartTime \
simpleLoop \
nls.cs \
nls.me \
QuarterCarModel.DisplacementDisplacement.Chassis \
Expand Down
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading