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

我们两清 提交于 2020-01-17 05:36:28

问题


There are questions how to determine the maximum of a mixed time-continuous and time-discrete signal x(t) over passed time with Modelica, i.e.,

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

This is an open issue in the Modelica bug tracker (see https://trac.modelica.org/Modelica/ticket/109).

I will give a SimultionX-specific solution.


回答1:


SimulationX extends Modelica by the last-operator which returns the last accepted value of the argument. At event-time points it returns the value at which the integration stopped before the event iteration. The last-operator can be used to calculate the maximum of the current x value and the last maximum. See the following working example.

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;

The input signal x and the corresponding output signal y are depicted in the following Figure.




回答2:


I am not sure what exactly last() does. But, from your description it seems to do the same the same thing as pre() in standard modelica. And this gives the same results in 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;


来源:https://stackoverflow.com/questions/31134220/how-to-determine-the-maximum-of-a-mixed-time-continuous-time-discrete-signal-in

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!