MMM Library Documentation

Contents

Public Definitions

The MMM module modmmm makes the following public definitions available via the compiled library file libmmm.a. The statement Use modmmm is required to access the public definitions in this section. The current version of MMM can be referenced using the public character MMM_VERSION.

Public Subroutines

Two public subroutines are specified by the MMM module:

Public :: mmm               ! Main subroutine
Public :: set_mmm_switches  ! Specify real and integer switch options (Optional)

Each of these subroutine calls will be explained in greater detail below (see MMM Subroutine). Note that the main subroutine mmm can be called without calling set_mmm_switches beforehand, which will run MMM using default options (see Model Options).

Subroutine Dimensions

Public parameters are used to specify the size of various arrays used by MMM:

Integer, Parameter, Public :: &
   MMM_NCH   = 6, &  ! Number of transport channels
   MMM_NMODE = 4, &  ! Number of internal models
   MMM_NOPT  = 20    ! Maximum number of internal switch options per model

These parameters should be referenced by external codes using MMM for array initialization, as needed.

Model Identifiers

Public parameters are also used to reference each model K<MODEL> within MMM:

Integer, Parameter, Public :: &
   KW20  = 1, &  ! Weiland (W20)
   KDBM  = 2, &  ! Drift-Resistive-Inertial Ballooning Modes (DBM)
   KETGM = 3, &  ! Electron Temperature Gradient Modes (ETGM)
   KMTM  = 4, &  ! Microtearing Modes (MTM)

These model identifiers should be referenced by external codes using MMM when specifying internal switch values, as model integer values are subject to change in future updates.

Input Options

Model Weights

Model weights are specified by the optional input array cmodel of dimension (MMM_NMODE) (see Subroutine Dimensions), where array indices should be referenced using the Model Identifiers. Setting the weight of any model to 0 will disable that model. All models are enabled by default.

Model Options

Real and Integer options are passed in via the optional input arrays rswitch and iswitch, respectively, with dimensions (MMM_NOPT,MMM_NMODE) (see Subroutine Dimensions). These arrays can be initialized with default values by making the following subroutine call:

CALL set_mmm_switches(rswitch=rswitch, iswitch=iswitch) 

Afterwards, values can be modified as needed before passing these arrays into MMM via the main subroutine call. The first dimension here corresponds to the model identifier K<MODEL> (see Model Identifiers), and the second dimension corresponds to the option index <INDEX>. For further reference on this subroutine call and how to edit the values of model options, please see the included files wrapper/mmm_wrapper.f90 and wrapper/input.dat.

The following sections provide tables of real and integer switch options, along with their default values, for each of the models in MMM:

Model Options (Real)

Real options are specified by rswitch(K<MODEL>, <INDEX>). Diffusivity bounds are given in units of m2/s.

Model Index Default Description
W20 1 1 E×B shear coefficient
2 1 Convective velocity coefficient
3 0.316 kyρs (ion direction)
4 100 max |xti|
5 100 max |xde|
6 100 max |xte|
7 100 max |xdz|
8 100 max |xvt|
9 100 max |xvp|
DBM 1 1 E×B shear coefficient
2 0.05 kyρs Scan: Lower bound
3 0.30 kyρs Scan: Upper bound
4 25 max |xti|
5 25 max |xde|
6 25 max |xte|
ETGM 1 1 E×B shear coefficient
2 1 kyρs Scan: Lower bound
3 50 kyρs Scan: Upper bound
4 25 max |xte|
MTM 1 0.005 kyρs Scan: Lower bound
2 10 kyρs Scan: Upper bound
3 25 max |xte|

Model Options (Integer)

Integer options are specified by iswitch(K<MODEL>, <INDEX>).

Model Index Default Description
W20 1 0 [Effective shear definition] 0: Use elong, 1: Use gxi
2 0 [Minimum Diffusivity] 0: Zero, 1: Negative of max
DBM 1 20 Number of ky modes (20 minimum), 0: Disable ky scan
2 2 Saturation ratio exponent (0 minimum)
3 1 [Frequency search direction] 0: Any, 1: Electron, -1: Ion
4 0 [Mode handling] 0: Most unstable mode, 1: Sum modes
5 0 [Minimum Diffusivity] 0: Zero, 1: Negative of max
6 0 [Model] 0: Default, 1: Alternate
ETGM 1 50 Number of ky modes (50 minimum), 0: Disable ky scan
2 2 Saturation ratio exponent (0 minimum)
3 0 [Frequency search direction] 0: Any, 1: Electron, -1: Ion
4 0 [Mode handling] 0: Most unstable mode, 1: Sum modes
5 0 [Minimum Diffusivity] 0: Zero, 1: Negative of max
6 2 [Jenko Threshold]
0: Disabled (use original Horton model)
1: Applied to electrostatic
2: Applied to electromagnetic + electrostatic
7 0 [Model] 0: Default, 1: Alternate, 2: Horton
MTM 1 100 Number of ky modes (100 minimum), 0: Disable ky scan
2 0 [Minimum Diffusivity] 0: Zero, 1: Negative of max

Note: The ETGM Jenko Threshold option is only used when the Horton model is selected.

Input Variables

Input Arrays

The majority of input variables for MMM are plasma profiles. All of the one-dimensional arrays listed below are defined on flux surfaces call radial points or zone boundaries, where the transport is to be computed. The number of radial points is given by the input argument npoints. Since MMM has been written as a local code, the size npoints = 1 is allowed.

The following table lists all array input variables:

# Name Symbol Description Units
1 z_rmin $r$ Half-width of the magnetic surface m
2 z_rmaj $R$ Major radius to geometric center of the magnetic surface m
3 z_elong $\kappa$ Local elongation -
4 z_ne $n_{\rm e}$ Thermal electron density m-3
5 z_nh $n_{\rm h}$ Hydrogenic ion density m-3
6 z_nz $n_{\rm z}$ Impurity ion density m-3
7 z_nf $n_{\rm f}$ Fast ion density (non-thermal) m-3
8 z_te $T_{\rm e}$ Thermal electron temperature keV
9 z_ti $T_{\rm i}$ Thermal ion temperature keV
10 z_q $q$ Safety factor -
11 z_bu $B_{\rm u}$ Effective magnetic field T
12 z_btor $B_{\phi}$ Toroidal magnetic field T
13 z_bpol $B_{\theta}$ Poloidal magnetic field T
14 z_dbp $B_{\theta}^{\prime}$ 1st derivative of poloidal magnetic field w.r.t. normalized ρ T
15 z_d2bp $B_{\theta}^{\prime\prime}$ 2nd derivative of poloidal magnetic field w.r.t. normalized ρ T
16 z_zeff $Z_{\rm eff}$ Effective charge -
17 z_zz $Z_{\rm z}$ Mean charge of impurities -
18 z_az $M_{\rm z}$ Mean atomic mass of impurities u
19 z_ah $M_{\rm h}$ Mean atomic mass of hydrogenic ions u
20 z_wexb $\omega_{\rm E\times B}$ E×B shearing rate s-1
21 z_gne $g_{\rm ne}$ Normalized electron density gradient -
22 z_gnh $g_{\rm nh}$ Normalized hydrogenic ion density gradient -
23 z_gnz $g_{\rm nz}$ Normalized impurity density gradient -
24 z_gte $g_{\rm Te}$ Normalized electron temperature gradient -
25 z_gti $g_{\rm Ti}$ Normalized ion temperature gradient -
26 z_gq $g_{\rm q}$ Normalized safety factor gradient -
27 z_gbu $g_{\rm Bu}$ Normalized effective magnetic field gradient -
28 z_vtor $v_{\phi}$ Toroidal velocity m/s
29 z_vpol $v_{\theta}$ Poloidal velocity m/s
30 z_vpar $v_{\parallel}$ Parallel velocity m/s
31 z_gvtor $g_{\rm v\phi}$ Normalized toroidal velocity gradient -
32 z_gvpol $g_{\rm v\theta}$ Normalized poloidal velocity gradient -
33 z_gvpar $g_{\rm v\parallel}$ Normalized parallel velocity gradient -
34 z_gxi $\nabla\hat{\rho}$ Zone boundary gradient m-1
35* z_gelong $\kappa^\prime$ 1st derivative of elongation w.r.t. inverse aspect ratio -
36* z_etanc $\eta_{\rm nc}$ Neoclassical resistivity Ωm

Variables marked with an asterisk (*) are optional inputs.

zgelong is required to run ETGM when the Horton model is selected.
z
etanc is only used in DBM, but is not required to run this model.

Input Scalars

Additionally, there are two single-point (non-array) input variables:

# Name Symbol Description Units
37 z_rmaj0 $R_0$ Major radius of plasma on axis m
38 z_amin $a$ Minor radius of plasma at edge m

Output Variables

Output Channels

MMM calculates transport for six channels, defined by MMM_NCH (see Subroutine Dimensions):

Channel Description
1 Ion Thermal
2 Electron Particle
3 Electron Thermal
4 Impurity Ion Particle
5 Toroidal Momentum
6 Poloidal Momentum

Total Diffusivity

Total diffusivities are returned as individual arrays of dimension (npoints), where each variable corresponds to an output channel:

Name Symbol Units Description
xti $\chi_{\rm i}$ m2/s Ion thermal diffusivity
xde $\chi_{\rm n}$ m2/s Electron particle diffusivity
xte $\chi_{\rm e}$ m2/s Electron thermal diffusivity
xdz $\chi_{\rm z}$ m2/s Impurity ion particle diffusivity
xvt $\chi_{\rm \phi}$ m2/s Toroidal momentum diffusivity
xvp $\chi_{\rm \theta}$ m2/s Poloidal momentum diffusivity

Total Flux

The total flux corresponding to each total diffusivity is an optional output variable, and is returned as the array vflux, with dimensions (MMM_NCH, npoints):

Name Channel Symbol Units Description
vflux 1 $\Gamma_{\rm i}$ keVm/s Ion thermal flux
2 $\Gamma_{\rm n}$ m-2 Electron particle flux
3 $\Gamma_{\rm e}$ keVm/s Electron thermal flux
4 $\Gamma_{\rm z}$ m-2 Impurity ion particle flux
5 $\Gamma_{\rm \phi}$ m2/s2 Toroidal momentum flux
6 $\Gamma_{\rm \theta}$ m2/s2 Poloidal momentum flux

Convective Velocity

Convective velocities and momentum pinches are returned as the array vconv, with dimensions (MMM_NCH, npoints):

Name Channel Symbol Units Description
vconv 1 $V_{\rm i}$ m/s Ion thermal convective velocity
2 $V_{\rm n}$ m/s Electron particle convective velocity
3 $V_{\rm e}$ m/s Electron thermal convective velocity
4 $V_{\rm z}$ m/s Impurity ion particle convective velocity
5 $V_{\rm \phi}$ m/s Toroidal momentum pinch
6 $V_{\rm \theta}$ m/s Poloidal momentum pinch

Note: Convective velocities are only calculated for the two momentum channels.

Error Tracking

Errors are counted using the variable nerr, which can be used to help verify output results. Such errors denote serious issues with the eigenvalue solver and are not expected. Please contact Tariq Rafiq immediately if any errors are encountered.

Output Variables (Components)

Each model in MMM returns its individual diffusivities, real frequencies, and growth rates (when applicable) as optional output variables. In addition, models may also return additional output variables that can be viewed for diagnostic purposes. All output variables listed in this section have dimension (npoints), unless otherwise specified.

W20 Outputs

The Weiland model outputs individual diffusivities corresponding to the first three output channels (see Output Channels). However, since no other models contribute to the diffusivities of the last three output channels, these total diffusivities are also the component diffusivities of the Weiland model.

The growth rate and real frequency of the Weiland model has dimension (2, npoints), as the complex frequency is calculated and returned for both the most unstable ion mode and the most unstable electron mode.

Name Units Description
xtiW20 m2/s Ion thermal diffusivity
xdeW20 m2/s Electron particle diffusivity
xteW20 m2/s Electron thermal diffusivity
gammaW20(1, :) s-1 Growth rate of the most unstable ion mode
gammaW20(2, :) s-1 Growth rate of the most unstable electron mode
omegaW20(1, :) s-1 Real frequency of the most unstable ion mode
omegaW20(2, :) s-1 Real frequency of the most unstable electron mode
kyrhosW20(1, :) - $k_{\rm y}\rho_>g{\rm s}$ for ion modes
kyrhosW20(2, :) - $k_{\rm y}\rho_>g{\rm s}$ for electron modes

DBM Outputs

Name Units Description
xtiDBM m2/s Ion thermal diffusivity
xdeDBM m2/s Electron particle diffusivity
xteDBM m2/s Electron thermal diffusivity
gammaDBM s-1 Growth rate of the most unstable mode
omegaDBM s-1 Real frequency of the most unstable mode
kyrhosDBM - $k_{\rm y}\rho_>g{\rm s}$ of the most unstable mode

ETGM Outputs

Name Units Description
xteETGM m2/s Electron thermal diffusivity
gammaETGM s-1 Growth rate of the most unstable mode
omegaETGM s-1 Real frequency of the most unstable mode
kyrhosETGM - $k_{\rm y}\rho_{\rm s}$ of the most unstable mode

MTM Outputs

Name Units Description
xteMTM m2/s Electron thermal diffusivity
gammaMTM s-1 Growth rate of the most unstable mode
omegaMTM s-1 Real frequency of the most unstable mode
kyrhosMTM - $k_{\rm y}\rho_>g{\rm s}$ of the most unstable mode
dbsqMTM - $|\delta B/B|^2$ profile

MMM Subroutine

The MMM subroutine can be called without any initialization beforehand. However, Model Options may be initialized and edited via the set_mmm_switches subroutine call if needed. Otherwise, MMM will use default model options if the arrays rswitch and iswitch aren't specified.

It is strongly recommended to call MMM using keyword arguments, as the number and order of the arguments is subject to change in future updates. A complete MMM subroutine call with all optional arguments included can be seen in the included script: wrapper/wrapper.f90.