# mus_moments_module Module

This module deals with the calculation of moments from pdfs

## Functions

### public pure function get_moment(QQ, cxDir, expX, pdf) result(mom)

Calculate the moment of a centain order The moment of a distribution $f_i$ is defined as:\n The fucntion argument expX is array of size 3, which contains the values of \f$p, q, r\f$

#### Arguments

TypeIntentOptionalAttributesName
integer, intent(in) :: QQ
integer, intent(in) :: cxDir(3,QQ)
integer, intent(in) :: expX(3)
real(kind=rk), intent(in) :: pdf(QQ)

distribution value

### public pure function get_momentVector(QQ, cxDir, expX) result(mom)

get the moment vector to calculate the moment from the pdf

#### Arguments

TypeIntentOptionalAttributesName
integer, intent(in) :: QQ
integer, intent(in) :: cxDir(3,QQ)
integer, intent(in) :: expX(3)

exponents of the moments

moment vector

### private pure function mus_iMomVector(cxDir, expX, QQ) result(iMom)

The integer moment vector for a given cxDir and order.

#### Arguments

TypeIntentOptionalAttributesName
integer, intent(in) :: cxDir(:,:)

discrete velocity

integer, intent(in) :: expX(3)

order in each direction

integer, intent(in) :: QQ

number of velocity channels (include rest)

## Subroutines

### public subroutine mus_init_moments(me, QQ, cxDir, label, schemeHeader)

Initialize the moment space

#### Arguments

TypeIntentOptionalAttributesName
type(mus_moment_type), intent(inout) :: me
integer, intent(in) :: QQ
integer, intent(in) :: cxDir(3,QQ)
character(len=labelLen) :: label

identifier of the scheme

### public subroutine set_momentIndices(nDims, iPress, iVelMin, iVelMax, iSMin, iSMax)

set indices for accessing the pressure, velocity and the shear from a 1d vector

#### Arguments

TypeIntentOptionalAttributesName
integer, intent(in) :: nDims

number of dimensions

integer, intent(out) :: iPress

index for the pressure / density

integer, intent(out) :: iVelMin

starting index for velocity

integer, intent(out) :: iVelMax

ending index for velocity

integer, intent(out) :: iSMin

starting index for shear

integer, intent(out) :: iSMax

ending index for shear

### public subroutine mus_dump_moments(me, outUnit)

Dump moments matrix: toPDF and toMoment

#### Arguments

TypeIntentOptionalAttributesName
type(mus_moment_type), intent(in) :: me
integer, intent(in) :: outUnit

### private subroutine init_transformation_matrix_fluid(QQ, cxDir, label, me, toMoment, toPdf)

Initialize Moments transformation matrix for LBM compressible and incompressible fluid model. This matrix must be consistent with the relaxation matrix used in compute kernel and interpolation routines

#### Arguments

TypeIntentOptionalAttributesName
integer, intent(in) :: QQ
integer, intent(in) :: cxDir(3,QQ)
character(len=labelLen) :: label
type(mus_moment_type), intent(inout) :: me
real(kind=rk), intent(inout) :: toMoment(me%toMoments%nEntries(1),me%toMoments%nEntries(2))
real(kind=rk), intent(inout) :: toPdf(me%toPDF%nEntries(1),me%toPDF%nEntries(2))

### private subroutine init_transformation_matrix_MS(QQ, cxDir, label, me, toMoment, toPdf)

Intialize the moment transformation matrix for multispecies. This matrix must be consistent with relaxation matrix used for multispecies MRT collision routines

#### Arguments

TypeIntentOptionalAttributesName
integer, intent(in) :: QQ
integer, intent(in) :: cxDir(3,QQ)
character(len=labelLen) :: label
type(mus_moment_type), intent(inout) :: me
real(kind=rk), intent(inout) :: toMoment(me%toMoments%nEntries(1),me%toMoments%nEntries(2))
real(kind=rk), intent(inout) :: toPdf(me%toPDF%nEntries(1),me%toPDF%nEntries(2))