kt_grids Module

Set up the perpendicular wavenumbers by calling the appropriate sub-modules.



Contents


Variables

Type Visibility Attributes Name Initial
logical, public, dimension(:,:), allocatable :: kwork_filter
integer, public, dimension(:,:), allocatable :: itleft
integer, public, dimension(:,:), allocatable :: itright
integer, public, dimension(:,:), allocatable :: l_links
integer, public, dimension(:,:), allocatable :: r_links
integer, public, dimension(:,:,:), allocatable :: n_links
integer, public, dimension(:, :), allocatable :: supercell_labels

Labels the supercells as a function of {it, ik}. Primarily to help with post-processing, although can also help with conversion from flux tube to ballooning space. This probably really belongs in kt_grids, but placing here alongside related itleft, itright etc.

integer, public, dimension(:), allocatable :: n_supercells

Records the number of unique supercells for each ky,

integer, public, dimension(:, :), allocatable :: n_cells

Records the number of cells which are members of the supercell which owns the particular {it, ik} point. One would expect this to be equivalent to l_links + r_links + 1.

real, public, dimension (:,:,:), allocatable :: kperp2
real, public, dimension (:,:,:), allocatable :: inv_kperp2
real, public, dimension (:,:), allocatable :: theta0

The grid

real, public, dimension (:), allocatable :: akx

The grid

real, public, dimension (:), allocatable :: aky

The grid

integer, public, dimension(:), allocatable :: ikx

Discrete kx grid index

integer, public :: naky

Number of points

integer, public :: ntheta0

Number of points

integer, public :: nx

Number of (real space) points

integer, public :: ny

Number of (real space) points

integer, public :: jtwist

Related to the box size in x. See jtwist

character(len=20), private :: grid_option

The type of perpendicular wavenumber grid used. See grid_option

real, private :: rhostar

The rhostar (rhoref/Lref) to use to calculate ky from n0. Only used if n0 also set greater than zero.

integer, private :: gridopt_switch
integer, private, parameter :: gridopt_single = 1
integer, private, parameter :: gridopt_range = 2
integer, private, parameter :: gridopt_specified = 3
integer, private, parameter :: gridopt_box = 4
logical, public :: enforce_reality = .false.
logical, public :: is_box = .false.
logical, private :: initialized = .false.
logical, private :: kp2init = .false.
type(kt_grids_config_type), private :: kt_grids_config

Derived Types

type, public, extends(abstract_config_type) ::  kt_grids_config_type

Used to represent the input configuration of kt_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?

logical, public :: skip_smart_defaults = .false.

Do we want to skip the smaart defaults in init?

character(len=20), public :: grid_option = "default"

Controls the type of perpendicular wavenumber grid to use. Can be one of

Read more…
real, public :: rhostar = 1.0e-4

The rhostar (rhoref/Lref) to use to calculate ky from n0. Only used if n0 also set in the active kt_grids sub-type

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 , :: set_smart_defaults => set_smart_defaults_null Subroutine
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_kt_grids_config Subroutine
procedure , public :: write => write_kt_grids_config Subroutine
procedure , public :: reset => reset_kt_grids_config Subroutine
procedure , public :: broadcast => broadcast_kt_grids_config Subroutine
procedure , public , nopass :: get_default_name => get_default_name_kt_grids_config Function
procedure , public , nopass :: get_default_requires_index => get_default_requires_index_kt_grids_config Function

Functions

private function compute_jshift0() result(jshift0)

Compute the spacing in kx indices between connected kx domains (cells) for the lowest non-zonal ky.

Arguments

None

Return Value integer

public elemental function get_leftmost_it(it, ik) result(it_cur)

Helper function for finding the leftmost it of supercell

Arguments

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

Return Value integer

public elemental function get_rightmost_it(it, ik) result(it_cur)

Helper function for finding the rightmost it of supercell

Arguments

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

Return Value integer

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

public pure function get_kt_grids_config()

Get the module level config instance

Arguments

None

Return Value type(kt_grids_config_type)


Subroutines

public subroutine init_kt_grids(kt_grids_config_in, kt_grids_single_config_in, kt_grids_range_config_in, kt_grids_specified_config_in, kt_grids_specified_element_config_in, kt_grids_box_config_in)

FIXME : Add documentation

Arguments

Type IntentOptional Attributes Name
type(kt_grids_config_type), intent(in), optional :: kt_grids_config_in
type(kt_grids_single_config_type), intent(in), optional :: kt_grids_single_config_in
type(kt_grids_range_config_type), intent(in), optional :: kt_grids_range_config_in
type(kt_grids_specified_config_type), intent(in), optional :: kt_grids_specified_config_in
type(kt_grids_specified_element_config_type), intent(in), optional, dimension(:) :: kt_grids_specified_element_config_in
type(kt_grids_box_config_type), intent(in), optional :: kt_grids_box_config_in

private subroutine read_parameters(kt_grids_config_in)

FIXME : Add documentation

Arguments

Type IntentOptional Attributes Name
type(kt_grids_config_type), intent(in), optional :: kt_grids_config_in

public subroutine wnml_kt(unit)

FIXME : Add documentation

Arguments

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

private subroutine init_kperp2()

FIXME : Add documentation

Arguments

None

public subroutine finish_kt_grids()

FIXME : Add documentation

Arguments

None

private subroutine compute_itleft_and_itright(jshift0, itleft, itright)

For the passed jshift0 value determine the it (kx) indices to the left and right of each {it, ik} index pair. Used to construct the connected boundary conditions.

Arguments

Type IntentOptional Attributes Name
integer, intent(in) :: jshift0
integer, intent(out), dimension(:, :) :: itleft
integer, intent(out), dimension(:, :) :: itright

private subroutine count_links_one_side(it_connections, links)

Count how many links are to the left/right of each {it,ik} point

Arguments

Type IntentOptional Attributes Name
integer, intent(in), dimension(:, :) :: it_connections
integer, intent(out), dimension(:, :) :: links

Links is the number of links to the left or right

private subroutine count_links(itleft, itright, l_links, r_links, n_links)

Count the links to the left and right of each {it, ik} point and work out how many values are required to set the bc.

Arguments

Type IntentOptional Attributes Name
integer, intent(in), dimension(:, :) :: itleft
integer, intent(in), dimension(:, :) :: itright
integer, intent(out), dimension(:, :) :: l_links
integer, intent(out), dimension(:, :) :: r_links
integer, intent(out), dimension(:, :, :) :: n_links

private subroutine calculate_supercell_labels(supercell_labels, n_supercells, n_cells)

Assigns a label to each {it, ik} point denoting which unique supercell the point belongs to.

Arguments

Type IntentOptional Attributes Name
integer, intent(out), dimension(:, :) :: supercell_labels
integer, intent(out), dimension(:) :: n_supercells
integer, intent(out), dimension(:, :) :: n_cells

public subroutine flux_tube_field_like_to_ballooning_space(it, ik, field_like_ft, theta_bs, field_like_bs, drop_duplicates)

Extracts the field like data corresponding to the supercell with the {it, ik} wavenumber pair as a member and constructs the ballooning space form. By default includes duplicate theta points but can drop these on request.

Arguments

Type IntentOptional Attributes Name
integer, intent(in) :: it
integer, intent(in) :: ik
complex, intent(in), dimension(-ntgrid:, :, :) :: field_like_ft
real, intent(out), dimension(:), allocatable :: theta_bs
complex, intent(out), dimension(:), allocatable :: field_like_bs
logical, intent(in), optional :: drop_duplicates

public subroutine check_kt_grids(report_unit)

FIXME : Add documentation

Arguments

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

private subroutine read_kt_grids_config(self)

Reads in the kt_grids_knobs namelist and populates the member variables

Arguments

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

private subroutine write_kt_grids_config(self, unit)

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

Arguments

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

private subroutine reset_kt_grids_config(self)

Resets the config object to the initial empty state

Arguments

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

private subroutine broadcast_kt_grids_config(self)

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

Arguments

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

public subroutine set_kt_grids_config(kt_grids_config_in)

Set the module level config instance

Arguments

Type IntentOptional Attributes Name
type(kt_grids_config_type), intent(in), optional :: kt_grids_config_in