modelExampleIntegral

Example integration using GSL

Extends from Modelica.Icons.Example (Icon for runnable examples).

Information

Example integral: 

I(b) = 2/sqrt(pi) ∫0b exp(-x*x) dx 

using the GSL QAG routine and a comparison with the known result: erf(b). Several values of b from 0.01 to 1 are explored and the integral is reevaluated for each one. The ratio of I(b)/erf(b) is also calculated and is always consistent with 1.

IMPORTANT!!!: The integrand-setup model 'CreateIntegrand' (or a duplicate) must be run before using GSL integration routines within a larger Modelica model (like this one). (Alternatively, one could edit integrand.c directly and then compile "by hand" in a command window:
gcc -fPIC -c integrand.c integration_mi.c
gcc -shared integration.o integration_mi.o -o libgsl_integration_MI.so  [.dll for windows])


For the relevant meanings of the 'rel_err', 'limit', 'key', etc., see the 'qag' function and:

Parameters

TypeNameDefaultDescription
Integern_par1
Reala0
Realrel_err1.e-6
Integerlimit1000
Integerkey6

Components

TypeNameDefaultDescription
Modelica.Blocks.Sources.Rampb_ramp
Modelica.Blocks.Math.GainI_qag
Modelica.Blocks.Math.Divisioniiratio
Modelica.Blocks.Sources.Constanta_const
Modelica.Blocks.Sources.Constant[n_par]p_const
Blocks.integration.QAG_quadratureqAG_quad
Blocks.specfunc.Erferf_gsl