Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

integration of function in modelica

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
like image 419
Tymo Avatar asked May 09 '13 08:05

Tymo


1 Answers

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

like image 116
Marco Romanoni Avatar answered Oct 03 '22 09:10

Marco Romanoni