integration of function in modelica

心不动则不痛 提交于 2019-12-10 17:54:36

问题


I would like to perform integration of a function of a variable other than time in Modelica, but I don't know how to do it. For example, how can I evaluate the integral of x dx with upper limit 5 and lower limit 2?

∫x dx=x^2/2

回答1:


Modelica was not designed to be a CAS (computer algebra system) as Maple, Mathematica or Matlab, but with a little coding you can do it anyway. The thing is that your problem can not be solved automatically symbolically with Modelica tools, but numerically yes. In order to solve it numerically you have to do the trick to substitute the x with the time variable since in Modelica you can perform derivatives and therefore integrals only with respect to time. Therefore you can create a signal source with the function you want to integrate and then use it as input of the Modelica.Blocks.Continuous.Integrator block, that implements this simple equation:

model Integrator
  input Real u;
  output Real y;
equation
  der(y) = u;
end Integrator;

Finally if you send as input to this block zero for t<2 and t<5, then you should get in output the correct value of your integral between 2 and 5:

I hope this helps, Marco



来源:https://stackoverflow.com/questions/16457839/integration-of-function-in-modelica

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