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.
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
| Type | Name | Default | Description |
|---|---|---|---|
| Integer | n_par | 1 | |
| Real | a | 0 | |
| Real | rel_err | 1.e-6 | |
| Integer | limit | 1000 | |
| Integer | key | 6 |
Components
| Type | Name | Default | Description |
|---|---|---|---|
| Modelica.Blocks.Sources.Ramp | b_ramp | ||
| Modelica.Blocks.Math.Gain | I_qag | ||
| Modelica.Blocks.Math.Division | iiratio | ||
| Modelica.Blocks.Sources.Constant | a_const | ||
| Modelica.Blocks.Sources.Constant[n_par] | p_const | ||
| Blocks.integration.QAG_quadrature | qAG_quad | ||
| Blocks.specfunc.Erf | erf_gsl |