问题描述
我正在研究一个包含 dy/dx 导数的简单模型,但在 Modelica 中,我不能直接写出这个方程,我可以使用 x=time
和 der(y)
,但我认为这是一种妥协,因为 Modelica 语言的限制.
I am working on a simple model which includes a derivative of dy/dx, but in Modelica, I can't write this equation directly, I could use the combination of x=time
and der(y)
, but I think this is a compromise because of limitation of Modelica language.
我的问题是:有没有其他更好的方法来描述 Modelica 中的导数?
My question is:Is there another better method to describe derivative in 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
.
I also tried to use der(y)/der(x)
to express dy/dx
, but there is an error when x equals 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
推荐答案
给定焓 h
和曲柄角 phi
你可以替换 dh/dphi=...
作者:
Given enthalpy h
and crank-angle phi
you could replace dh/dphi=...
by:
der(h)/der(phi)=...
但是,即使正确该公式也会在引擎静止时失效(der(phi)=0
),因此并不理想.
However, even if correct that formula will break down when the engine is standing still (der(phi)=0
), so it is not ideal.
另一种方法是重写公式.仔细观察公式似乎是:
An alternative would be to rewrite the formulas. Looking more closely the formula seems to be:
dh/dphi=(\partial a/\partial T)*dT/dphi+...
这表明它们可以重写为:
which suggests that they could be rewritten as:
der(h)=(\partial a/\partial T)*der(T)+...
这篇关于如何在 Modelica 中描述 dy/dx 的导数?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!