Time-varying model parameters remain constant when loading FMU into DaeBuilder
Hi,
I am using the DaeBuilder functionality to read an FMU into CasADi. I have multiple parameters in my model that are function of time. When I create an integrator, these parameters do not change over time as I would expect. When I simulate with the FMU itself, the parameters do change over time. Is this expected behavior?
In attachment a small example of a moving mass where I made the acceleration function of time. Unfortunately I cannot share the FMU itself because it is not in my license plan.
The plot shows how the acceleration changes as a function of time when simulating with the FMU, but remains constant (but does calculate the initial value correctly) when using the integrator
`
Currently I have a workaround where I change the model in a way that time becomes an input variable for the time-varying parameters. I then also have to provide the time as an input to the integrator and output function.
Best regard accelerated_mass.zip
Hi @b-mare did you manage to have a model with some time var as input variable that can also work in OpenModelica? I add a var 'modelTime', then add an equation "modelTime = time" OpenModelica gives an error that the "Equation has no unknown variables to solve for".
We were able to work around the issue by introducing an internal variable for time, e.g. modelTime, and adding a differential equation that will equate it to the Modelive 'time' - der(modelTime) = 1. In the case of the model used in this issue the model would become:
model accelerated_mass
Modelica.Mechanics.Translational.Sources.Accelerate accelerate;
Modelica.Mechanics.Translational.Components.Mass mass(L=1, m=1);
Real acceleration_input = Modelica.Math.cos(10*modelTime)+1; // Use modelTime instead of `time`
Real modelTime(start = 0); // New internal var for the time
Modelica.Blocks.Interfaces.RealOutput mass_x;
Modelica.Blocks.Interfaces.RealOutput mass_v;
Modelica.Blocks.Interfaces.RealOutput mass_a;
equation
der(modelTime) = 1; // Equation to make modelTime = time
mass_x = mass.s;
mass_v = mass.v;
mass_a = mass.a;
acceleration_input = accelerate.a_ref;
connect(accelerate.flange, mass.flange_a);
end accelerated_mass;