modelUnfairComparison

Comparison of GSL and Modelica integration routines

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

Information

Example integral: 

I(a) = ∫a1 x-1/2 ln(x) dx 

using the GSL QAGS routine and Modelica.Math.Nonlinear.quadratureLobatto(). Several values of a from 0.1 to 10-6 are explored and the integral is reevaluated for each one. The ratio of the results from the two methods is also calculated for comparison. As the integrand contains a singularity at x=0, the integration is stopped at a=10-6. Only the QAGS result is evaluated for the full range (qAGS_quad0.y = I(0) = -4). The Lobatto routine will hang or crash for values of a < 10-6.

IMPORTANT!!!: The integrand-setup model 'CreateIntegrand2' (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])


Parameters

TypeNameDefaultDescription
Integern_par1
Realb1
Realrel_err1.e-7
Real[n_par]par{1.0}
Integerlimit1000

Components

TypeNameDefaultDescription
Reala
Realz
Modelica.Blocks.Sources.Rampa_ramp
Modelica.Blocks.Sources.RealExpressionres_from_Mod
Modelica.Blocks.Math.Divisioniiratio
Blocks.integration.QAGS_quadratureqAGS_quad
Modelica.Blocks.Sources.Constant[n_par]p_const
Modelica.Blocks.Sources.Constantb_const
Blocks.integration.QAGS_quadratureqAGS_quad0
Modelica.Blocks.Sources.Constantconst0

Contents

NameDescription
func