integration of function in modelica

前端 未结 1 1703
借酒劲吻你
借酒劲吻你 2021-01-19 17:20

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

相关标签:
1条回答
  • 2021-01-19 18:11

    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:

    enter image description here

    I hope this helps, Marco

    0 讨论(0)
提交回复
热议问题