# mus_compute_cumulant_module Module

This module contains functions for Cumulant and Cascaded for D3Q27 stencil. author: Gregorio Gerardo Spinelli

## Variables

TypeVisibilityAttributesNameInitial
integer, private, parameter:: QQ =27
integer, private, parameter:: q000 =27

## Functions

### public pure function weights_from_layout(layout_weight) result(w)

allocate weights from D3Q27 ordered disposition to cumulant disposition

#### Arguments

TypeIntentOptionalAttributesName
real(kind=rk), intent(in) :: layout_weight(27)

layout weights

### public pure function weights_ijg(ii, jj, ig, w) result(weight)

Calculating central moment weights This follows equation 3 in cumulent paper (Geier .et al 2017)

#### Arguments

TypeIntentOptionalAttributesName
integer, intent(in) :: ii

indeces of the pdf

integer, intent(in) :: jj

indeces of the pdf

integer, intent(in) :: ig

order gamma of moments

real(kind=rk), intent(in) :: w(-1:1,-1:1,-1:1)

cumulant ordered weights

### public pure function weights_ibg(ii, ib, ig, w_ij_g) result(weight)

Calculating central moment weights This follows equation 3 in cumulent paper (Geier .et al 2017)

#### Arguments

TypeIntentOptionalAttributesName
integer, intent(in) :: ii

indeces of the pdf

integer, intent(in) :: ib

order gamma of moments

integer, intent(in) :: ig

order gamma of moments

real(kind=rk), intent(in) :: w_ij_g(-1:1,-1:1,0:2)

partial weights_ij_g

### public pure function weights_abg(ia, ib, ig, w_i_bg) result(weight)

Calculating central moment weights This follows equation 5 in cumulent paper (Geier .et al 2017)

#### Arguments

TypeIntentOptionalAttributesName
integer, intent(in) :: ia

order gamma of moments

integer, intent(in) :: ib

order gamma of moments

integer, intent(in) :: ig

order gamma of moments

real(kind=rk), intent(in) :: w_i_bg(-1:1,0:2,0:2)

partial weights_i_bg

### public pure function central_moment_split(f, a, b, g, ux, uy, uz) result(kappa)

Calculating central moment by spliting among directions. This follows equations 43, 44, 45 in cumulent paper (Geier .et al 2015) We first do x direction for better performance.

#### Arguments

TypeIntentOptionalAttributesName
real(kind=rk), intent(in) :: f(-1:1,-1:1,-1:1)

PDF

integer, intent(in) :: a

order of central moments

integer, intent(in) :: b

order of central moments

integer, intent(in) :: g

order of central moments

real(kind=rk), intent(in) :: ux
real(kind=rk), intent(in) :: uy
real(kind=rk), intent(in) :: uz

### public pure function central_moment(f, a, b, g, ux, uy, uz) result(kappa)

Calculating central moment. This follows equations 21 in cumulent paper ( Geier .et al 2015 )

#### Arguments

TypeIntentOptionalAttributesName
real(kind=rk), intent(in) :: f(-1:1,-1:1,-1:1)

PDF

integer, intent(in) :: a

order of central moments

integer, intent(in) :: b

order of central moments

integer, intent(in) :: g

order of central moments

real(kind=rk), intent(in) :: ux
real(kind=rk), intent(in) :: uy
real(kind=rk), intent(in) :: uz

### public pure function kum_ij_g(f, ii, jj, gg, uz, w_ij_g) result(kappa)

Calculating central moment This follows equations 6-8 in cumulent paper (Geier .et al 2017)

#### Arguments

TypeIntentOptionalAttributesName
real(kind=rk), intent(in) :: f(-1:1,-1:1,-1:1)

PDF

integer, intent(in) :: ii

indeces of the pdf

integer, intent(in) :: jj

indeces of the pdf

integer, intent(in) :: gg

order gamma of moments

real(kind=rk), intent(in) :: uz

z-component of velocity

real(kind=rk), intent(in) :: w_ij_g(-1:1,-1:1,0:2)

partial weights_ij_g

### public pure function kum_i_bg(ii, bb, gg, uy, w_i_bg, k_ij_g) result(kappa)

Calculating central moment This follows equations 9-11 in cumulent paper (Geier .et al 2017)

#### Arguments

TypeIntentOptionalAttributesName
integer, intent(in) :: ii

indeces of the pdf

integer, intent(in) :: bb

order gamma of moments

integer, intent(in) :: gg

order gamma of moments

real(kind=rk), intent(in) :: uy

y-, z-component of velocity

real(kind=rk), intent(in) :: w_i_bg(-1:1,0:2,0:2)

partial weights_i_bg

real(kind=rk), intent(in) :: k_ij_g(-1:1,-1:1,0:2)

partial cumulants_ij_g

### public pure function kum_abg(aa, bb, gg, ux, w_abg, k_i_bg) result(kappa)

Calculating central moment This follows equations 12-14 in cumulent paper (Geier .et al 2017)

#### Arguments

TypeIntentOptionalAttributesName
integer, intent(in) :: aa

order gamma of moments

integer, intent(in) :: bb

order gamma of moments

integer, intent(in) :: gg

order gamma of moments

real(kind=rk), intent(in) :: ux

x-, y-, z-component of velocity

real(kind=rk), intent(in) :: w_abg(0:2,0:2,0:2)

partial weights_abg

real(kind=rk), intent(in) :: k_i_bg(-1:1,0:2,0:2)

partial cumulants_i_bg

### public pure function kpc_i_bg(k, ii, bb, gg, ux, w_abg) result(kappa)

Back to central moment This follows equations 57-59 in cumulent paper (Geier .et al 2017)

#### Arguments

TypeIntentOptionalAttributesName
real(kind=rk), intent(in) :: k(0:2,0:2,0:2)

cumulant

integer, intent(in) :: ii

indeces of the pdf

integer, intent(in) :: bb

order gamma of moments

integer, intent(in) :: gg

order gamma of moments

real(kind=rk), intent(in) :: ux

x-component of velocity

real(kind=rk), intent(in) :: w_abg(0:2,0:2,0:2)

partial weights_abg

### public pure function kpc_ij_g(ii, jj, gg, uy, w_i_bg, k_i_bg) result(kappa)

Back to central moment This follows equations 60-62 in cumulent paper (Geier .et al 2017)

#### Arguments

TypeIntentOptionalAttributesName
integer, intent(in) :: ii

indeces of the pdf

integer, intent(in) :: jj

indeces of the pdf

integer, intent(in) :: gg

order gamma of moments

real(kind=rk), intent(in) :: uy

y-component of velocity

real(kind=rk), intent(in) :: w_i_bg(-1:1,0:2,0:2)

partial weights_i_bg

real(kind=rk), intent(in) :: k_i_bg(-1:1,0:2,0:2)

partial cumulant_i_bg

### public pure function kpc_ijk(ii, jj, kk, uz, w_ij_g, k_ij_g) result(kappa)

Back to central moment This follows equations 63-65 in cumulent paper (Geier .et al 2017)

#### Arguments

TypeIntentOptionalAttributesName
integer, intent(in) :: ii

indeces of the pdf

integer, intent(in) :: jj

indeces of the pdf

integer, intent(in) :: kk

indeces of the pdf

real(kind=rk), intent(in) :: uz

x-, y-, z-component of velocity

real(kind=rk), intent(in) :: w_ij_g(-1:1,-1:1,0:2)

partial weights_ij_g

real(kind=rk), intent(in) :: k_ij_g(-1:1,-1:1,0:2)

partial cumulants_ij_g

### public pure function cm_to_pdf(k, ux, uy, uz) result(f)

#### Arguments

TypeIntentOptionalAttributesName
real(kind=rk), intent(in) :: k(0:2,0:2,0:2)
real(kind=rk), intent(in) :: ux
real(kind=rk), intent(in) :: uy
real(kind=rk), intent(in) :: uz

## Subroutines

### public subroutine cumulant_d3q27(fieldProp, inState, outState, auxField, neigh, nElems, nSolve, level, layout, params, varSys, derVarPos)

No comment yet!

#### Arguments

TypeIntentOptionalAttributesName
type(mus_field_prop_type), intent(in) :: fieldProp(:)

Array of field properties (fluid or species)

real(kind=rk), intent(in) :: inState(nElems*varSys%nScalars)

input pdf vector

real(kind=rk), intent(out) :: outState(nElems*varSys%nScalars)

output pdf vector

real(kind=rk), intent(inout) :: auxField(nElems*varSys%nAuxScalars)

Auxiliary field computed from pre-collision state Is updated with correct velocity field for multicomponent models

integer, intent(in) :: neigh(nElems*layout%fStencil%QQ)

connectivity vector

integer, intent(in) :: nElems

number of elements in state Array

integer, intent(in) :: nSolve

number of elements solved in kernel

integer, intent(in) :: level

current level

type(mus_scheme_layout_type), intent(in) :: layout

current layout

type(mus_param_type), intent(in) :: params

global parameters

type(tem_varSys_type), intent(in) :: varSys

variable system definition

type(mus_derVarPos_type), intent(in) :: derVarPos(:)

position of derived quantities in varsys for all fields

### public subroutine cumulant_d3q27_extended_fast(fieldProp, inState, outState, auxField, neigh, nElems, nSolve, level, layout, params, varSys, derVarPos)

Cumulant kernel based on Geier2017 and optimized. Just omega(2) is given in input. omega(2)=-1 means omega2=omegaBulk. Limiters read from input. lim(N)=10^10 means unlimited. lim(N) is for omega(N+2). Just omega(3:5) are limited as in the paper. omega(6:10) = 1._rk

#### Arguments

TypeIntentOptionalAttributesName
type(mus_field_prop_type), intent(in) :: fieldProp(:)

Array of field properties (fluid or species)

real(kind=rk), intent(in) :: inState(nElems*varSys%nScalars)

input pdf vector

real(kind=rk), intent(out) :: outState(nElems*varSys%nScalars)

output pdf vector

real(kind=rk), intent(inout) :: auxField(nElems*varSys%nAuxScalars)

Auxiliary field computed from pre-collision state Is updated with correct velocity field for multicomponent models

integer, intent(in) :: neigh(nElems*layout%fStencil%QQ)

connectivity vector

integer, intent(in) :: nElems

number of elements in state Array

integer, intent(in) :: nSolve

number of elements solved in kernel

integer, intent(in) :: level

current level

type(mus_scheme_layout_type), intent(in) :: layout

current layout

type(mus_param_type), intent(in) :: params

global parameters

type(tem_varSys_type), intent(in) :: varSys

variable system definition

type(mus_derVarPos_type), intent(in) :: derVarPos(:)

position of derived quantities in varsys for all fields

### public subroutine cumulant_d3q27_extended_generic(fieldProp, inState, outState, auxField, neigh, nElems, nSolve, level, layout, params, varSys, derVarPos)

Cumulant based on Geier2017 paper. With all modifications and limiters. All omegas are given in input. When omega(N) = -1 means adjusted in this routine. omega(2)=-1 means omega2=omegaBulk. Limiters read from input. lim(N)=10^10 means unlimited. lim(N) is for omega(N+2). Just omega(3:5) are limited as in the paper.

#### Arguments

TypeIntentOptionalAttributesName
type(mus_field_prop_type), intent(in) :: fieldProp(:)

Array of field properties (fluid or species)

real(kind=rk), intent(in) :: inState(nElems*varSys%nScalars)

input pdf vector

real(kind=rk), intent(out) :: outState(nElems*varSys%nScalars)

output pdf vector

real(kind=rk), intent(inout) :: auxField(nElems*varSys%nAuxScalars)

Auxiliary field computed from pre-collision state Is updated with correct velocity field for multicomponent models

integer, intent(in) :: neigh(nElems*layout%fStencil%QQ)

connectivity vector

integer, intent(in) :: nElems

number of elements in state Array

integer, intent(in) :: nSolve

number of elements solved in kernel

integer, intent(in) :: level

current level

type(mus_scheme_layout_type), intent(in) :: layout

current layout

type(mus_param_type), intent(in) :: params

global parameters

type(tem_varSys_type), intent(in) :: varSys

variable system definition

type(mus_derVarPos_type), intent(in) :: derVarPos(:)

position of derived quantities in varsys for all fields

### public subroutine cascaded_d3q27(fieldProp, inState, outState, auxField, neigh, nElems, nSolve, level, layout, params, varSys, derVarPos)

No comment yet!

#### Arguments

TypeIntentOptionalAttributesName
type(mus_field_prop_type), intent(in) :: fieldProp(:)

Array of field properties (fluid or species)

real(kind=rk), intent(in) :: inState(nElems*varSys%nScalars)

input pdf vector

real(kind=rk), intent(out) :: outState(nElems*varSys%nScalars)

output pdf vector

real(kind=rk), intent(inout) :: auxField(nElems*varSys%nAuxScalars)

Auxiliary field computed from pre-collision state Is updated with correct velocity field for multicomponent models

integer, intent(in) :: neigh(nElems*layout%fStencil%QQ)

connectivity vector

integer, intent(in) :: nElems

number of elements in state Array

integer, intent(in) :: nSolve

number of elements solved in kernel

integer, intent(in) :: level

current level

type(mus_scheme_layout_type), intent(in) :: layout

current layout

type(mus_param_type), intent(in) :: params

global parameters

type(tem_varSys_type), intent(in) :: varSys

variable system definition

type(mus_derVarPos_type), intent(in) :: derVarPos(:)

position of derived quantities in varsys for all fields