PB3D [2.47]
Ideal linear high-n MHD stability in 3-D
Loading...
Searching...
No Matches
num_utilities::calc_int Interface Reference

Integrates a function using the trapezoidal rule. More...

Public Member Functions

integer function calc_int_eqd (var, step_size, var_int)
 equidistant version
integer function calc_int_reg (var, x, var_int)
 regular version

Detailed Description

Integrates a function using the trapezoidal rule.

This function can be defined on an equidistant grid or a regular one:

  • For an equidistant grid,

    \[\int_1^n f(x) dx = \sum_{k=1}^{n-1} {\left(f(k+1)+f(k)\right) \frac{\Delta_x}{2}},\]

    is used, with \(n\) the number of points, which are assumed to be equidistant with a given step size \(Delta_x\).
  • For a regular grid,

    \[\int_1^n f(x) dx = \sum_{k=1}^{n-1} {\left(f(k+1)+f(k)\right) \frac{x(k+1)-x(k)}{2}}, \]

    is used, with \(n\) the number of points.
    • Therefore, \(n\) points have to be specified as well as \(n\) values for the function to be integrated.
    • They have to be given in ascending order but the step size does not have to be constant.
    • This yields the following difference formula:

      \[\int_1^n f(x) dx = \int_1^{n-1} f(x) dx + \left(f(n)+f(n-1)\right) \frac{x(n)-x(n-1)}{2},\]

      which is used here
Note
For periodic function, the trapezoidal rule works well only if the last point of the grid is included, i.e. the point where the function is equal to the first point.
Returns
ierr

Definition at line 160 of file num_utilities.f90.

Member Function/Subroutine Documentation

◆ calc_int_eqd()

integer function num_utilities::calc_int::calc_int_eqd ( real(dp), dimension(:), intent(in) var,
real(dp), intent(in) step_size,
real(dp), dimension(:), intent(inout) var_int )

equidistant version

Parameters
[in,out]var_intintegrated variable
[in]varvariable to be integrated
[in]step_sizestep size of abscissa

Definition at line 326 of file num_utilities.f90.

Here is the call graph for this function:

◆ calc_int_reg()

integer function num_utilities::calc_int::calc_int_reg ( real(dp), dimension(:), intent(in) var,
real(dp), dimension(:), intent(in) x,
real(dp), dimension(:), intent(inout) var_int )

regular version

Parameters
[in,out]var_intintegrated variable
[in]varvariable to be integrated
[in]xabscissa

Definition at line 285 of file num_utilities.f90.

Here is the call graph for this function:

The documentation for this interface was generated from the following file: