Moh*_*mad 2 modelica openmodelica
我遇到了一个可以在 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.
Run Code Online (Sandbox Code Playgroud)
问题是:t*在模拟过程中有一个函数要捕获吗?或者模型如何编程来做到这一点?我尝试了多种方法,但模型永远不会关闭。欢迎提出想法并表示赞赏!
节日快乐/新年快乐!
穆罕默德
您可能会发现我书中的示例和保持示例很有用。它使用基于时间的采样,而您可能希望它基于您的压力值。但原理是一样的。这将允许您记录事件发生的时间。
针对您的具体情况,以下(未经测试的)代码可能与您想要的非常接近:
...
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);
Run Code Online (Sandbox Code Playgroud)