Why does the “der()” operator in Modelica apply to the time variable only?

喜夏-厌秋 提交于 2020-12-30 03:13:37

问题


I build a simple to model in Dymola, but I got confused about the der() operator, why does the der() operator apply to the time variable only? What if I want to use the derivate to other variables

In the following code, if I want to calculate dy/dx(derivative of y to x), how should I do this?

model A
  Real x, y, z;
equation
  x=10;
  y=sin(x);
  z=der(y);
end A;


回答1:


Partial derivatives are supported via functions. See chapter 12.7.2 in Modelica Spec 3.4: Partial Derivatives of Functions.

You have to move the equation of interest into the algorithm section of a function. Your example could look as follows:

model A
  Real x, z;

  function f1
    input Real a;
    output Real b;
  algorithm 
    b :=sin(a);
  end f1;

  function der_f1 = der(f1, a);

equation 
  x = 10;
  z = der_f1(x);
end A;


来源:https://stackoverflow.com/questions/64262053/why-does-the-der-operator-in-modelica-apply-to-the-time-variable-only

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!