Given a python script that triggers simulations in the Dynamic Modeling Laboratory (Dymola).
My goal is to get the data of the trajectories of my simulation, but in different sampling intervals. E.g. I want the transient section from 0 sec to 1000 sec to be sampled in 1sec intervals and the steady state section from 1000sec to 100000sec to be sampled in 100sec intervals without having to perform two simulations with different start times, stop times and output intervals.
An excerpt of the code that triggers the simulation for the transient section:
[result, simulation_result] = dymola.simulateExtendedModel(problem=problem,
initialNames=["input1", "input2", "input3"],
initialValues=[input1, input2, input3],
finalNames=output_names,
outputInterval=1,
startTime=0,
stopTime=1000,
resultFile=result_filename)
trajectory_size_transient = dymola.readTrajectorySize("simulation_result_python.mat")
sim_res_transient = np.array(dymola.readTrajectory("simulation_result_python.mat",
output_names,
trajectory_size_transient))
The code for the simulation of the the steady state:
[result, simulation_result] = dymola.simulateExtendedModel(problem=problem,
initialNames=["input1", "input2", "input3"],
initialValues=[input1, input2, input3],
finalNames=output_names,
outputInterval=100,
startTime=1000,
stopTime=10000,
resultFile=result_filename)
trajectory_size_steady = dymola.readTrajectorySize("simulation_result_python.mat")
sim_res_steady = np.array(dymola.readTrajectory("simulation_result_python.mat",
output_names,
trajectory_size_steady))
The value "outputInterval" is the interval in which the results are written into the trajectory. As seen, I have to perform two simulations and stack the results later on. I'd rather have one simulation with two different values of "outputInterval" and set
startTime=0
stopTime=10000
so that I can get two trajectories from one simulation.
Does anyone know if this is possible? Or maybe is there another approach?