0

I am trying to simulate same model multiple times but each time I would like to set initial states as the result of previous simulation. In order to do that I am using get_fmu_states and set_fmu_states functions. However I am getting a "FMUException: Failed to update the events at time: 0.000000E+00." error. My code is as follows, if get_fmu_states and set_fmu_states functions are not proper ways to do that how can I do it instead? My code is as follows.

from pyfmi import load_fmu
import numpy as np
import pyfmi
from matplotlib import *


model = load_fmu('BouncingBall.fmu')
opts = model.simulate_options()
opts['CVode_options']['rtol'] = 1e-6  # Set relative tolerance
opts['CVode_options']['atol'] = 1e-8  # Set absolute tolerance
opts["ncp"] = 100 #One hundred output points


res = model.simulate(final_time = 21600, options = opts)
state = model.get_fmu_state()


model2 = load_fmu('BouncingBall.fmu')
model2.set_fmu_state(state)

res2 = model2.simulate(final_time = 21600, options = opts)

I tried setting at different time values but each time I received same error.

0 Answers0