Modelica - 在模拟过程中冻结特定时间值

Modelica - freezing a specific time value during simulation

我有一个问题,在像 Fortran 这样的因果环境中可以很容易地解决,但在 Modelica 中被证明是困难的,考虑到我有限的知识

考虑一个带有入口和出口的体积。入口质量流量是指定的,而出口质量流量是根据体积中的压力计算的。当体积中的压力超过设定点时,出口面积开始从其初始值线性增加到最大值,然后保持不变。换句话说:

A = min( const * (t - t*) + A_0, A_max)
if p > p_set
where t* = the time at which pressure in the volume exceeds the set pressure.

问题是:在模拟过程中有捕获t*的函数吗?或者如何对模型进行编程来做到这一点?我尝试了多种方法,但模型从未关闭。欢迎和赞赏的想法!

holidays/New年快乐!

穆罕默德

您可能会发现我书中的 sample and hold example 很有用。它使用基于时间的采样,而您可能希望它基于您的压力值。但原理是一样的。这样您就可以记录事件发生的时间。

针对您的具体情况,以下(未经测试的)代码可能与您想要的非常接近:

  ...
  Modelica.SIunits.Time t_star=-1;
equation
  when p >= p_set then
    t_star = time;
  end when;
  A = if t_star<0 then A_max else min(const*(t - t_star) + A_0, A_max);