How to determine the maximum mixed time-continuous discrete signal in SimulationX?

There are questions how to determine the maximum of the mixed continuous time and discrete time x (t) for the past time with Modelica, i.e.

y (t) = max {x (s) with s in [startTime, t]}.

This is an open issue in Tracker by Modelica (see https://trac.modelica.org/Modelica/ticket/109 ).

I will give a solution specific to SimultionX.

0
source share
2 answers

SimulationX Modelica last, . , . last - x . . .

model test "test.ism"
    extends SimModel;
    Real x=2*sin(2*pi*time)+sin(20*pi*time)+(if time < 0.5 then 0 else 3) "some input signal with jump";
    Real y=if noEvent( time > time.start ) then max(x,last(y)) else x  "Calculate the maximum with the help of the last-operator";
    Real z(start=0,fixed=true)=-der(z)+y "Just any dymanics.";
end test;

x y .

enter image description here

+3

, last(). , pre() . OpenModelica:

model minTest
Real x;
Real y;
equation      
x = 2. * sin(2.0 * Modelica.Constants.pi * time) + sin(20.0 * Modelica.Constants.pi * time)+ (if time < 0.5 then 0. else 3.);
      y=max(x,pre(y))  ;
end minTest;
+1

All Articles