Reputation: 163
I try to control the volume of a tank, but the simulation chatters after 8 s.
This is the control model which is used to control the valves:
model CONTROLLER
Modelica.Blocks.Interfaces.RealInput V_min;
Modelica.Blocks.Interfaces.RealInput V_max;
Modelica.Blocks.Interfaces.RealInput V;
Boolean open1(start=true), open2(start=false);
equation
when V > V_min then
open1 = true;
elsewhen V <= V_min then
open1 = false;
end when;
open2 = not open1;
end CONTROLLER;
Upvotes: 1
Views: 477
Reputation: 697
Try something like
when abs(V - V_min) > 1.E-5 then
open = not pre(open);
end when;
This is a when condition that triggers both ways, but has a small tolerance. You have to initialize the variable open(start = false)
to make sure it works as intended.
If the surrounding system reacts to this change slowly it does not cause chattering, if this directly influences der(V)
it slows the simulation down and may still break.
For good handling of such switches i recommend looking at Modelica.Electrical.Analog.Ideal.IdealDiode
(extends from Modelica.Electrical.Analog.Interfaces.IdealSemiconductor
) which represents an ideal diode. As you might see it is not really the model of a truly ideal diode, but it is as simplified as it can be without causing chattering.
Upvotes: 1
Reputation: 6655
If you use the same threshold to open and close the valves, chattering is the obvious result.
See this answer and Modelica by Example, which both describe very good what chattering is and how it can be avoided.
Upvotes: 3