le_grids Module

FIXME : Add documentation



Contents


Variables

Type Visibility Attributes Name Initial
real, private, dimension (:), allocatable :: xx
real, private, dimension (:,:), allocatable :: wlerr
real, private, dimension (:,:,:), allocatable :: werr
real, private, dimension (:,:,:), allocatable :: wlterr
real, private, dimension (:,:,:), allocatable :: wlmod
real, private, dimension (:,:,:), allocatable :: wtmod
real, private, dimension (:,:,:), allocatable :: wmod
real, private, dimension (:,:,:), allocatable :: lpe
real, private, dimension (:,:), allocatable, save :: lpl
real, private, dimension (:,:,:,:), allocatable, save :: lpt
real, public, dimension (:), allocatable :: energy_maxw
real, public, dimension (:), allocatable :: w_maxw
real, public, dimension (:), allocatable :: speed_maxw
real, public, dimension (:,:), allocatable :: energy
real, public, dimension (:,:), allocatable :: w
real, public, dimension (:,:), allocatable :: speed
real, public, dimension (:), allocatable :: al
real, public, dimension (:,:), allocatable :: wl
real, public, dimension (:,:), allocatable :: wxi
integer, public, dimension (:), allocatable :: jend
logical, public, dimension (:,:), allocatable :: forbid
logical, public, dimension (:,:), allocatable :: is_ttp
logical, public, dimension (:,:), allocatable :: is_bounce_point
logical, public, dimension (:), allocatable :: can_be_ttp
real, public, dimension (:,:), allocatable :: xi
integer, public, dimension (:,:), allocatable :: ixi_to_il
integer, public, dimension (:,:), allocatable :: ixi_to_isgn
integer, public, dimension (2) :: sgn
integer, public :: wdim
complex, private, dimension (:,:), allocatable :: integration_work
logical, private :: exist
integer, private :: ngauss
integer, private :: npassing
integer, public :: negrid
integer, private :: nesuper
integer, public :: nesub
real, private :: bouncefuzz
real, public :: vcut
logical, private :: genquad
integer, public :: nlambda
integer, public :: ng2
integer, public :: lmax
integer, public :: nxi
logical, private :: test = .false.
logical, private :: trapped_particles = .true.
logical, public :: new_trap_int = .false.
logical, private :: new_trap_int_split = .false.
logical, private :: radau_gauss_grid = .true.
logical, private :: split_passing_region = .false.
logical, private :: slintinit = .false.
logical, private :: lintinit = .false.
logical, private :: eintinit = .false.
logical, private :: initialized = .false.
logical, private :: leinit = .false.
logical, private :: gfinit = .false.
logical, private :: lzinit = .false.
logical, private :: einit = .false.
logical, private :: init_weights_init = .false.
logical, public :: trapped_wfb
logical, public :: passing_wfb
logical, public :: mixed_wfb
integer, private :: wfbbc_option_switch
integer, private, parameter :: wfbbc_option_mixed = 1
integer, private, parameter :: wfbbc_option_passing = 2
integer, private, parameter :: wfbbc_option_trapped = 3
integer, private :: nmax = 500
real, private :: wgt_fac = 10.0
type(redist_type), public, save :: lambda_map
type(redist_type), public, save :: energy_map
type(redist_type), public, save :: g2le
type(redist_type), public, save :: g2gf
integer, private, dimension(:), allocatable :: recvcnts_intspec
integer, private, dimension(:), allocatable :: displs_intspec
integer, private :: sz_intspec
integer, private :: local_rank_intspec
type(le_grids_config_type), private :: le_grids_config

Interfaces

public interface integrate_moment

  • private subroutine integrate_moment_c34(g, total, all, full_arr)

    FIXME : Add documentation

    returns results to PE 0 [or to all processors if 'all' is present in input arg list] NOTE: Takes f = f(x, y, z, sigma, lambda, E, species) and returns int f, where the integral is over all velocity space

    Arguments

    Type IntentOptional Attributes Name
    complex, intent(in), dimension (-ntgrid:,:,g_lo%llim_proc:) :: g
    complex, intent(out), dimension (-ntgrid:,:,:,:) :: total
    logical, intent(in), optional :: all
    logical, intent(in), optional :: full_arr
  • private subroutine integrate_moment_r34(g, total, all, full_arr)

    Takes f = f(theta, sigma ; x, y, z, lambda, E, species) and returns int f, where the integral is over all velocity space returns results to PE 0 [or to all processors if 'all' is present in input arg list]

    Arguments

    Type IntentOptional Attributes Name
    real, intent(in), dimension (-ntgrid:,:,g_lo%llim_proc:) :: g
    real, intent(out), dimension (-ntgrid:,:,:,:) :: total
    logical, intent(in), optional :: all
    logical, intent(in), optional :: full_arr
  • private subroutine integrate_moment_lec(lo, g, total)

    Perform an integral over velocity space whilst in the LE_LAYOUT in which we have ensured that all of velocity space is local. As such we don't need any calls to MPI reduction routines. Note that this means the processors for different distributed spatial points (x,y) don't know the results at other points.

    Arguments

    Type IntentOptional Attributes Name
    type(le_layout_type), intent(in) :: lo
    complex, intent(in), dimension (:,:,lo%llim_proc:) :: g
    complex, intent(out), dimension (lo%llim_proc:) :: total
  • private subroutine integrate_moment_r33(g, total, all)

    FIXME : Add documentation

    returns results to PE 0 [or to all processors if 'all' is present in input arg list] NOTE: Takes f = f(y, z, sigma, lambda, E, species) and returns int f, where the integral is over all velocity space

    Arguments

    Type IntentOptional Attributes Name
    real, intent(in), dimension (-ntgrid:,:,p_lo%llim_proc:) :: g
    real, intent(out), dimension (-ntgrid:,:,:) :: total
    integer, intent(in), optional :: all

public interface integrate_species

  • private subroutine integrate_species_master(g, weights, total, nogath, gf_lo)

    Integrate_species on subcommunicator with gather Falls back to original method if not using xyblock sub comm

    Arguments

    Type IntentOptional Attributes Name
    complex, intent(in), dimension (-ntgrid:,:,g_lo%llim_proc:) :: g
    real, intent(inout), dimension (:) :: weights
    complex, intent(out), dimension (0:,:,:) :: total
    logical, intent(in), optional :: nogath
    logical, intent(in), optional :: gf_lo
  • private subroutine integrate_species_gf_nogather(gf, weights, total)

    Integrate species using gf_lo data format assuming that gf has already been gathered prior to being passed to this routine. Currently this routine isn't being used as the functionality has been directly added to getan_nogath in dist_fn.

    AJ

    Arguments

    Type IntentOptional Attributes Name
    complex, intent(in), dimension(-ntgrid:ntgrid,2,nspec,negrid,nlambda,gf_lo%llim_proc:gf_lo%ulim_alloc) :: gf
    real, intent(inout), dimension (:) :: weights
    complex, intent(out), dimension (-ntgrid:ntgrid,gf_lo%ntheta0,gf_lo%naky) :: total

public interface integrate_volume

  • private subroutine integrate_volume_c(g, total, all)

    FIXME : Add documentation

    returns results to PE 0 [or to all processors if 'all' is present in input arg list] NOTE: Takes f = f(x, y, z, sigma, lambda, E, species) and returns int f, where the integral is over x-y space

    Arguments

    Type IntentOptional Attributes Name
    complex, intent(in), dimension (-ntgrid:,:,g_lo%llim_proc:) :: g
    complex, intent(out), dimension (-ntgrid:,:,:,:,:) :: total
    integer, intent(in), optional :: all
  • private subroutine integrate_volume_r(g, total, all)

    FIXME : Add documentation

    returns results to PE 0 [or to all processors if 'all' is present in input arg list] NOTE: Takes f = f(x, y, z, sigma, lambda, E, species) and returns int f, where the integral is over x-y space

    Arguments

    Type IntentOptional Attributes Name
    real, intent(in), dimension (-ntgrid:,:,g_lo%llim_proc:) :: g
    real, intent(out), dimension (-ntgrid:,:,:,:,:) :: total
    integer, intent(in), optional :: all

private interface get_hermite_polynomials

  • private subroutine get_hermite_polynomials_1d(xptsdum, hpdum)

    Returns Gn = Hn / sqrt(2^n n!) / pi^(1/4), where Hn are the hermite polynomials i.e. int dx Gm * Gn exp(-x^2) = 1

    Arguments

    Type IntentOptional Attributes Name
    real, intent(in), dimension (:) :: xptsdum
    real, intent(out), dimension (:,0:) :: hpdum
  • private subroutine get_hermite_polynomials_4d(xptsdum, hpdum)

    Returns Gn = Hn / sqrt(2^n n!) / pi^(1/4), where Hn are the hermite polynomials i.e. int dx Gm * Gn exp(-x^2) = 1

    Arguments

    Type IntentOptional Attributes Name
    real, intent(in), dimension (-ntgrid:,:,:,:) :: xptsdum
    real, intent(out), dimension (-ntgrid:,:,:,:,0:) :: hpdum

Derived Types

type, public, extends(abstract_config_type) ::  le_grids_config_type

Used to represent the input configuration of le_grids

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?

real, public :: bouncefuzz = 10*epsilon(0.0)

Acts as a small tolerance in deciding if a particular pitch angle is forbidden at a particular theta grid point. Rather than considering particles to be forbidden if 1.0 - lambda * B(theta) < 0 we treat them as forbidden if 1.0 - lambda * B(theta) < -bouncefuzz. This provides a small "buffer" to account for floating round off in the calculation of lambda and B.

logical, public :: genquad = .false.

If true use generalised quadrature scheme for velocity integrals and energy grid. See G. Wilkie thesis.

integer, public :: negrid = -10

Sets the number of energy grid points to use. If specified then overrides values of nesuper = min(negrid/10 + 1, 4) and nesub = negrid - nesuper. If not set then the total number of energy grid points is just negrid = nesub + nesuper. The energy grid is split into two regions at a point controlled by vcut.

integer, public :: nesub = 8

Sets the number of energy grid points below the cutoff.

integer, public :: nesuper = 2

Sets the number of energy grid points above the cutoff.

logical, public :: new_trap_int = .false.

If true then use a more accurate integration method for the trapped pitch angle contribution to velocity integrals. The default uses a simple, but potentially less accurate, finite difference method.

logical, public :: new_trap_int_split = .false.

If true then split the trapped region into two symmetric regions when calculating the integration weights associated with the new_trap_int approach.

integer, public :: npassing = -1

The number of untrapped pitch-angles moving in one direction along field line.

integer, public :: ngauss = 5

The number of untrapped pitch-angles moving in one direction along field line is 2*ngauss if npassing is not set. Note that the number of trapped pitch angles is directly related to the number of theta grid points (per ) and is ntheta/2 + 1.

integer, public :: nmax = 500

Influences the minimum number of grid points in an integration subinterval used in calculating the integration grid weights.

logical, public :: radau_gauss_grid = .true.

The default lambda grid is now gauss-radau, for passing particles up to and including the passing-trapped boundary (wfb). The grid gives finite weight to the class of particles which bounce at theta = +/- pi (wfb) in the passing integral Note that the old gauss-legendre is used in the case that trapped_particles =.false.

Read more…
logical, public :: split_passing_region = .false.

If true then we split the passing region into two separate regions for the purpose of choosing the integration weights. The split point is determined automatically by an attempt to minimise the passing weights error.

logical, public :: test = .false.

If true then just does a few tests and writes pitch angle and energy grids to screen before aborting the simulation.

logical, public :: trapped_particles = .true.

If set to false then the lambda grid weighting wl is set to zero for trapped pitch angles. This means that integrals over velocity space do not include a contribution from trapped particles which is equivalent to the situation where eps<=0.0. Trapped particle drifts are not set to zero so "trapped" particles still enter the source term through wdfac. At least for s-alpha the drifts are the main difference (please correct if not true) between the eps<=0.0 and the trapped_particles = .false. cases as Bmag is not a function of theta in the eps<=0.0 case whilst it is in the trapped_particles = .false. case.

real, public :: vcut = 2.5

No. of standard deviations from the standard Maxwellian beyond which the distribution function will be set to 0.

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

Set boundary condition for WFB in the linear/parallel solve:

Read more…
real, public :: wgt_fac = 10.0

Influences the maximum integration weight allowed.

Type-Bound Procedures

procedure , public , :: is_initialised => is_initialised_generic Function
procedure , public , :: init => init_generic Subroutine
procedure , public , :: setup => setup_generic Subroutine
procedure , public , :: write_namelist_header Subroutine
procedure , public , :: get_name => get_name_generic Function
procedure , public , :: get_requires_index => get_requires_index_generic Function
procedure , public , nopass :: write_namelist_footer Subroutine
generic, public , :: write_key_val => write_key_val_string, write_key_val_real, write_key_val_complex, write_key_val_integer, write_key_val_logical, write_key_val_real_array, write_key_val_complex_array, write_key_val_integer_array
procedure , public :: read => read_le_grids_config Subroutine
procedure , public :: write => write_le_grids_config Subroutine
procedure , public :: reset => reset_le_grids_config Subroutine
procedure , public :: broadcast => broadcast_le_grids_config Subroutine
procedure , public , nopass :: get_default_name => get_default_name_le_grids_config Function
procedure , public , nopass :: get_default_requires_index => get_default_requires_index_le_grids_config Function

Functions

public pure function grid_has_trapped_particles() result(has_trapped)

Returns true if there are trapped particles on the current pitch angle grid.

Arguments

None

Return Value logical

public elemental function il_is_trapped(il) result(is_trapped)

Returns true if the passed pitch angle grid point is considered trapped.

Arguments

Type IntentOptional Attributes Name
integer, intent(in) :: il

Return Value logical

public elemental function il_is_passing(il) result(is_passing)

Returns true if the passed pitch angle grid point is considered passing.

Arguments

Type IntentOptional Attributes Name
integer, intent(in) :: il

Return Value logical

public elemental function il_is_wfb(il) result(is_wfb)

Returns true if the passed pitch angle grid point is considered the wfb.

Arguments

Type IntentOptional Attributes Name
integer, intent(in) :: il

Return Value logical

public elemental function is_lower_bounce_point(ig, il) result(is_lower)

Returns true if the passed theta grid index, ig, is a lower bounce point for the passed pitch angle index, il.

Arguments

Type IntentOptional Attributes Name
integer, intent(in) :: ig
integer, intent(in) :: il

Return Value logical

public elemental function is_upper_bounce_point(ig, il) result(is_upper)

Returns true if the passed theta grid index, ig, is a upper bounce point for the passed pitch angle index, il.

Arguments

Type IntentOptional Attributes Name
integer, intent(in) :: ig
integer, intent(in) :: il

Return Value logical

public elemental function hermite_prob(n, x)

Returns probabilist's Hermite polynomials, He_n(x)

Arguments

Type IntentOptional Attributes Name
integer, intent(in) :: n
real, intent(in) :: x

Return Value double precision

public pure function is_passing_hybrid_electron(is, ik, il)

Determine if the passed species, ky and lambda indicies correspond to a passing hybrid electron point which should be skipped.

Arguments

Type IntentOptional Attributes Name
integer, intent(in) :: is
integer, intent(in) :: ik
integer, intent(in) :: il

Return Value logical

public function get_le_grids_config()

Get the module level config instance

Arguments

None

Return Value type(le_grids_config_type)

Gets the default name for this namelist

Arguments

None

Return Value character(len=CONFIG_MAX_NAME_LEN)

Gets the default requires index for this namelist

Arguments

None

Return Value logical


Subroutines

public subroutine wnml_le_grids(unit)

FIXME : Add documentation

Arguments

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

public subroutine init_le_grids(le_grid_config_in)

FIXME : Add documentation

Arguments

Type IntentOptional Attributes Name
type(le_grids_config_type), intent(in), optional :: le_grid_config_in

private subroutine set_vgrid()

FIXME : Add documentation

Arguments

None

private subroutine broadcast_results()

FIXME : Add documentation

Arguments

None

private subroutine read_parameters(le_grid_config_in)

FIXME : Add documentation

Arguments

Type IntentOptional Attributes Name
type(le_grids_config_type), intent(in), optional :: le_grid_config_in

private subroutine init_integrations()

FIXME : Add documentation

Arguments

None

public subroutine init_weights()

Calculates energy grid and (untrapped) pitch angle weights for integrals which drop a point from the energy/lambda dimensions. These are only used for estimating the velocity space error in [[dist_fn::get_verr]] as a part of the adaptive collisionality algorithm.

Arguments

None

private subroutine get_weights(maxpts_in, llim, ulim, nodes, wgts, ndiv, divmax, err_flag)

The get_weights subroutine determines how to divide up the integral into subintervals and how many grid points should be in each subinterval

Arguments

Type IntentOptional Attributes Name
integer, intent(in) :: maxpts_in
real, intent(in) :: llim
real, intent(in) :: ulim
real, intent(in), dimension (:) :: nodes
real, intent(out), dimension (:) :: wgts
integer, intent(out) :: ndiv
integer, intent(out) :: divmax
logical, intent(out) :: err_flag

private subroutine get_intrvl_weights(llim, ulim, nodes, wgts)

Used by get_weights to find the Lagrange quadrature weights for the given grid.

Read more…

Arguments

Type IntentOptional Attributes Name
real, intent(in) :: llim
real, intent(in) :: ulim
real, intent(in), dimension (:) :: nodes
real, intent(inout), dimension (:) :: wgts

private subroutine integrate_species_original(g, weights, total)

FIXME : Add documentation

Arguments

Type IntentOptional Attributes Name
complex, intent(in), dimension (-ntgrid:,:,g_lo%llim_proc:) :: g
real, intent(inout), dimension (:) :: weights
complex, intent(out), dimension (-ntgrid:,:,:) :: total

private subroutine integrate_species_sub(g, weights, total)

Integrate species on xy subcommunicator - NO GATHER

Arguments

Type IntentOptional Attributes Name
complex, intent(in), dimension (-ntgrid:,:,g_lo%llim_proc:) :: g
real, intent(inout), dimension (:) :: weights
complex, intent(out), dimension (-ntgrid:,:,:) :: total

private subroutine integrate_species_gf(g, weights, total)

Integrate species using gf_lo data format

Arguments

Type IntentOptional Attributes Name
complex, intent(in), dimension (-ntgrid:,:,g_lo%llim_proc:) :: g
real, intent(inout), dimension (:) :: weights
complex, intent(out), dimension (-ntgrid:ntgrid,gf_lo%ntheta0,gf_lo%naky) :: total

private subroutine integrate_species_gf_nogather(gf, weights, total)

Integrate species using gf_lo data format assuming that gf has already been gathered prior to being passed to this routine. Currently this routine isn't being used as the functionality has been directly added to getan_nogath in dist_fn.

Read more…

Arguments

Type IntentOptional Attributes Name
complex, intent(in), dimension(-ntgrid:ntgrid,2,nspec,negrid,nlambda,gf_lo%llim_proc:gf_lo%ulim_alloc) :: gf
real, intent(inout), dimension (:) :: weights
complex, intent(out), dimension (-ntgrid:ntgrid,gf_lo%ntheta0,gf_lo%naky) :: total

private subroutine integrate_species_master(g, weights, total, nogath, gf_lo)

Integrate_species on subcommunicator with gather Falls back to original method if not using xyblock sub comm

Arguments

Type IntentOptional Attributes Name
complex, intent(in), dimension (-ntgrid:,:,g_lo%llim_proc:) :: g
real, intent(inout), dimension (:) :: weights
complex, intent(out), dimension (0:,:,:) :: total
logical, intent(in), optional :: nogath
logical, intent(in), optional :: gf_lo

public subroutine legendre_transform(g, tote, totl, tott)

FIXME : Add documentation

Read more…

Arguments

Type IntentOptional Attributes Name
complex, intent(in), dimension (-ntgrid:,:,g_lo%llim_proc:) :: g
complex, intent(out), dimension (0:,-ntgrid:,:,:,:) :: tote
complex, intent(out), dimension (0:,-ntgrid:,:,:,:) :: totl
complex, intent(out), optional, dimension (0:,-ntgrid:,:,:,:) :: tott

private subroutine legendre_polynomials(llim, ulim, xptsdum, lpdum)

FIXME : Add documentation

Arguments

Type IntentOptional Attributes Name
real, intent(in) :: llim
real, intent(in) :: ulim
real, intent(in), dimension (:) :: xptsdum
real, intent(out), dimension (:,0:) :: lpdum

private subroutine integrate_moment_c34(g, total, all, full_arr)

FIXME : Add documentation

Read more…

Arguments

Type IntentOptional Attributes Name
complex, intent(in), dimension (-ntgrid:,:,g_lo%llim_proc:) :: g
complex, intent(out), dimension (-ntgrid:,:,:,:) :: total
logical, intent(in), optional :: all
logical, intent(in), optional :: full_arr

private subroutine integrate_moment_r34(g, total, all, full_arr)

Takes f = f(theta, sigma ; x, y, z, lambda, E, species) and returns int f, where the integral is over all velocity space returns results to PE 0 [or to all processors if 'all' is present in input arg list]

Arguments

Type IntentOptional Attributes Name
real, intent(in), dimension (-ntgrid:,:,g_lo%llim_proc:) :: g
real, intent(out), dimension (-ntgrid:,:,:,:) :: total
logical, intent(in), optional :: all
logical, intent(in), optional :: full_arr

private subroutine integrate_moment_r33(g, total, all)

FIXME : Add documentation

Read more…

Arguments

Type IntentOptional Attributes Name
real, intent(in), dimension (-ntgrid:,:,p_lo%llim_proc:) :: g
real, intent(out), dimension (-ntgrid:,:,:) :: total
integer, intent(in), optional :: all

private subroutine integrate_moment_lec(lo, g, total)

Perform an integral over velocity space whilst in the LE_LAYOUT in which we have ensured that all of velocity space is local. As such we don't need any calls to MPI reduction routines. Note that this means the processors for different distributed spatial points (x,y) don't know the results at other points.

Arguments

Type IntentOptional Attributes Name
type(le_layout_type), intent(in) :: lo
complex, intent(in), dimension (:,:,lo%llim_proc:) :: g
complex, intent(out), dimension (lo%llim_proc:) :: total

public subroutine integrate_kysum(g, ig, total, all)

FIXME : Add documentation

Read more…

Arguments

Type IntentOptional Attributes Name
complex, intent(in), dimension (p_lo%llim_proc:) :: g
integer, intent(in) :: ig
complex, intent(out), dimension (:) :: total
integer, intent(in), optional :: all

public subroutine lint_error(g, weights, total)

FIXME : Add documentation

Arguments

Type IntentOptional Attributes Name
complex, intent(in), dimension (-ntgrid:,:,g_lo%llim_proc:) :: g
real, intent(in), dimension (:) :: weights
complex, intent(out), dimension (-ntgrid:,:,:,:) :: total

public subroutine trap_error(g, weights, total)

FIXME : Add documentation

Arguments

Type IntentOptional Attributes Name
complex, intent(in), dimension (-ntgrid:,:,g_lo%llim_proc:) :: g
real, intent(in), dimension (:) :: weights
complex, intent(out), dimension (-ntgrid:,:,:,:) :: total

public subroutine eint_error(g, weights, total)

FIXME : Add documentation

Arguments

Type IntentOptional Attributes Name
complex, intent(in), dimension (-ntgrid:,:,g_lo%llim_proc:) :: g
real, intent(in), dimension (:) :: weights
complex, intent(out), dimension (-ntgrid:,:,:,:) :: total

private subroutine set_grids()

FIXME : Add documentation

Arguments

None

private subroutine report_velocity_integration_error_estimate(unit_in)

Calculate estimates of the velocity space integration errors and report to screen / specified unit.

Read more…

Arguments

Type IntentOptional Attributes Name
integer, intent(in), optional :: unit_in

private subroutine lgridset()

Sets up the pitch angle grid and associated data. Does so by calling other routines. A summary of the actions is below.

Read more…

Arguments

None

public subroutine setup_passing_lambda_grids(lambda_grid, weights)

Determines the location of lambda (al) grid points in the passing domain and the associated integrations weights.

Arguments

Type IntentOptional Attributes Name
real, intent(inout), dimension(:) :: lambda_grid

The lambda grid points. Note this is intent in out as we only set a portion of the grid so may want to keep the rest of the input values.

real, intent(inout), dimension(-ntgrid:, :) :: weights

The integration weights for the lambda grid. This is intent in out for the same reason as lambda_grid.

private subroutine try_to_optimise_passing_grid(optimal_split, optimal_points, use_max_error, noptimal_points)

Try to find the optimal way to split the passing lambda grid into two regions in order to minimise the error on the integration weights. The approach taken is trial and error -- we try a number of predetermined splits, spline the error over the trials and then evaluate the spline on a high resolution grid to determine an approximate minmium.

Arguments

Type IntentOptional Attributes Name
real, intent(out) :: optimal_split
integer, intent(out) :: optimal_points
logical, intent(in), optional :: use_max_error
integer, intent(in), optional :: noptimal_points

private subroutine setup_trapped_lambda_grids(lambda_grid, weights)

Determines the lambda grid point integration weights in the trapped domain using either new or old (default) methods, determined by [[le_grids_knobs::new_trap_int]] with new=high-order interp, old=finite difference).

Read more…

Arguments

Type IntentOptional Attributes Name
real, intent(in), dimension(:) :: lambda_grid

The lambda grid points.

real, intent(inout), dimension(-ntgrid:, :) :: weights

The integration weights for the lambda grid. Note this is intent in out as we only set a portion of the grid so may want to keep the rest of the input values.

private subroutine setup_trapped_lambda_grids_new_trap_int(lambda_grid, weights)

Determine trapped pitch angle weights using "new" polynomial interpolation.

Read more…

Arguments

Type IntentOptional Attributes Name
real, intent(in), dimension(:) :: lambda_grid

The lambda grid points.

real, intent(inout), dimension(-ntgrid:, :) :: weights

The integration weights for the lambda grid. Note this is intent in out as we only set a portion of the grid so may want to keep the rest of the input values.

public subroutine setup_trapped_lambda_grids_old_finite_difference(lambda_grid, weights)

Find the trapped pitch angle weights using an old (finite-difference) integration scheme

Read more…

Arguments

Type IntentOptional Attributes Name
real, intent(in), dimension(:) :: lambda_grid

The lambda grid points.

real, intent(inout), dimension(-ntgrid:, :) :: weights

The integration weights for the lambda grid. Note this is intent in out as we only set a portion of the grid so may want to keep the rest of the input values.

private subroutine get_trapped_lambda_grid_error_estimate_weights(yb, llim, ulim, npts, wberr)

Routine for getting the weights used in estimating the error on trapped particle integrals as a part of trap_error

Read more…

Arguments

Type IntentOptional Attributes Name
real, intent(in), dimension(:) :: yb
real, intent(in) :: llim
real, intent(in) :: ulim
integer, intent(in) :: npts
real, intent(inout), dimension(:, :) :: wberr

private subroutine calculate_forbidden_region(forbid)

Determine which lambda grid points are forbidden at each theta/bmag value.

Arguments

Type IntentOptional Attributes Name
logical, intent(out), dimension(-ntgrid:, :) :: forbid

private subroutine calculate_bounce_points(bounce_points)

Determine which theta grid points correspond to bounce points for each pitch angle.

Read more…

Arguments

Type IntentOptional Attributes Name
logical, intent(out), dimension(-ntgrid:, :) :: bounce_points

private subroutine calculate_jend(jend)

Determine which lambda grid point bounces at this theta/bmag value.

Arguments

Type IntentOptional Attributes Name
integer, intent(out), dimension(-ntgrid:) :: jend

private subroutine calculate_ittp(can_be_ttp_flag, is_ttp_value)

Determine which lambda grid point is totally trapped at this theta grid point.

Arguments

Type IntentOptional Attributes Name
logical, intent(out), dimension(nlambda) :: can_be_ttp_flag
logical, intent(out), dimension(-ntgrid:ntgrid, nlambda) :: is_ttp_value

private subroutine xigridset()

FIXME : Add documentation

Arguments

None

private subroutine integrate_volume_c(g, total, all)

FIXME : Add documentation

Read more…

Arguments

Type IntentOptional Attributes Name
complex, intent(in), dimension (-ntgrid:,:,g_lo%llim_proc:) :: g
complex, intent(out), dimension (-ntgrid:,:,:,:,:) :: total
integer, intent(in), optional :: all

private subroutine integrate_volume_r(g, total, all)

FIXME : Add documentation

Read more…

Arguments

Type IntentOptional Attributes Name
real, intent(in), dimension (-ntgrid:,:,g_lo%llim_proc:) :: g
real, intent(out), dimension (-ntgrid:,:,:,:,:) :: total
integer, intent(in), optional :: all

public subroutine get_flux_vs_theta_vs_vpa(f, vflx, dealloc)

Calculates and returns toroidal momentum flux as a function of vpar and theta

Arguments

Type IntentOptional Attributes Name
real, intent(in), dimension (-ntgrid:,:,:,:,:) :: f
real, intent(out), dimension (-ntgrid:,:,:) :: vflx
logical, intent(in), optional :: dealloc

private subroutine get_hermite_polynomials_4d(xptsdum, hpdum)

Returns Gn = Hn / sqrt(2^n n!) / pi^(1/4), where Hn are the hermite polynomials i.e. int dx Gm * Gn exp(-x^2) = 1

Arguments

Type IntentOptional Attributes Name
real, intent(in), dimension (-ntgrid:,:,:,:) :: xptsdum
real, intent(out), dimension (-ntgrid:,:,:,:,0:) :: hpdum

private subroutine get_hermite_polynomials_1d(xptsdum, hpdum)

Returns Gn = Hn / sqrt(2^n n!) / pi^(1/4), where Hn are the hermite polynomials i.e. int dx Gm * Gn exp(-x^2) = 1

Arguments

Type IntentOptional Attributes Name
real, intent(in), dimension (:) :: xptsdum
real, intent(out), dimension (:,0:) :: hpdum

public subroutine init_map(use_lz_layout, use_e_layout, use_le_layout, test)

FIXME : Add documentation

Arguments

Type IntentOptional Attributes Name
logical, intent(in) :: use_lz_layout
logical, intent(in) :: use_e_layout
logical, intent(in) :: use_le_layout
logical, intent(in) :: test

public subroutine init_g2gf(test)

FIXME : Add documentation

Arguments

Type IntentOptional Attributes Name
logical, intent(in) :: test

private subroutine setup_g2le_redistribute_local(g_lo, le_lo, g2le)

Construct a redistribute for g_lo -> le_lo

Arguments

Type IntentOptional Attributes Name
type(g_layout_type), intent(in) :: g_lo
type(le_layout_type), intent(in) :: le_lo
type(redist_type), intent(inout) :: g2le

private subroutine init_g2le_redistribute_local()

Constructs the redistribute mapping from the global g_lo data decomposition to the le_lo decomposition.

Arguments

None

private subroutine check_g2le()

FIXME : Add documentation

Arguments

None

private subroutine setup_g2gf_redistribute(g_lo, gf_lo, g2gf)

Construct the redistribute for g_lo -> gf_lo

Arguments

Type IntentOptional Attributes Name
type(g_layout_type), intent(in) :: g_lo
type(gf_layout_type), intent(in) :: gf_lo
type(redist_type), intent(inout) :: g2gf

private subroutine init_g2gf_redistribute()

Setup the module level g2gf instance describing the transformation from global g_lo to global gf_lo.

Arguments

None

private subroutine check_g2gf()

FIXME : Add documentation

Arguments

None

private subroutine setup_lambda_redistribute_local(g_lo, lz_lo, lambda_map)

Computes the redistribute mapping from the g_lo data decomposition to the lz_lo decomposition

Arguments

Type IntentOptional Attributes Name
type(g_layout_type), intent(in) :: g_lo
type(lz_layout_type), intent(in) :: lz_lo
type(redist_type), intent(inout) :: lambda_map

private subroutine init_lambda_redistribute_local()

Computes the redistribute mapping from the global g_lo data decomposition to the global lz_lo decomposition

Arguments

None

private subroutine setup_energy_redistribute_local(g_lo, e_lo, energy_map)

Constructs the redistribute mapping from a g_lo data decomposition to an e_lo decomposition

Arguments

Type IntentOptional Attributes Name
type(g_layout_type), intent(in) :: g_lo
type(e_layout_type), intent(in) :: e_lo
type(redist_type), intent(inout) :: energy_map

private subroutine init_energy_redistribute_local()

Constructs the redistribute mapping from the global g_lo data decomposition to the global e_lo decomposition

Arguments

None

private subroutine write_mpdist(dist, extension, last)

Used for testing takes as input an array using g_lo and writes it to a .distmp output file

Arguments

Type IntentOptional Attributes Name
complex, intent(in), dimension (-ntgrid:,:,g_lo%llim_proc:) :: dist
character(len=*), intent(in) :: extension
logical, intent(in), optional :: last

private subroutine write_mpdist_le(dist, extension, last)

Used for testing takes as input an array using le_lo and writes it to a .distmp output file

Arguments

Type IntentOptional Attributes Name
complex, intent(in), dimension (:,:,le_lo%llim_proc:) :: dist
character(len=*), intent(in) :: extension
logical, intent(in), optional :: last

public subroutine finish_le_grids()

FIXME : Add documentation

Arguments

None

public subroutine finish_weights()

Deallocate the weights used to provide error estimates

Arguments

None

public subroutine set_le_grids_config(le_grids_config_in)

Set the module level config type Will abort if the module has already been initialised to avoid inconsistencies.

Arguments

Type IntentOptional Attributes Name
type(le_grids_config_type), intent(in), optional :: le_grids_config_in

private subroutine read_le_grids_config(self)

Reads in the le_grids_knobs namelist and populates the member variables

Arguments

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

private subroutine write_le_grids_config(self, unit)

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

Arguments

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

private subroutine reset_le_grids_config(self)

Resets the config object to the initial empty state

Arguments

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

private subroutine broadcast_le_grids_config(self)

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

Arguments

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