According to FMI 2.0.4 spec (Section 4.2.4), start values are read during instantiated state via fmi2SetXXX . But libcosim does not run these functions in instantiated state and this makes some of FMUs exported (e.g. Simulink) not initializing values accordingly.
For example see below cosim_demo_app that runs an integrator whose initial condition is set via parameter Parameter.Integrator_x0:
The initial condition is not properly set via the parameter (i.e. not starting from 10).
On the other hand, fmpy properly initialize this value when set in the simulation setting:
To fix this, this PR added an additional function initialize_start_values() that runs before simulator::setup() in fixed_step_algorithm::cosim::impl::initialize()
Check state_init_test.cpp to observe different behaviours with the previous libcosim version
According to FMI 2.0.4 spec (Section 4.2.4), start values are read during
instantiated
state viafmi2SetXXX
. But libcosim does not run these functions ininstantiated
state and this makes some of FMUs exported (e.g. Simulink) not initializing values accordingly.For example see below cosim_demo_app that runs an integrator whose initial condition is set via parameter
Parameter.Integrator_x0
:The initial condition is not properly set via the parameter (i.e. not starting from 10). On the other hand,
fmpy
properly initialize this value when set in the simulation setting:To fix this, this PR added an additional function
initialize_start_values()
that runs beforesimulator::setup()
infixed_step_algorithm::cosim::impl::initialize()
Check
state_init_test.cpp
to observe different behaviours with the previous libcosim version