dist_fn_config_type Derived Type

type, public, extends(abstract_config_type) :: dist_fn_config_type

Used to represent the input configuration of dist_fn


Contents

Source Code


Components

Type Visibility Attributes Name Initial
logical, public :: exist = .false.

Does the related namelist exist in the target input file?

integer, public :: index = 0

Used to hold the specific index of numbered namelists

logical, public :: skip_read = .false.

Do we want to skip the read step in init?

logical, public :: skip_broadcast = .false.

Do we want to skip the broadcast step in init?

character(len=30), public :: adiabatic_option = 'default'

The form of the adiabatic response (if a species is being modeled as adiabatic). Ignored if there are electrons in the species list.

  • 'no-field-line-average-term' Adiabatic species has n = Phi. Appropriate for single-species ETG simulations.
  • 'default' Same as 'no-field-line-average-term'
  • 'iphi00=0' Same as 'no-field-line-average-term'
  • 'iphi00=1' Same as 'no-field-line-average-term'
  • 'field-line-average-term' Adiabatic species has n=Phi-< Phi >. Appropriate for single-species ITG simulations.
  • 'iphi00=2' Same as field-line-average-term'
  • 'iphi00=3' Adiabatic species has n=Phi-< Phi >_y. Incorrect implementation of field-line-average-term.

real, public :: afilter = 0.0

For debugging only.

real, public :: apfac = 1.0

Leave as unity. For debugging.

character(len=20), public :: boundary_option = 'default'

Sets the boundary condition along the field line (i.e. the boundary conditions at in flux-tube simulations or in ballooning space). Possible values are:

  • 'default' - "Smart" default -- equivalent to 'zero' except if kt_grids:grid_option='box' in which case equivalent to 'linked'. In simulations with suffifienctly small shear default boundaries correspond to 'periodic'.
  • 'zero', 'unconnected' - Use Kotschenreuther boundary condition at endpoints of theta grid
  • 'self-periodic', 'periodic', 'kperiod=1' - Each mode is periodic in theta with itself.
  • 'linked' - Twist and shift boundary conditions (used for kt_grids:grid_option='box')
  • 'alternate-zero' - Ignored

See also nonad_zero

real, public :: btor_slab = 0.0

Overrides the itor_over_B internal parameter, meant only for slab runs where it sets the angle between the magnetic field and the toroidal flow.

logical, public :: def_parity = .false.

True only allows solutions of single parity as determined by the input even.

real, public :: driftknob = 1.0

Leave as unity for physical runs can be used for debugging. Multiplies the passing particle drifts (also see tpdriftknob).

logical, public :: esv = .false.

If esv=.true. and boundary_option='linked' (i.e. flux tube simulation) then at every time step we ensure the fields are exactly single valued by replacing the field at one of the repeated boundary points with the value at the other boundary (i.e. of the two array locations which should be storing the field at the same point in space we pick one and set the other equal to the one we picked). This can be important in correctly tracking the amplitude of damped modes to very small values. Also see clean_init.

logical, public :: even = .true.

If def_parity is true, determines allowed parity.

real, public :: g_exb = 0.0

where is toroidal angular velocity normalised to the reference frequency and is the normalised flux label which has value on the local surface.

real, public :: g_exb_error_limit = 0.0

With flow shear in single mode, constrains relative error in phi^2.

real, public :: g_exb_start_time = -1

Flow shear switched on when simulation time exceeds this time.

integer, public :: g_exb_start_timestep = -1

Flow shear switched on when simulation timestep exceeds this timestep.

real, public :: g_exbfac = 1.0

Multiplies g_exb in the perpendicular shearing term but not in the parallel drive term. Can be used to construct simulations with purely parallel flow.

logical, public :: gf_lo_integrate = .false.

Perform velocity space integration using gf_lo, rather than g_lo, data decomposition if true. If used without field_option = 'gf_local' in fields_knobs it is likely to give poor performance. If field_option = 'gf_local' in fields_knobs then this needs to be present and set to .true..

real, public :: gridfac = 1.0

Affects boundary condition at end of theta grid. Recommended value: 1. _

logical, public :: hyper_in_initialisation = .true.

Determines if we include the hyperviscosity term during the initialisation of the response matrix or not.

logical, public :: lf_decompose = .false.

Set up lowflow term

logical, public :: lf_default = .true.

Treatment of radial variation of temperature in NEO energy variable:

  • (true, default) take it into account when constructing distribution function, i.e. H(EGS2, r)
  • (false) construct H(ENEO) and deal with it later by including a temp gradient term in wstarfac in dist_fn.fpp
real, public :: mach = 0.0

Number multiplying the coriolis drift.

logical, public :: mult_imp = .false.

Allow different species to have different values of bakdif and fexpr. Not allowed for nonlinear runs.

logical, public :: nonad_zero = .true.

If true switches on "new" parallel boundary condition where h=0 at incoming boundary instead of g=0. This is considered the correct boundary condition but old behaviour retained for experimentation.

real, public :: omprimfac = 1.0

Factor multiplying the parallel shearing drive term when running with non-zero g_exb

logical, public :: opt_source = .false.

If true then use an optimised linear source calculation which uses pre-calculated coefficients, calculates both sigma together and skips work associated with empty fields. Can contribute at least 10-25% savings for linear electrostatic collisionless simulations. For more complicated runs the savings may be less. If enabled memory usage will increase due to using an additional array of size 2-4 times gnew.

real, public :: poisfac = 0.0

If non-zero, quasineutrality is not enforced, poisfac=

logical, public :: start_from_previous_solution = .false.

Determines if we set gnew = 0 (if flag is false) or gnew = g in invert_rhs_1 or not. This is currently considered experimental, but the intention is to change the default to true.

real, public :: tpdriftknob = -9.9e9

For debugging only. Multiplies the trapped particle drifts (also see driftknob).

real, public :: vparknob = 1.0

For debugging only. Scales the calculated vparallel.

real, public :: wfb = 1.0

For debugging only. Sets the boundary value for the barely trapped/passing particle.

character(len=20), public :: wfbbc_option = 'unset'

Deprecated option, moved to le_grids. Setting will lead to an error message and abort. To be removed entirely in future release

logical, public :: zero_forbid = .false.

If true then force gnew=0 in the forbidden region at the end of invert_rhs_1 (this is the original behaviour). Nothing should depend on the forbidden region so g should be 0 here and if it is not for some reason then it shouldn't impact on results. If the results of your simulation depend upon this flag then something has likely gone wrong somewhere.


Type-Bound Procedures

procedure, public, :: is_initialised => is_initialised_generic

procedure, public, :: init => init_generic

  • private subroutine init_generic(self, name, requires_index, index)

    Fully initialise the config object

    Arguments

    Type IntentOptional Attributes Name
    class(abstract_config_type), intent(inout) :: self
    character(len=*), intent(in), optional :: name
    logical, intent(in), optional :: requires_index
    integer, intent(in), optional :: index

procedure, public, :: setup => setup_generic

  • private subroutine setup_generic(self, name, requires_index, index)

    Do some standard setup/checking

    Arguments

    Type IntentOptional Attributes Name
    class(abstract_config_type), intent(inout) :: self
    character(len=*), intent(in), optional :: name
    logical, intent(in), optional :: requires_index
    integer, intent(in), optional :: index

procedure, public, :: write_namelist_header

  • private subroutine write_namelist_header(self, unit)

    Write the namelist header for this instance

    Arguments

    Type IntentOptional Attributes Name
    class(abstract_config_type), intent(in) :: self
    integer, intent(in) :: unit

procedure, public, :: get_name => get_name_generic

  • private function get_name_generic(self)

    Returns the namelist name. Not very useful at the moment but may want to do more interesting things in the future

    Arguments

    Type IntentOptional Attributes Name
    class(abstract_config_type), intent(in) :: self

    Return Value character(len=CONFIG_MAX_NAME_LEN)

procedure, public, :: get_requires_index => get_requires_index_generic

  • private function get_requires_index_generic(self)

    Returns the requires_index value. Allows access whilst keeping the variable private

    Arguments

    Type IntentOptional Attributes Name
    class(abstract_config_type), intent(in) :: self

    Return Value logical

procedure, public, nopass :: write_namelist_footer

  • private subroutine write_namelist_footer(unit)

    Write the namelist footer

    Arguments

    Type IntentOptional Attributes Name
    integer, intent(in) :: unit
  • private subroutine write_key_val_string(key, val, unit)

    Writes a {key,val} pair where the value is of type character

    Arguments

    Type IntentOptional Attributes Name
    character(len=*), intent(in) :: key
    character(len=*), intent(in) :: val
    integer, intent(in) :: unit
  • private subroutine write_key_val_real(key, val, unit)

    Writes a {key,val} pair where the value is of type real

    Arguments

    Type IntentOptional Attributes Name
    character(len=*), intent(in) :: key
    real, intent(in) :: val
    integer, intent(in) :: unit
  • private subroutine write_key_val_complex(key, val, unit)

    Writes a {key,val} pair where the value is of type complex

    Arguments

    Type IntentOptional Attributes Name
    character(len=*), intent(in) :: key
    complex, intent(in) :: val
    integer, intent(in) :: unit
  • private subroutine write_key_val_integer(key, val, unit)

    Writes a {key,val} pair where the value is of type integer

    Arguments

    Type IntentOptional Attributes Name
    character(len=*), intent(in) :: key
    integer, intent(in) :: val
    integer, intent(in) :: unit
  • private subroutine write_key_val_logical(key, val, unit)

    Writes a {key,val} pair where the value is of type logical

    Arguments

    Type IntentOptional Attributes Name
    character(len=*), intent(in) :: key
    logical, intent(in) :: val
    integer, intent(in) :: unit
  • private subroutine write_key_val_real_array(self, key, val, unit)

    Writes a {key,val} pair where the value is of type real array

    Arguments

    Type IntentOptional Attributes Name
    class(abstract_config_type), intent(in) :: self
    character(len=*), intent(in) :: key
    real, intent(in), dimension(:) :: val
    integer, intent(in) :: unit
  • private subroutine write_key_val_complex_array(self, key, val, unit)

    Writes a {key,val} pair where the value is of type complex array

    Arguments

    Type IntentOptional Attributes Name
    class(abstract_config_type), intent(in) :: self
    character(len=*), intent(in) :: key
    complex, intent(in), dimension(:) :: val
    integer, intent(in) :: unit
  • private subroutine write_key_val_integer_array(self, key, val, unit)

    Writes a {key,val} pair where the value is of type integer array

    Arguments

    Type IntentOptional Attributes Name
    class(abstract_config_type), intent(in) :: self
    character(len=*), intent(in) :: key
    integer, intent(in), dimension(:) :: val
    integer, intent(in) :: unit

procedure, public :: read => read_dist_fn_config

  • private subroutine read_dist_fn_config(self)

    Reads in the dist_fn_knobs namelist and populates the member variables

    Arguments

    Type IntentOptional Attributes Name
    class(dist_fn_config_type), intent(inout) :: self

procedure, public :: write => write_dist_fn_config

  • private subroutine write_dist_fn_config(self, unit)

    Writes out a namelist representing the current state of the config object

    Arguments

    Type IntentOptional Attributes Name
    class(dist_fn_config_type), intent(in) :: self
    integer, intent(in), optional :: unit

procedure, public :: reset => reset_dist_fn_config

  • private subroutine reset_dist_fn_config(self)

    Resets the config object to the initial empty state

    Arguments

    Type IntentOptional Attributes Name
    class(dist_fn_config_type), intent(inout) :: self

procedure, public :: broadcast => broadcast_dist_fn_config

  • private subroutine broadcast_dist_fn_config(self)

    Broadcasts all config parameters so object is populated identically on all processors

    Arguments

    Type IntentOptional Attributes Name
    class(dist_fn_config_type), intent(inout) :: self

procedure, public, nopass :: get_default_name => get_default_name_dist_fn_config

  • private function get_default_name_dist_fn_config()

    Gets the default name for this namelist

    Arguments

    None

    Return Value character(len=CONFIG_MAX_NAME_LEN)

procedure, public, nopass :: get_default_requires_index => get_default_requires_index_dist_fn_config

Source Code

  type, extends(abstract_config_type) :: dist_fn_config_type
     ! namelist : dist_fn_knobs
     ! indexed : false
     !> The form of the adiabatic response (if a species is being modeled as adiabatic). Ignored if there are electrons in the species list.
     !>
     !> - 'no-field-line-average-term'  Adiabatic species has n = Phi.  Appropriate for single-species ETG simulations.
     !> - 'default'  Same as 'no-field-line-average-term'
     !> - 'iphi00=0' Same as 'no-field-line-average-term'
     !> - 'iphi00=1' Same as 'no-field-line-average-term'
     !> - 'field-line-average-term'  Adiabatic species has n=Phi-< Phi >.  Appropriate for single-species ITG simulations.
     !> - 'iphi00=2' Same as field-line-average-term'
     !> - 'iphi00=3' Adiabatic species has n=Phi-< Phi >_y.  Incorrect implementation of field-line-average-term.
     !>
     !> @todo Remove 'iphi00=3'
     character(len = 30) :: adiabatic_option = 'default'
     !> For debugging only.
     !>
     !> @todo Improve documentation
     real :: afilter = 0.0
     !> Leave as unity.  For debugging.
     !>
     !> @todo Improve documentation
     real :: apfac = 1.0
     !> Sets the boundary condition along the field line (i.e. the
     !> boundary conditions at \(\theta = \pm \pi\) in flux-tube
     !> simulations or \(\theta = \pm (2*\textrm{nperiod}-1)*\pi\) in
     !> ballooning space). Possible values are:
     !>
     !> - 'default' - "Smart" default -- equivalent to 'zero' except if
     !>                kt_grids:grid_option='box' in which case equivalent to 'linked'.
     !>                In simulations with suffifienctly small shear default boundaries correspond
     !>                to 'periodic'.
     !> - 'zero', 'unconnected' - Use Kotschenreuther boundary condition at endpoints
     !>                           of theta grid
     !> - 'self-periodic', 'periodic', 'kperiod=1' - Each mode is periodic in theta with
     !>                                              itself.
     !> - 'linked' - Twist and shift boundary conditions (used for kt_grids:grid_option='box')
     !> - 'alternate-zero' - Ignored
     !>
     !> See also [[dist_fn_knobs:nonad_zero]]
     character(len = 20) :: boundary_option = 'default'
     !> Overrides the [[theta_grid:itor_over_B]] internal parameter,
     !> meant only for slab runs where it sets the angle between the
     !> magnetic field and the toroidal flow.
     real :: btor_slab = 0.0
     !> True only allows solutions of single parity as determined by
     !> the input [[dist_fn_knobs:even]].
     logical :: def_parity = .false.
     !> Leave as unity for physical runs can be used for
     !> debugging. Multiplies the passing particle drifts (also see
     !> [[dist_fn_knobs:tpdriftknob]]).
     real :: driftknob = 1.0
     !> If `esv=.true.` and `boundary_option='linked'` (i.e. flux tube
     !> simulation) then at every time step we ensure the fields are
     !> exactly single valued by replacing the field at one of the
     !> repeated boundary points with the value at the other boundary
     !> (i.e. of the two array locations which should be storing the
     !> field at the same point in space we pick one and set the other
     !> equal to the one we picked). This can be important in
     !> correctly tracking the amplitude of damped modes to very small
     !> values. Also see [[init_g_knobs:clean_init]].
     logical :: esv = .false.
     !> If `def_parity` is true, determines allowed parity.
     logical :: even = .true.
     !> \(\frac{\rho}{q} \frac{d\Omega^{\rm GS2}}{d\rho_n}\) where
     !> \(\Omega^{\rm GS2}\) is toroidal angular velocity normalised
     !> to the reference frequency \(v_{t}^{\rm ref}/a\) and
     !> \(\rho_n\) is the normalised flux label which has value
     !> \(\rho\) on the local surface.
     real :: g_exb = 0.0
     !> With flow shear in single mode, constrains relative error in `phi^2`.
     !>
     !> @todo Add more documentation
     real :: g_exb_error_limit = 0.0
     !> Flow shear switched on when simulation time exceeds this time.
     real :: g_exb_start_time = -1
     !> Flow shear switched on when simulation timestep exceeds this timestep.
     integer :: g_exb_start_timestep = -1
     !> Multiplies `g_exb` in the perpendicular shearing term *but
     !> not* in the parallel drive term. Can be used to construct simulations with
     !> purely parallel flow.
     real :: g_exbfac = 1.0
     !> Perform velocity space integration using `gf_lo`, rather than
     !> `g_lo`, data decomposition if true.  If used without
     !> `field_option = 'gf_local'` in [[fields_knobs]] it is likely to give
     !> poor performance. If `field_option = 'gf_local'` in
     !> [[fields_knobs]] then this needs to be present and set to `.true.`.
     !>
     !> @todo Consider if this should be a field input.
     logical :: gf_lo_integrate = .false.
     !> Affects boundary condition at end of theta grid.   Recommended value: 1.
     !>_
     !> @note This used to default to 5.e4
     !> @todo Improve documentation
     real :: gridfac = 1.0
     !> Determines if we include the hyperviscosity term during the
     !> initialisation of the response matrix or not.
     logical :: hyper_in_initialisation = .true.
     !> Set up lowflow term \(F_1/F_0 = xi*(v/v_{th})*(a + b*(v/v_{th})^2)\)
     logical :: lf_decompose = .false.
     !> Treatment of radial variation of temperature in NEO energy variable:
     !>
     !> - (true, default) take it into account when constructing distribution
     !>   function, i.e. `H(EGS2, r)`
     !> - (false) construct `H(ENEO)` and deal with it later by including a temp
     !>   gradient term in `wstarfac` in [[dist_fn.fpp]]
     logical :: lf_default = .true.
     !> Number multiplying the coriolis drift.
     !>
     !> @todo Expand documentation
     real :: mach = 0.0
     !> Allow different species to have different values of `bakdif` and
     !> `fexpr`.  Not allowed for nonlinear runs.
     !>
     !> @note The restriction to `.false.` for nonlinear runs isn't actually enforced.
     logical :: mult_imp = .false.
     !> If true switches on "new" parallel boundary condition where h=0 at incoming boundary instead of g=0.
     !> This is considered the correct boundary condition but old behaviour retained for experimentation.
     logical :: nonad_zero = .true.
     !> Factor multiplying the parallel shearing drive term when
     !> running with non-zero [[dist_fn_knobs:g_exb]]
     real :: omprimfac = 1.0
     !>  If true then use an optimised linear source calculation which
     !>  uses pre-calculated coefficients, calculates both sigma
     !>  together and skips work associated with empty fields. Can
     !>  contribute at least 10-25% savings for linear electrostatic
     !>  collisionless simulations. For more complicated runs the
     !>  savings may be less. If enabled memory usage will
     !>  increase due to using an additional array of size 2-4 times
     !>  `gnew`.
     logical :: opt_source = .false.
     !> If non-zero, quasineutrality is not enforced,
     !> `poisfac`=  \((\lambda_\textrm{Debye}/\rho)^2\)
     real :: poisfac = 0.0
     !> Determines if we set gnew = 0 (if flag is false) or gnew = g
     !> in [[invert_rhs_1]] or not. This is currently considered
     !> experimental, but the intention is to change the default to true.
     logical :: start_from_previous_solution = .false.
     !> For debugging only. Multiplies the trapped particle drifts
     !> (also see [[dist_fn_knobs:driftknob]]).
     real :: tpdriftknob = -9.9e9
     !> For debugging only. Scales the calculated vparallel.
     !>
     !> @note If set to zero then the homogeneous contribution, `g1`, will be
     !> exactly 1 everywhere it is defined. This can lead to a divide by zero
     !> in the trapped particle continuity calculation in [[invert_rhs_1]],
     !> leading to NaNs appearing in the solution.
     real :: vparknob = 1.0
     !> For debugging only. Sets the boundary value for the barely trapped/passing particle.
     real :: wfb = 1.0
     !> Deprecated option, moved to [[le_grids]]. Setting
     !> will lead to an error message and abort. To be removed
     !> entirely in future release
     character(len = 20) :: wfbbc_option = 'unset'
     !> If true then force `gnew=0` in the forbidden region at the end
     !> of [[invert_rhs_1]] (this is the original behaviour).
     !> Nothing should depend on the forbidden region so `g` should be 0 here
     !> and if it is not for some reason then it shouldn't impact on
     !> results. If the results of your simulation depend upon this
     !> flag then something has likely gone wrong somewhere.
     logical :: zero_forbid = .false.
   contains
     procedure, public :: read => read_dist_fn_config
     procedure, public :: write => write_dist_fn_config
     procedure, public :: reset => reset_dist_fn_config
     procedure, public :: broadcast => broadcast_dist_fn_config
     procedure, public, nopass :: get_default_name => get_default_name_dist_fn_config
     procedure, public, nopass :: get_default_requires_index => get_default_requires_index_dist_fn_config
  end type dist_fn_config_type