- Index
- » Users
- » Hagmar
- » Profile
Posts
Posts
AnHeuermann wrote:
What step size is your FMU simulation tool using? My guess: It is bigger then 0.01
You were absolutely right. Thank you very much!
When simulating the model below in OpenModelica, x is a damped oscillation, as expected. However, when simulating the model using the generated FMU in co-simulation mode, x is undamped. Does anyone have an explanation for this? I have verified my program for running the FMU with simpler models like an exponential decay, and that looks OK.
model RLC
type Voltage=Real(unit="V");
type Time=Real(unit="s");
type Current=Real(unit="A");
type Resistance=Real(unit="Ohm");
type Capacitance=Real(unit="F");
type Inductance=Real(unit="H");
parameter Voltage qi = 0;
parameter Voltage qf = 0.02;
Voltage x;
protected
Voltage V;
Voltage Vs = qf;
Current i_L;
Current i_R;
Current i_C;
Inductance L = 1;
Resistance R = 100;
Capacitance C = 1e-3;
initial equation
V = qi;
equation
i_R = V/R;
i_C = C*der(V);
i_L=i_R+i_C;
L*der(i_L) = (Vs-V);
x = V;
end RLC;
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;
- Index
- » Users
- » Hagmar
- » Profile