Archived OpenModelica forums. Posting is disabled.

Alternative forums include GitHub discussions or StackOverflow (make sure to read the Stack Overflow rules; you need to have well-formed questions)


Forgot password? | Forgot username? | Register

Solver instability when using FMU in co-simulation mode

Solver instability when using FMU in co-simulation mode

I am trying to set up a program that can run FMUs in co-simulation mode that can take input signals and deliver output signals. However, I am running into issues with solver stability. I export my model (test model below) from OpenModelica to an FMU, and drive the system with a step on the input xs (using a C program with fmi-library). With step lengths even as short as 10e-4, the output x diverges after the step from 0 to 1. When simulating with OpenModelica, giving an expression for xs, the solution is fine. I guess that this is because OpenModelica can detect the step event, and reinitialize the system? I have, however, not seen any way to do this using FMI with co-simulation, where I do fmiSetReal(...) followed by fmiDoStep(...). Is there any way to remedy this problem?

model PIDTest
  Modelica.Blocks.Continuous.TransferFunction plant(initType = Modelica.Blocks.Types.Init.NoInit, b = {10000}, a={1, 10, 10000})  annotation(
    Placement(visible = true, transformation(origin = {2, 34}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));
  input Real xs;
  output Real x;
  Modelica.Blocks.Continuous.LimPID pid(k = 100, Ti = 0.1, Td = 0.1, yMax=1000000) annotation(
    Placement(visible = true, transformation(origin = {-32, 34}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));
equation
  pid.u_s = xs;
  x = plant.y;
  connect(pid.y, plant.u) annotation(
    Line(points = {{-20, 34}, {-10, 34}}, color = {0, 0, 127}));
  connect(plant.y, pid.u_m) annotation(
    Line(points = {{14, 34}, {20, 34}, {20, 0}, {-32, 0}, {-32, 22}}, color = {0, 0, 127}));
  annotation(
    uses(Modelica(version = "4.0.0")));
end PIDTest;

There are 0 guests and 0 other users also viewing this topic
You are here: