发布于 2018-11-26 12:10:41
为了使计算更加通用(例如,权力的符号可以改变),请看下面的代码。从它构建一个函数也是一个好主意(对于noEvent()-statements可以省略).
model DivNoZeroExample
parameter Real eps = 1e-6 "Smallest number to be used as divisor";
Real power = 0.5-time "Some artificial value for power";
Real heat = 1 "Some artificial value for heat";
Real COP "To be computed";
equation
if noEvent(abs(power) < abs(eps)) then
COP = if noEvent(power>= 0) then heat/eps else heat/(-eps);
else
COP = heat/power;
end if;
end DivNoZeroExample;发布于 2018-11-26 11:12:27
在Modelica中,关系操作的工作方式有点不同。
如果您将if u>0替换为if noEvent(u>0),那么它应该会像您预期的那样工作。
有关详细信息,请参阅Modelica规范https://modelica.org/documents/ModelicaSpec34.pdf中的8.5节事件和同步
https://stackoverflow.com/questions/53479601
复制相似问题