Skip to content

Commit

Permalink
Update tests
Browse files Browse the repository at this point in the history
  • Loading branch information
lochel authored and OpenModelica-Hudson committed Jan 18, 2019
1 parent d663c40 commit 84a90a3
Show file tree
Hide file tree
Showing 3 changed files with 58 additions and 58 deletions.
48 changes: 24 additions & 24 deletions omsimulator/DualMassOscillator_me.mos
Expand Up @@ -8,39 +8,39 @@ buildModelFMU(DualMassOscillator.System1, version="2.0", fmuType="me", platforms
buildModelFMU(DualMassOscillator.System2, version="2.0", fmuType="me", platforms={"static"}); getErrorString();

writeFile("DualMassOscillator_me.lua", "
oms3_setCommandLineOption(\"--suppressPath=true\")
oms3_setTempDirectory(\"./temp-DualMassOscillator_me/\")
oms_setCommandLineOption(\"--suppressPath=true\")
oms_setTempDirectory(\"./temp-DualMassOscillator_me/\")

oms3_newModel(\"DualMassOscillator\")
oms3_addSystem(\"DualMassOscillator.root\", oms_system_sc)
oms3_addSubModel(\"DualMassOscillator.root.system1\", \"DualMassOscillator.System1.fmu\")
oms3_addSubModel(\"DualMassOscillator.root.system2\", \"DualMassOscillator.System2.fmu\")
oms_newModel(\"DualMassOscillator\")
oms_addSystem(\"DualMassOscillator.root\", oms_system_sc)
oms_addSubModel(\"DualMassOscillator.root.system1\", \"DualMassOscillator.System1.fmu\")
oms_addSubModel(\"DualMassOscillator.root.system2\", \"DualMassOscillator.System2.fmu\")

oms3_addConnection(\"DualMassOscillator.root.system1.F\", \"DualMassOscillator.root.system2.F\")
oms3_addConnection(\"DualMassOscillator.root.system1.s1\", \"DualMassOscillator.root.system2.s1\")
oms3_addConnection(\"DualMassOscillator.root.system1.v1\", \"DualMassOscillator.root.system2.v1\")
oms3_addConnection(\"DualMassOscillator.root.system1.a1\", \"DualMassOscillator.root.system2.a1\")
oms_addConnection(\"DualMassOscillator.root.system1.F\", \"DualMassOscillator.root.system2.F\")
oms_addConnection(\"DualMassOscillator.root.system1.s1\", \"DualMassOscillator.root.system2.s1\")
oms_addConnection(\"DualMassOscillator.root.system1.v1\", \"DualMassOscillator.root.system2.v1\")
oms_addConnection(\"DualMassOscillator.root.system1.a1\", \"DualMassOscillator.root.system2.a1\")

oms3_setResultFile(\"DualMassOscillator\", \"\")
oms3_setStopTime(\"DualMassOscillator\", 0.1)
oms3_setFixedStepSize(\"DualMassOscillator.root\", 1e-4)
oms3_setTolerance(\"DualMassOscillator.root\", 1e-6)
oms_setResultFile(\"DualMassOscillator\", \"\")
oms_setStopTime(\"DualMassOscillator\", 0.1)
oms_setFixedStepSize(\"DualMassOscillator.root\", 1e-4)
oms_setTolerance(\"DualMassOscillator.root\", 1e-6)

oms3_instantiate(\"DualMassOscillator\")
oms3_setReal(\"DualMassOscillator.root.system2.s2_start\", 2.5)
oms_instantiate(\"DualMassOscillator\")
oms_setReal(\"DualMassOscillator.root.system2.s2_start\", 2.5)

oms3_initialize(\"DualMassOscillator\")
oms_initialize(\"DualMassOscillator\")
print(\"info: Initialization\")
print(\"info: system1.s1: \" .. oms3_getReal(\"DualMassOscillator.root.system1.s1\"))
print(\"info: system2.s2: \" .. oms3_getReal(\"DualMassOscillator.root.system2.s2\"))
print(\"info: system1.s1: \" .. oms_getReal(\"DualMassOscillator.root.system1.s1\"))
print(\"info: system2.s2: \" .. oms_getReal(\"DualMassOscillator.root.system2.s2\"))

oms3_simulate(\"DualMassOscillator\")
oms_simulate(\"DualMassOscillator\")
print(\"info: Simulation\")
print(\"info: system1.s1: \" .. oms3_getReal(\"DualMassOscillator.root.system1.s1\"))
print(\"info: system2.s2: \" .. oms3_getReal(\"DualMassOscillator.root.system2.s2\"))
print(\"info: system1.s1: \" .. oms_getReal(\"DualMassOscillator.root.system1.s1\"))
print(\"info: system2.s2: \" .. oms_getReal(\"DualMassOscillator.root.system2.s2\"))

oms3_terminate(\"DualMassOscillator\")
oms3_delete(\"DualMassOscillator\")
oms_terminate(\"DualMassOscillator\")
oms_delete(\"DualMassOscillator\")
"); getErrorString();

system(getInstallationDirectoryPath() + "/bin/OMSimulator --ignoreInitialUnknowns=true DualMassOscillator_me.lua");
Expand Down
36 changes: 18 additions & 18 deletions omsimulator/initialization.mos
Expand Up @@ -19,31 +19,31 @@ end initialization;"); getErrorString();
buildModelFMU(initialization, version="2.0", fmuType="me", platforms={"static"}); getErrorString();

writeFile("initialization.lua", "
oms3_setCommandLineOption(\"--suppressPath=true\")
oms3_setTempDirectory(\"./temp-initialization/\")
oms_setCommandLineOption(\"--suppressPath=true\")
oms_setTempDirectory(\"./temp-initialization/\")

oms3_newModel(\"test\")
oms3_addSystem(\"test.root\", oms_system_sc)
oms3_addSubModel(\"test.root.A\", \"initialization.fmu\")
oms3_setResultFile(\"test\", \"\")
oms_newModel(\"test\")
oms_addSystem(\"test.root\", oms_system_sc)
oms_addSubModel(\"test.root.A\", \"initialization.fmu\")
oms_setResultFile(\"test\", \"\")

oms3_instantiate(\"test\")
oms3_setReal(\"test.root.A.x_start\", 1.5)
oms_instantiate(\"test\")
oms_setReal(\"test.root.A.x_start\", 1.5)

oms3_initialize(\"test\")
oms_initialize(\"test\")
print(\"info: Initialization\")
print(\"info: A.x_start: \" .. oms3_getReal(\"test.root.A.x_start\"))
print(\"info: A.x: \" .. oms3_getReal(\"test.root.A.x\"))
print(\"info: A.w: \" .. oms3_getReal(\"test.root.A.w\"))
print(\"info: A.x_start: \" .. oms_getReal(\"test.root.A.x_start\"))
print(\"info: A.x: \" .. oms_getReal(\"test.root.A.x\"))
print(\"info: A.w: \" .. oms_getReal(\"test.root.A.w\"))

oms3_simulate(\"test\")
oms_simulate(\"test\")
print(\"info: Simulation\")
print(\"info: A.x_start: \" .. oms3_getReal(\"test.root.A.x_start\"))
print(\"info: A.x: \" .. oms3_getReal(\"test.root.A.x\"))
print(\"info: A.w: \" .. oms3_getReal(\"test.root.A.w\"))
print(\"info: A.x_start: \" .. oms_getReal(\"test.root.A.x_start\"))
print(\"info: A.x: \" .. oms_getReal(\"test.root.A.x\"))
print(\"info: A.w: \" .. oms_getReal(\"test.root.A.w\"))

oms3_terminate(\"test\")
oms3_delete(\"test\")
oms_terminate(\"test\")
oms_delete(\"test\")
"); getErrorString();

system(getInstallationDirectoryPath() + "/bin/OMSimulator initialization.lua");
Expand Down
32 changes: 16 additions & 16 deletions omsimulator/initialization2.mos
Expand Up @@ -21,26 +21,26 @@ writeFile("input.csv", "time,y
"); getErrorString();

writeFile("initialization2.lua", "
oms3_setCommandLineOption(\"--suppressPath=true\")
oms3_setTempDirectory(\"./temp-initialization2/\")
oms_setCommandLineOption(\"--suppressPath=true\")
oms_setTempDirectory(\"./temp-initialization2/\")

oms3_newModel(\"test\")
oms3_addSystem(\"test.root\", oms_system_sc)
oms3_addSubModel(\"test.root.A\", \"input.csv\")
oms3_addSubModel(\"test.root.B\", \"initialization2.fmu\")
oms3_addConnection(\"test.root.A.y\", \"test.root.B.u\")
oms3_setResultFile(\"test\", \"\")
oms_newModel(\"test\")
oms_addSystem(\"test.root\", oms_system_sc)
oms_addSubModel(\"test.root.A\", \"input.csv\")
oms_addSubModel(\"test.root.B\", \"initialization2.fmu\")
oms_addConnection(\"test.root.A.y\", \"test.root.B.u\")
oms_setResultFile(\"test\", \"\")

oms3_instantiate(\"test\")
oms3_initialize(\"test\")
oms_instantiate(\"test\")
oms_initialize(\"test\")
print(\"info: Initialization\")
print(\"info: A.y: \" .. oms3_getReal(\"test.root.A.y\"))
print(\"info: B.x: \" .. oms3_getReal(\"test.root.B.x\"))
print(\"info: B.y: \" .. oms3_getReal(\"test.root.B.y\"))
print(\"info: B.u: \" .. oms3_getReal(\"test.root.B.u\"))
print(\"info: A.y: \" .. oms_getReal(\"test.root.A.y\"))
print(\"info: B.x: \" .. oms_getReal(\"test.root.B.x\"))
print(\"info: B.y: \" .. oms_getReal(\"test.root.B.y\"))
print(\"info: B.u: \" .. oms_getReal(\"test.root.B.u\"))

oms3_terminate(\"test\")
oms3_delete(\"test\")
oms_terminate(\"test\")
oms_delete(\"test\")
"); getErrorString();

system(getInstallationDirectoryPath() + "/bin/OMSimulator initialization2.lua");
Expand Down

0 comments on commit 84a90a3

Please sign in to comment.