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

Chattering - how to avoid?

Chattering - how to avoid?

Hi.
I wrote in Dymola a Modelica code:

Code:

equation 

  i_eneu=
    if (u_ist - u_soll <= 0) then (u_ist-L_e*der(i_e))/R_e
    else (U_f-L_e*der(i_e))/R_e;

For simulation I want to use DASSL Integration Algorithm. DASSL got variable integration steps, so I get this error:

Code:

 WARNING: You have many state events. It might be due to chattering.

Because the Integration steps get very very small. The simulation gets stuck.

With EULER as Integration Algorithm it works fine. (Euler=fixed Integration steps).

But I have to use DASSL. Can anyone help me with this?

thanks

Edited by: mx - Jan-25-12 12:38:10

Re: Chattering - how to avoid?

Yes solvers often have difficulties whith these instanteneous switches, best is to use smooth switches such as the Modelica.Fluid.Utilities.regStep function or the spliceFunction from the Buildings library (http://simulationresearch.lbl.gov/modelica).

Good luck with it.

Arne

function spliceFunction
    input Real pos "Argument of x > 0";
    input Real neg "Argument of x < 0";
    input Real x "Independent value";
    input Real deltax "Half width of transition interval";
    output Real out "Smoothed value";
protected
    Real scaledX;
    Real scaledX1;
    Real y;
algorithm
    scaledX1 := x/deltax;
    scaledX := scaledX1*Modelica.Math.asin(1);
    if scaledX1 <= -0.999999999 then
      y := 0;
    elseif scaledX1 >= 0.999999999 then
      y := 1;
    else
      y := (Modelica.Math.tanh(Modelica.Math.tan(scaledX)) + 1)/2;
    end if;
    out := pos*y + (1 - y)*neg;

  annotation (smoothOrder=1,derivative=BaseClasses.der_spliceFunction);
end spliceFunction;

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