【发布时间】:2020-12-09 13:09:49
【问题描述】:
我正在研究一个包含 dy/dx 导数的简单模型,但在 Modelica 中,我不能直接写这个方程,我可以使用 x=time 和 der(y) 的组合,但我认为这个由于 Modelica 语言的限制,是一种妥协。
我的问题是: 有没有其他更好的方法来描述 Modelica 中的导数?
代码如下:
model HowToExpressDerivative "dy/dx=5, how to describe this equation in Modelica?"
Real x,y;
equation
x = time;
der(y) = 5;
end HowToExpressDerivative;
我也试过用der(y)/der(x)来表达dy/dx,但是当x等于time^2时出现错误。
model HowToExpressDerivative "dy/dx=5, how to describe this equation in Modelica?"
Real x,y;
equation
x=time^2;
der(y)/der(x)=5;
end HowToExpressDerivative;
Error: The following error was detected at time: 0
Model error - division by zero: (1.0) / (der(x)) = (1) / (0)
Error: Integrator failed to start model.
... "HowToExpressDerivative.mat" creating (simulation result file)
ERROR: The simulation of HowToExpressDerivative FAILED
【问题讨论】:
-
仅通过函数支持偏导数,但我想您知道这是对您自己问题之一的回答:stackoverflow.com/questions/64262053/…。如果公式正确,您可以设置
der_f1= 5。 -
您想在需要 dy/dx 的地方建模什么?如果 dy/dx 已知,它似乎与函数案例完全不同。
-
@HansOlsson。这是一个例子:焓和密度相对于曲柄角的变化率。就像下面论文中的方程(5)sciencedirect.com/science/article/pii/S2405896316324843