modelica: compute minimum/maximum of continuous variable over time

后端 未结 3 1226
一生所求
一生所求 2021-01-14 01:35

As stated above: I wish to compute the minimum (and/or maximum) of a continuous variable over time. Here is a minimal example to demonstrate:

model MinMaxTes         


        
3条回答
  •  北荒
    北荒 (楼主)
    2021-01-14 02:20

    For your initial question, what seems to work correctly for me in OpenModelica is this:

    u_min = min(u, pre(u_min));
    u_max = max(u, pre(u_max));
    

    For me that compiles, simulates, and gives the expected results, but also does say "Matrix singular!". On the other hand, if I change the initial declaration for u_max to this:

    Real u_max(start = 0);
    

    Then, the "Matrix singular!" goes away.
    I don't know why, but that does seems to do the job, and I would suggest is more straightforward then the other options you have listed.

提交回复
热议问题