-
Notifications
You must be signed in to change notification settings - Fork 0
/
example.py
38 lines (32 loc) · 1 KB
/
example.py
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
import sys
egg_path='./eggs/dymola.egg'
sys.path.append(egg_path)
import platform
from dymola.dymola_interface import DymolaInterface
from dymola.dymola_exception import DymolaException
osString = platform.system()
isWindows = osString.startswith("Win")
dymola = None
try:
# Instantiate the Dymola interface and start Dymola
dymola = DymolaInterface()
# Call a function in Dymola and check its return value
result = dymola.simulateModel("Modelica.Mechanics.Rotational.Examples.CoupledClutches")
if not result:
print("Simulation failed. Below is the translation log.")
log = dymola.getLastErrorLog()
print(log)
exit(1)
dymola.plot(["J1.w", "J2.w", "J3.w", "J4.w"])
if (isWindows):
plotPath = "C:/temp/plot.png"
else:
plotPath = "/tmp/plot.png";
dymola.ExportPlotAsImage(plotPath)
print("OK")
except DymolaException as ex:
print(("Error: " + str(ex)))
finally:
if dymola is not None:
dymola.close()
dymola = None