在modelica中集成功能 [英] integration of function in modelica

查看:52
本文介绍了在modelica中集成功能的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在 Modelica 中对时间以外的变量的函数进行积分,但我不知道该怎么做.例如,如何计算 x dx 的积分上限为 5,下限为 2?

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

推荐答案

Modelica 并非像 Maple、Mathematica 或 Matlab 那样被设计为 CAS(计算机代数系统),但通过少量编码,您无论如何都可以做到.问题是您的问题不能用 Modelica 工具自动解决,但在数字上是可以的.为了在数值上解决它,您必须使用时间变量替换 x 的技巧,因为在 Modelica 中您可以执行导数,因此只能对时间进行积分.因此,您可以使用要积分的函数创建信号源,然后将其用作 Modelica.Blocks.Continuous.Integrator 块的输入,该块实现了这个简单的等式:

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;

最后,如果您将 t<2t<5 的零作为输入发送到该块,那么您应该在输出 t<2t<5 之间获得正确的积分值code>2 和 5:

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

这篇关于在modelica中集成功能的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆