-
Notifications
You must be signed in to change notification settings - Fork 297
/
DualMassOscillator_cs.mos
84 lines (71 loc) · 4 KB
/
DualMassOscillator_cs.mos
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
// keywords: fmu export import
// status: correct
// teardown_command: rm -rf DualMassOscillator_cs.lua DualMassOscillator.System1.fmu DualMassOscillator.System2.fmu DualMassOscillator_System1.log DualMassOscillator_System2.log DualMassOscillator_cs_systemCall.log temp-DualMassOscillator_cs/
loadFile("DualMassOscillator.mo"); getErrorString();
buildModelFMU(DualMassOscillator.System1, version="2.0", fmuType="cs", fileNamePrefix="DualMassOscillator.System1", platforms={"static"}); getErrorString();
buildModelFMU(DualMassOscillator.System2, version="2.0", fmuType="cs", fileNamePrefix="DualMassOscillator.System2", platforms={"static"}); getErrorString();
writeFile("DualMassOscillator_cs.lua", "
oms_setCommandLineOption(\"--suppressPath=true\")
oms_setTempDirectory(\"./temp-DualMassOscillator_cs/\")
oms_newModel(\"DualMassOscillator\")
oms_addSystem(\"DualMassOscillator.root\", oms_system_wc)
oms_addSubModel(\"DualMassOscillator.root.system1\", \"DualMassOscillator.System1.fmu\")
oms_addSubModel(\"DualMassOscillator.root.system2\", \"DualMassOscillator.System2.fmu\")
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\")
oms_setResultFile(\"DualMassOscillator\", \"\")
oms_setStopTime(\"DualMassOscillator\", 0.1)
oms_setFixedStepSize(\"DualMassOscillator.root\", 1e-5)
oms_setTolerance(\"DualMassOscillator.root\", 1e-6)
oms_instantiate(\"DualMassOscillator\")
oms_setReal(\"DualMassOscillator.root.system2.s2_start\", 2.5)
oms_initialize(\"DualMassOscillator\")
print(\"info: Initialization\")
print(\"info: system1.s1: \" .. oms_getReal(\"DualMassOscillator.root.system1.s1\"))
print(\"info: system2.s2: \" .. oms_getReal(\"DualMassOscillator.root.system2.s2\"))
oms_simulate(\"DualMassOscillator\")
print(\"info: Simulation\")
print(\"info: system1.s1: \" .. oms_getReal(\"DualMassOscillator.root.system1.s1\"))
print(\"info: system2.s2: \" .. oms_getReal(\"DualMassOscillator.root.system2.s2\"))
oms_terminate(\"DualMassOscillator\")
oms_delete(\"DualMassOscillator\")
"); getErrorString();
system(getInstallationDirectoryPath() + "/bin/OMSimulator DualMassOscillator_cs.lua", "DualMassOscillator_cs_systemCall.log");
readFile("DualMassOscillator_cs_systemCall.log");
simulate(DualMassOscillator.CoupledSystem, stopTime=0.1, simflags="-override=system2.s2_start=2.5"); getErrorString();
val(system1.s1, {0.0,0.1});
val(system2.s2, {0.0,0.1});
// Result:
// true
// "Notification: Automatically loaded package Modelica 3.2.2 due to uses annotation from DualMassOscillator.
// Notification: Automatically loaded package Complex 3.2.2 due to uses annotation from Modelica.
// Notification: Automatically loaded package ModelicaServices 3.2.2 due to uses annotation from Modelica.
// "
// "DualMassOscillator.System1.fmu"
// ""
// "DualMassOscillator.System2.fmu"
// ""
// true
// ""
// 0
// "info: No result file will be created
// info: Initialization
// info: system1.s1: 1.0
// info: system2.s2: 2.5
// info: Simulation
// info: system1.s1: 0.87154409411158
// info: system2.s2: 1.9937955391923
// "
// record SimulationResult
// resultFile = "DualMassOscillator.CoupledSystem_res.mat",
// simulationOptions = "startTime = 0.0, stopTime = 0.1, numberOfIntervals = 500, tolerance = 1e-06, method = 'dassl', fileNamePrefix = 'DualMassOscillator.CoupledSystem', options = '', outputFormat = 'mat', variableFilter = '.*', cflags = '', simflags = '-override=system2.s2_start=2.5'",
// messages = "LOG_SUCCESS | info | The initialization finished successfully without homotopy method.
// LOG_SUCCESS | info | The simulation finished successfully.
// "
// end SimulationResult;
// ""
// {1.0,0.9112766780030248}
// {2.5,1.955637128659751}
// endResult