I am using Dymola's python_interface and want to simulate a set of models:
import platform
from dymola.dymola_interface import DymolaInterface
from dymola.dymola_exception import DymolaException
osString = platform.system()
isWindows = osString.startswith("Win")
with open('ModelList.txt', 'r') as f:
models = f.read().splitlines()
for model in models:
dymola = None
try:
dymola = DymolaInterface("C:\\Program Files\\Dymola 2018 FD01\\bin64\\Dymola.exe")
result = dymola.simulateModel(model)
if not result:
print("Simulation failed:")
log = dymola.getLastErrorLog()
print(log)
else:
print("OK")
except DymolaException as ex:
print(("Error: " + str(ex)))
finally:
if dymola is not None:
dymola.close()
dymola = None
Basically, this is the example given in the Dymola manual (with the added for-loop). Now I want to get the models' simulation time and write it to a (csv-)file.
The simulation time is also written to the log-file, but is there a way to get it directly? The results of the simulation are written to a .mat file which is fine for me.
Thank You for your help!