dist_fn Module

The principal function of this module is to evolve the distribution function, that is, to advance the discrete gyrokinetic equation. This involves calculating the source and dealing with the complexities of the parallel boundary conditions. In addition it contains a routine for implementing perpendicular velocity shear and calculating the right-hand side of the field equation, as well as a host of other functions. Initializes a limited selection of arrays, for example g, gnew, vperp2, typically those which are needed by other modules that don't need dist_fn to be fully initialized (e.g. nonlinear_terms) This initialization level depends on grid sizes.

Deallocates arrays allocated in init_dist_fn_arrays

Reads the dist_fn_knobs, source knobs, and dist_fn_species_knobs namelists. This has be done independently of initializing the distribution function because it needs to be possible to override parameters such as g_exb. Initializes parallel boundary conditions. This level depends on geometry. Initializes bessel functions and field_eq. Note that this level depends on species paramters. Fully initialize the dist_fn module. Note that this level depends on the size of the timestep. Done for slab, where itor_over_B is determined by angle between B-field and toroidal flow: itor_over_B = (d(u_z)/dx) / (d(u_y)/dx) = Btor / Bpol u = u0 (phihat) = x d(u0)/dx (phihat) = x d(uy)/dx (yhat + Btor/Bpol zhat) g_exb = d(uy)/dx => d(uz)/dx = g_exb * Btor/Bpol = g_exb * itor_over_B



Contents

check_dist_fn wnml_dist_fn wnml_dist_fn_species init_dist_fn_parameters init_dist_fn_arrays init_dist_fn_level_1 init_dist_fn_level_2 init_dist_fn init_dist_fn_level_3 finish_dist_fn finish_dist_fn_parameters finish_dist_fn_arrays finish_dist_fn_level_1 finish_dist_fn_level_2 finish_dist_fn_level_3 set_profiles_overrides set_optimisations_overrides read_parameters read_species_knobs init_wdrift init_vperp2 init_vpa_vpac init_vpar init_wstar init_bessel init_invert_rhs init_homogeneous_g init_bc init_source_term flux_tube_field_like_to_ballooning_space calculate_supercell_labels compute_itleft_and_itright compute_connections set_save_h count_links_one_side count_links setup_fields_implicit_class_arrays setup_connected_bc_redistribute setup_connected_bc_redistribute_mixed_wfb setup_pass_incoming_boundary_to_connections init_connected_bc init_pass_ends get_left_connection get_right_connection allocate_arrays timeadv collisions_advance exb_shear init_enforce_parity get_parity_conn enforce_parity get_source_term get_source_term_opt get_source_term_on_local_domain invert_rhs_1 apply_parallel_boundary_conditions self_periodic enforce_linked_boundary_conditions apply_linked_boundary_conditions invert_rhs ensure_single_val_fields_pass ensure_single_val_fields_pass_r getan_from_dfn getan check_linked_boundaries_are_satisfied init_fieldeq getfieldeq1 getfieldeq getfieldeq_nogath getfieldeq1_nogath check_getan getan_nogath_from_dfn getan_nogath calculate_potentials_from_nonadiabatic_dfn setup_get_fields_direct_from_dfn_denominators get_fields_direct_from_dfn get_init_field get_field_inconsistency dump_current_source_term dump_homogeneous_solution find_leftmost_link find_rightmost_link calculate_flux_surface_average set_dist_fn_config read_dist_fn_config write_dist_fn_config reset_dist_fn_config broadcast_dist_fn_config read_source_config write_source_config reset_source_config broadcast_source_config read_dist_fn_species_config write_dist_fn_species_config reset_dist_fn_species_config broadcast_dist_fn_species_config

Variables

Type Visibility Attributes Name Initial
real, private, dimension (:), allocatable :: fexp
real, private, dimension (:), allocatable :: bkdiff
real, public :: apfac
real, private :: driftknob
real, private :: tpdriftknob
real, private :: poisfac
real, private :: vparknob
real, private :: t0
real, public :: omega0
real, public :: gamma0
real, private :: source0
real, private :: phi_ext
real, private :: afilter
real, private :: exponential_boundary_factor
real, private :: wfb
real, public :: g_exb
real, public :: g_exbfac
real, private :: omprimfac
real, private :: btor_slab
real, private :: mach
real, private :: g_exb_start_time
integer, private :: g_exb_start_timestep
logical, private :: hyper_in_initialisation
logical, private :: start_from_previous_solution
logical, private :: boundary_off_grid
logical, private :: exponential_boundary
logical, private :: nonad_zero
logical, private :: esv
logical, private :: opt_source
integer, public :: adiabatic_option_switch
integer, private, parameter :: adiabatic_option_default = 1
integer, public, parameter :: adiabatic_option_fieldlineavg = 3
integer, private, parameter :: adiabatic_option_yavg = 4
integer, private :: source_option_switch
integer, private, parameter :: source_option_full = 1
integer, private, parameter :: source_option_phiext_full = 5
integer, private, parameter :: source_option_homogeneous = 6
integer, private :: boundary_option_switch
integer, private, parameter :: boundary_option_default = 0
integer, private, parameter :: boundary_option_zero = 1
integer, private, parameter :: boundary_option_self_periodic = 2
integer, private, parameter :: boundary_option_linked = 4
logical, public :: def_parity
logical, public :: even
logical, private :: zero_forbid
logical, public :: gf_lo_integrate
logical, private :: mult_imp
real, private, dimension (:,:,:), allocatable :: wdrift
real, private, dimension (:,:,:), allocatable :: wdriftttp
real, public, dimension (:,:,:), allocatable :: gamtot
real, public, dimension (:,:,:), allocatable :: gamtot1
real, public, dimension (:,:,:), allocatable :: gamtot2
real, private, dimension (:,:,:), allocatable :: gamtot3
complex, private, dimension (:,:,:), allocatable :: a
complex, private, dimension (:,:,:), allocatable :: b
complex, private, dimension (:,:,:), allocatable :: r
complex, private, dimension (:,:,:), allocatable :: ainv
real, private, dimension(:, :, :), allocatable :: vpar
complex, private, dimension (:,:,:), allocatable :: g_h
complex, private, dimension (:,:,:), allocatable :: g_adj
integer, private, dimension(:), allocatable :: jump
integer, private, dimension(:), allocatable :: ikx_indexed
real, private, dimension(:,:), allocatable :: ufac
complex, private, dimension (:,:,:), allocatable :: source_coeffs_phim
complex, private, dimension (:,:,:), allocatable :: source_coeffs_phip
complex, private, dimension (:,:,:), allocatable :: source_coeffs_aparm
complex, private, dimension (:,:,:), allocatable :: source_coeffs_aparp
real, private, allocatable, dimension(:,:) :: awgt
complex, public, allocatable, dimension(:,:) :: fl_avg
integer, public, dimension (:,:), allocatable :: itleft
integer, public, dimension (:,:), allocatable :: itright
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, private, dimension(:, :, :), allocatable :: inv_phi_denominator_g
real, private, dimension(:, :, :), allocatable :: inv_bpar_denominator_g
type(connections_type), private, dimension (:), allocatable, save :: connections
type(redist_type), private, save :: links_p
type(redist_type), private, save :: links_h
type(redist_type), private, save :: wfb_p
type(redist_type), private, save :: wfb_h
type(redist_type), public, save :: pass_right
type(redist_type), private, save :: pass_left
type(redist_type), private, save :: incoming_links
type(redist_type), private, save :: parity_redist
integer, public, dimension (:,:), allocatable :: l_links
integer, public, dimension (:,:), allocatable :: r_links
integer, private, dimension (:,:,:), allocatable :: n_links
logical, private, dimension (:,:), allocatable :: save_h
logical, private :: no_connections = .false.

Indicates if there are connected theta domains in this simulation or not. Should only be used as a part of linked boundary conditions, but worth noting that the default given may suggest that there are connections in simulations with boundary conditions other than linked.

integer, public, dimension(:), allocatable :: M_class
integer, public, dimension(:), allocatable :: N_class
integer, public :: i_class
logical, private :: initialized = .false.
logical, private :: exb_first = .true.
logical, private :: initialized_dist_fn_parameters = .false.
logical, private :: initialized_dist_fn_arrays = .false.
logical, private :: initialized_dist_fn_level_1 = .false.
logical, private :: initialized_dist_fn_level_2 = .false.
logical, private :: initialized_dist_fn_level_3 = .false.
logical, private :: readinit = .false.
logical, private :: bessinit = .false.
logical, private :: connectinit = .false.
logical, private :: feqinit = .false.
integer, private, parameter :: max_allowed_links = 5000

Arbitrary limit on the maximum number of allowed links in connected boundary conditions

logical, private, parameter :: moment_to_allprocs = .false.
type(dist_fn_config_type), private :: dist_fn_config
type(source_config_type), private :: source_config
type(dist_fn_species_config_type), private, dimension(:), allocatable :: dist_fn_species_config

Interfaces

public interface set_overrides


Derived Types

type, private ::  connections_type

A type to record information about connections between iglo points Store the iglo and iproc indices for connections to the left and right of a given point. Initialised to no connections, indicated by negative values

Components

Type Visibility Attributes Name Initial
integer, public :: iproc_left = -1
integer, public :: iglo_left = -1
integer, public :: iproc_right = -1
integer, public :: iglo_right = -1
logical, public :: neighbor = .false.

type, public, extends(abstract_config_type) ::  dist_fn_config_type

Used to represent the input configuration of dist_fn

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.

Read more…
real, public :: afilter = 0.0

For debugging only.

Read more…
real, public :: apfac = 1.0

Leave as unity. For debugging.

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

If true then attempt to enforce gnew == 0 at a half grid point past the end of the grid rather than on the last grid point. This is an experimental feature which has been seen to help suppress grid scale oscillations near the boundary.

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:

Read more…
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.

logical, public :: exponential_boundary = .false.

If true then attempt to enforce an exponential decay boundary condition on gnew or hnew (depending on nonad_zero). Decay rate scaled by exponential_boundary_factor

real, public :: exponential_boundary_factor = 1.0

Factor scaling the exponential decay boundary condition

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_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..

Read more…
logical, public :: hyper_in_initialisation = .true.

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

real, public :: mach = 0.0

Number multiplying the coriolis drift.

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

Allow different species to have different values of bakdif. Forced false 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.

Read more…
real, public :: wfb = 1.0

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

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 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_dist_fn_config Subroutine
procedure , public :: write => write_dist_fn_config Subroutine
procedure , public :: reset => reset_dist_fn_config Subroutine
procedure , public :: broadcast => broadcast_dist_fn_config Subroutine
procedure , public , nopass :: get_default_name => get_default_name_dist_fn_config Function
procedure , public , nopass :: get_default_requires_index => get_default_requires_index_dist_fn_config Function

type, public, extends(abstract_config_type) ::  source_config_type

Used to represent the input configuration of source

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 :: gamma0 = 0.0

Growth rate of non-standard source used with source_option = 'phiext_full'.

real, public :: omega0 = 0.0

Frequency of non-standard source used with source_option = 'phiext_full'.

real, public :: phi_ext = 0.0

Amplitude of external phi added as source term with source_option = 'phiext_full'. If zero (default) then no extra term included in the source.

real, public :: source0 = 1.0

Amplitude of non-standard source used with source_option = 'phiext_full' when time >= t0.

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

Controls the source term used in the time advance. Should be one of:

Read more…
real, public :: t0 = 100.0

Turn on any artificial sources after time = t0. Only used with source_option = 'phiext_full'.

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_source_config Subroutine
procedure , public :: write => write_source_config Subroutine
procedure , public :: reset => reset_source_config Subroutine
procedure , public :: broadcast => broadcast_source_config Subroutine
procedure , public , nopass :: get_default_name => get_default_name_source_config Function
procedure , public , nopass :: get_default_requires_index => get_default_requires_index_source_config Function

type, public, extends(abstract_config_type) ::  dist_fn_species_config_type

Used to represent the input configuration of dist_fn_species. There should be one of this namelist for each species simulated.

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 :: bakdif = 0.0

Spatial implicitness parameter. Any value greater than 0 adds numerical dissipation which is often necessary to avoid grid scale oscillations. When bakdif = 0.0 (default) we use a order grid centered approach in the parallel direction. When bakdif = 1.0 this becomes a fully upwinded method. Recommended value is 0.05 for electrostatic simulations and 0.0 for electromagnetic.

Read more…
real, public :: fexpr = 0.4

Sets the real part of the temporal implicitness parameter. Any value smaller than 0.5 adds numerical dissipation. When fexpr = 0.5 we have a order time centered approach. If fexpr = 0.0 this reduces to a fully implicit backward Euler method. When fexpr = 1.0 this instead becomes a fully explicit forward Euler method (not recommended). The recommended value is 0.48.

Read more…

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_dist_fn_species_config Subroutine
procedure , public :: write => write_dist_fn_species_config Subroutine
procedure , public :: reset => reset_dist_fn_species_config Subroutine
procedure , public :: broadcast => broadcast_dist_fn_species_config Subroutine
procedure , public , nopass :: get_default_name => get_default_name_dist_fn_species_config Function
procedure , public , nopass :: get_default_requires_index => get_default_requires_index_dist_fn_species_config Function

Functions

public pure function wdrift_func(ig, iglo)

Calculates the value of the magnetic drifts (curvature + grad-B) corresponding to the theta grid location given by ig for the iglo index of interest.

Arguments

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

Return Value real

private pure function wcoriolis_func(ig, iglo)

Calculates the value of the Coriolis drift at the location corresponding to the passed indices.

Arguments

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

Return Value real

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

private 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

public function has_linked_boundary()

Returns true if we're using linked boundary conditions and false otherwise

Arguments

None

Return Value logical

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_dist_fn_config()

Get the module level config instance

Arguments

None

Return Value type(dist_fn_config_type)

private function get_default_name_source_config()

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_source_config()

Get the module level config instance

Arguments

None

Return Value type(source_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

public pure function get_dist_fn_species_config()

Get the array of module level config instances. If it isn't allocated, then return a zero-length array

Arguments

None

Return Value type(dist_fn_species_config_type), allocatable, dimension(:)


Subroutines

public subroutine check_dist_fn(report_unit)

FIXME : Add documentation

Arguments

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

public subroutine wnml_dist_fn(unit)

FIXME : Add documentation

Arguments

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

public subroutine wnml_dist_fn_species(unit)

FIXME : Add documentation

Arguments

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

public subroutine init_dist_fn_parameters(dist_fn_config_in, source_config_in, dist_fn_species_config_in)

FIXME : Add documentation

Arguments

Type IntentOptional Attributes Name
type(dist_fn_config_type), intent(in), optional :: dist_fn_config_in
type(source_config_type), intent(in), optional :: source_config_in
type(dist_fn_species_config_type), intent(in), optional, dimension(:), allocatable :: dist_fn_species_config_in

public subroutine init_dist_fn_arrays()

FIXME : Add documentation

Arguments

None

public subroutine init_dist_fn_level_1()

FIXME : Add documentation

Arguments

None

public subroutine init_dist_fn_level_2()

FIXME : Add documentation

Arguments

None

public subroutine init_dist_fn()

FIXME : Add documentation

Arguments

None

public subroutine init_dist_fn_level_3()

FIXME : Add documentation

Arguments

None

public subroutine finish_dist_fn()

FIXME : Add documentation

Arguments

None

public subroutine finish_dist_fn_parameters()

FIXME : Add documentation

Arguments

None

public subroutine finish_dist_fn_arrays()

Arguments

None

public subroutine finish_dist_fn_level_1()

Arguments

None

public subroutine finish_dist_fn_level_2()

FIXME : Add documentation

Arguments

None

public subroutine finish_dist_fn_level_3()

FIXME : Add documentation

Arguments

None

private subroutine set_profiles_overrides(prof_ov)

FIXME : Add documentation

Arguments

Type IntentOptional Attributes Name
type(profiles_overrides_type), intent(in) :: prof_ov

private subroutine set_optimisations_overrides(opt_ov)

FIXME : Add documentation

Arguments

Type IntentOptional Attributes Name
type(optimisations_overrides_type), intent(in) :: opt_ov

public subroutine read_parameters(dist_fn_config_in, source_config_in, dist_fn_species_config_in)

FIXME : Add documentation
CMR, 19/10/10: Override itor_over_B, if "dist_fn_knobs" parameter btor_slab ne 0 Not ideal to set geometry quantity here, but its historical!

Arguments

Type IntentOptional Attributes Name
type(dist_fn_config_type), intent(in), optional :: dist_fn_config_in
type(source_config_type), intent(in), optional :: source_config_in
type(dist_fn_species_config_type), intent(in), optional, dimension(:), allocatable :: dist_fn_species_config_in

private subroutine read_species_knobs(dist_fn_species_config_in)

FIXME : Add documentation

Arguments

Type IntentOptional Attributes Name
type(dist_fn_species_config_type), intent(in), optional, dimension(:), allocatable :: dist_fn_species_config_in

private subroutine init_wdrift()

FIXME : Add documentation

Arguments

None

private subroutine init_vperp2()

FIXME : Add documentation

Arguments

None

private subroutine init_vpa_vpac()

Initialised the on grid v|| (vpa) and grid-centred v|| (vpac) arrays

Arguments

None

private subroutine init_vpar()

FIXME : Add documentation

Arguments

None

private subroutine init_wstar()

FIXME : Add documentation

Arguments

None

private subroutine init_bessel()

Compute and store the Bessel functions required for future usage, aj0 and aj1.

Read more…

Arguments

None

private subroutine init_invert_rhs()

FIXME : Add documentation

Arguments

None

private subroutine init_homogeneous_g(g_h, force_passing)

Calculates the homogeneous solution g_h used as a part of the trapped particle and linked boundary condition solve in invert_rhs. This solution only depends on r so can be calculated during initialisation. Note that r depends on physics terms that contain dt so we must recalculate the solution g_h if the timestep changes. !!!!!!!!!!!!!!!!!!!!!!!!! time advance vpar < 0 ! !!!!!!!!!!!!!!!!!!!!!!!!! time advance vpar < 0 homogeneous part: g_h !!!!!!!!!!!!!!!!!!!!!!!!! time advance vpar > 0 ! !!!!!!!!!!!!!!!!!!!!!!!!! First set BCs for trapped particles at lower bounce point

Arguments

Type IntentOptional Attributes Name
complex, intent(out), dimension(-ntgrid:, :, g_lo%llim_proc:) :: g_h
logical, intent(in), optional :: force_passing

private subroutine init_bc()

FIXME : Add documentation

Arguments

None

private subroutine init_source_term()

FIXME : Add documentation

Arguments

None

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

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

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 compute_connections(itleft, itright, connections)

Look up and store the iglo index and responsible processor for connections to the left and right of each local iglo index. Note this is only interested in passing particles and the non-trapped wfb. Trapped particles are considered to have no connections.

Arguments

Type IntentOptional Attributes Name
integer, intent(in), dimension(:, :) :: itleft
integer, intent(in), dimension(:, :) :: itright
type(connections_type), intent(out), dimension(g_lo%llim_proc:) :: connections

private subroutine set_save_h(connections, save_h)

Set the save_h flag based on connections data

Arguments

Type IntentOptional Attributes Name
type(connections_type), intent(in), dimension(g_lo%llim_proc:) :: connections
logical, intent(out), dimension(:, g_lo%llim_proc:) :: save_h

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 setup_fields_implicit_class_arrays(l_links, r_links, M_class, N_class, i_class)

Count the number of unique supercell sizes and setup the fields implicit arrays M_class and N_class.

Arguments

Type IntentOptional Attributes Name
integer, intent(in), dimension(:, :) :: l_links
integer, intent(in), dimension(:, :) :: r_links
integer, intent(out), dimension(:), allocatable :: M_class

M_class(i) = number of members in i_th class (How many supercells of this size)

integer, intent(out), dimension(:), allocatable :: N_class

N_class(i) = number of linked cells for i_th class (Size of supercell)

integer, intent(out) :: i_class

i_class = number of classes (unique sizes of supercell)

private subroutine setup_connected_bc_redistribute(l_links, r_links, n_links_max, links_p, links_h, no_connections)

Populates the redistribute types describing the communication pattern required to deal with linked boundary conditions. Only deals with passing particles, including the wfb if passing_wfb is true. DD>Note the communications setup here are often equivalent to an all-to-all type

Arguments

Type IntentOptional Attributes Name
integer, intent(in), dimension(:, :) :: l_links
integer, intent(in), dimension(:, :) :: r_links
integer, intent(in) :: n_links_max
type(redist_type), intent(out) :: links_p
type(redist_type), intent(out) :: links_h
logical, intent(out) :: no_connections

private subroutine setup_connected_bc_redistribute_mixed_wfb(l_links, r_links, n_links_max, wfb_p, wfb_h)

Populates the redistribute types describing the communication pattern required to deal with linked boundary conditions for the mixed wfb. This is used when passing_wfb = trapped_wfb = false. This is the default.

Arguments

Type IntentOptional Attributes Name
integer, intent(in), dimension(:, :) :: l_links
integer, intent(in), dimension(:, :) :: r_links
integer, intent(in) :: n_links_max
type(redist_type), intent(out) :: wfb_p
type(redist_type), intent(out) :: wfb_h

private subroutine setup_pass_incoming_boundary_to_connections(l_links, r_links, incoming_links)

Setup the redistribute associated with passing the incoming boundary values to the previous connected cell, storing at its connected boundary. This is required in order to allow for non-zero incoming boundary conditions on internal cells.

Arguments

Type IntentOptional Attributes Name
integer, intent(in), dimension(:, :) :: l_links
integer, intent(in), dimension(:, :) :: r_links
type(redist_type), intent(out) :: incoming_links

private subroutine init_connected_bc()

Coordinates the calculation of all data required for later application of linked boundary conditions. Deals with identifying the communication pattern and creating the associated redistributes used to perform the required communication.

Arguments

None

public subroutine init_pass_ends(pass_obj, dir, sigma, typestr, ngsend)

Copy of CMR's init_pass_right (revision 2085) but in customisable direction to aid code reuse and with optional range in theta (i.e. so can pass more than just boundary points) An example use is: call init_pass_ends(pass_right,'r',1,'c',3) call fill(pass_right,gnew,gnew) This will pass gnew(ntgrid-2:ntgrid,1,iglo) to gnew(-ntgrid-2:-ntgrid,1,iglo_linked)

Read more…

Arguments

Type IntentOptional Attributes Name
type(redist_type), intent(out) :: pass_obj

Redist type object to hold communication logic

character(len=1), intent(in) :: dir

Character string for direction of communication, should be 'l' for left and 'r' for right

integer, intent(in) :: sigma

Which sigma index to send

character(len=1), intent(in) :: typestr

Character string for type of data to be communicated. Should be 'c','r','i' or 'l'

integer, intent(in), optional :: ngsend

How many theta grid points are we sending

private subroutine get_left_connection(iglo, iglo_left, iproc_left)

FIXME : Add documentation

Arguments

Type IntentOptional Attributes Name
integer, intent(in) :: iglo
integer, intent(out) :: iglo_left
integer, intent(out) :: iproc_left

private subroutine get_right_connection(iglo, iglo_right, iproc_right)

FIXME : Add documentation

Arguments

Type IntentOptional Attributes Name
integer, intent(in) :: iglo
integer, intent(out) :: iglo_right
integer, intent(out) :: iproc_right

private subroutine allocate_arrays()

FIXME : Add documentation

Arguments

None

public subroutine timeadv(phi, apar, bpar, phinew, aparnew, bparnew, istep, mode)

This function calculates the distribution function at the next timestep. It calculates both the inhomogeneous part, gnew, due to the sources (principly the drive terms and the nonlinear term) and the homogeneous part, g1. The actual evolution of the dist func is done in the subroutine invert_rhs.

Read more…

Arguments

Type IntentOptional Attributes Name
complex, intent(in), dimension (-ntgrid:,:,:) :: phi
complex, intent(in), dimension (-ntgrid:,:,:) :: apar
complex, intent(in), dimension (-ntgrid:,:,:) :: bpar
complex, intent(in), dimension (-ntgrid:,:,:) :: phinew
complex, intent(in), dimension (-ntgrid:,:,:) :: aparnew
complex, intent(in), dimension (-ntgrid:,:,:) :: bparnew
integer, intent(in) :: istep
integer, intent(in), optional :: mode

public subroutine collisions_advance(phi, bpar, phinew, aparnew, bparnew, mode)

Advance collision term one timestep by implicit Euler.

Read more…

Arguments

Type IntentOptional Attributes Name
complex, intent(in), dimension (-ntgrid:,:,:) :: phi
complex, intent(in), dimension (-ntgrid:,:,:) :: bpar
complex, intent(inout), dimension (-ntgrid:,:,:) :: phinew
complex, intent(inout), dimension (-ntgrid:,:,:) :: aparnew
complex, intent(inout), dimension (-ntgrid:,:,:) :: bparnew
integer, intent(in), optional :: mode

public subroutine exb_shear(g0, phi, apar, bpar, istep, field_local)

FIXME : Add documentation

Read more…

Arguments

Type IntentOptional Attributes Name
complex, intent(inout), dimension (-ntgrid:,:,g_lo%llim_proc:) :: g0
complex, intent(inout), dimension (-ntgrid:,:,:) :: phi
complex, intent(inout), dimension (-ntgrid:,:,:) :: apar
complex, intent(inout), dimension (-ntgrid:,:,:) :: bpar
integer, intent(in) :: istep
logical, intent(in), optional :: field_local

private subroutine init_enforce_parity(redist_obj, ik_ind)

Subroutine to setup a redistribute object to be used in enforcing parity

Arguments

Type IntentOptional Attributes Name
type(redist_type), intent(out) :: redist_obj
integer, intent(in), optional :: ik_ind

private subroutine get_parity_conn(iglo, iglo_conn, iproc_conn)

Return the iglo corresponding to the part of the domain given by iglo reflected in theta=theta0

Arguments

Type IntentOptional Attributes Name
integer, intent(in) :: iglo
integer, intent(out) :: iglo_conn
integer, intent(out) :: iproc_conn

private subroutine enforce_parity(redist_obj, ik_ind)

Enforce requested parity

Arguments

Type IntentOptional Attributes Name
type(redist_type), intent(in), optional :: redist_obj
integer, intent(in), optional :: ik_ind

private subroutine get_source_term(phi, apar, bpar, phinew, aparnew, bparnew, include_explicit, ab_coefficients, isgn, iglo, ik, it, il, ie, is, sourcefac, source)

FIXME : Add documentation !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! Default choice: solve self-consistent equations !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! Solve self-consistent terms + include external i omega_d * F_0 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! Do matrix multiplications !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! special source term for totally trapped particles !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! CMR, 13/10/2014: Upper limit of following loops setting source changed from ntgrid to ntgrid-1 Source is allocated as: source(-ntgrid:ntgrid-1), so ntgrid is out of bounds.

Arguments

Type IntentOptional Attributes Name
complex, intent(in), dimension (-ntgrid:,:,:) :: phi
complex, intent(in), dimension (-ntgrid:,:,:) :: apar
complex, intent(in), dimension (-ntgrid:,:,:) :: bpar
complex, intent(in), dimension (-ntgrid:,:,:) :: phinew
complex, intent(in), dimension (-ntgrid:,:,:) :: aparnew
complex, intent(in), dimension (-ntgrid:,:,:) :: bparnew
logical, intent(in) :: include_explicit
real, intent(in), dimension(:), allocatable :: ab_coefficients
integer, intent(in) :: isgn
integer, intent(in) :: iglo
integer, intent(in) :: ik
integer, intent(in) :: it
integer, intent(in) :: il
integer, intent(in) :: ie
integer, intent(in) :: is
complex, intent(in) :: sourcefac
complex, intent(out), dimension (-ntgrid:) :: source

private subroutine get_source_term_opt(phi, apar, bpar, phinew, aparnew, bparnew, include_explicit, ab_coefficients, iglo, ik, it, il, ie, is, sourcefac, source)

This is a version of get_source_term which does both sign (sigma) together and uses precalculated constant terms. Leads to more memory usage than original version but can be significantly faster (~50%)

Arguments

Type IntentOptional Attributes Name
complex, intent(in), dimension (-ntgrid:,:,:) :: phi
complex, intent(in), dimension (-ntgrid:,:,:) :: apar
complex, intent(in), dimension (-ntgrid:,:,:) :: bpar
complex, intent(in), dimension (-ntgrid:,:,:) :: phinew
complex, intent(in), dimension (-ntgrid:,:,:) :: aparnew
complex, intent(in), dimension (-ntgrid:,:,:) :: bparnew
logical, intent(in) :: include_explicit
real, intent(in), dimension(:), allocatable :: ab_coefficients
integer, intent(in) :: iglo
integer, intent(in) :: ik
integer, intent(in) :: it
integer, intent(in) :: il
integer, intent(in) :: ie
integer, intent(in) :: is
complex, intent(in) :: sourcefac
complex, intent(out), dimension (-ntgrid:,:) :: source

private subroutine get_source_term_on_local_domain(source, phi, apar, bpar, phinew, aparnew, bparnew, istep)

Calculates the regular source term on the entire local domain and stores in the output source.

Read more…

Arguments

Type IntentOptional Attributes Name
complex, intent(inout), dimension (-ntgrid:, :, g_lo%llim_proc:) :: source
complex, intent(in), dimension (-ntgrid:,:,:) :: phi
complex, intent(in), dimension (-ntgrid:,:,:) :: apar
complex, intent(in), dimension (-ntgrid:,:,:) :: bpar
complex, intent(in), dimension (-ntgrid:,:,:) :: phinew
complex, intent(in), dimension (-ntgrid:,:,:) :: aparnew
complex, intent(in), dimension (-ntgrid:,:,:) :: bparnew
integer, intent(in) :: istep

private subroutine invert_rhs_1(phinew, bparnew, source)

Calculates the "new" distribution function for the passed source calculated using the passed fields and current distribution in g.

Read more…

Arguments

Type IntentOptional Attributes Name
complex, intent(in), dimension (-ntgrid:,:,:) :: phinew
complex, intent(in), dimension (-ntgrid:,:,:) :: bparnew
complex, intent(inout), dimension (-ntgrid:,:,g_lo%llim_proc:) :: source

private pure subroutine apply_parallel_boundary_conditions(gnew, source, it, ik, ie, is, iglo, phinew, bparnew, is_left_boundary, is_right_boundary)

Apply one of the "end of the grid" parallel boundary conditions

Arguments

Type IntentOptional Attributes Name
complex, intent(inout), dimension (-ntgrid:,:,g_lo%llim_proc:) :: gnew
complex, intent(in), dimension (-ntgrid:,:,g_lo%llim_proc:) :: source
integer, intent(in) :: it
integer, intent(in) :: ik
integer, intent(in) :: ie
integer, intent(in) :: is
integer, intent(in) :: iglo
complex, intent(in), dimension (-ntgrid:,:,:) :: phinew
complex, intent(in), dimension (-ntgrid:,:,:) :: bparnew
logical, intent(in) :: is_left_boundary
logical, intent(in) :: is_right_boundary

private subroutine self_periodic(gnew, g_h, iglo, is, ie, it, ik, is_wfb, phinew, bparnew)

Sets sum of homogeneous and inhomogeneous solutions to give a result gnew(ntgrid,2) = gnew(-ntgrid,2) gnew(ntgrid,1) = gnew(-ntgrid,1) ie periodic bcs at the ends of the flux tube.

Read more…

Arguments

Type IntentOptional Attributes Name
complex, intent(inout), dimension(-ntgrid:, :, g_lo%llim_proc:) :: gnew
complex, intent(in), dimension(-ntgrid:, :, g_lo%llim_proc:) :: g_h
integer, intent(in) :: iglo
integer, intent(in) :: is
integer, intent(in) :: ie
integer, intent(in) :: it
integer, intent(in) :: ik
logical, intent(in) :: is_wfb
complex, intent(in), dimension (-ntgrid:,:,:) :: phinew
complex, intent(in), dimension (-ntgrid:,:,:) :: bparnew

A shorthand for apply_linked_boundary_conditions passing the regular module level instances of each of the required arguments. Primarily intended for testing to avoid having to expose additional data arrays.

Arguments

None

private subroutine apply_linked_boundary_conditions(g_in, g_h, g_adj, phinew, bparnew)

Applies linked (twist-shift) boundary conditions to passed distribution function DD>Note these fill routines are often equivalent to an all-to-all type

Arguments

Type IntentOptional Attributes Name
complex, intent(inout), dimension(-ntgrid:, :, g_lo%llim_proc:) :: g_in
complex, intent(inout), dimension(-ntgrid:, :, g_lo%llim_proc:) :: g_h
complex, intent(inout), dimension(:, :, g_lo%llim_proc:) :: g_adj
complex, intent(in), dimension (-ntgrid:, :, :) :: phinew
complex, intent(in), dimension (-ntgrid:, :, :) :: bparnew

private subroutine invert_rhs(phi, apar, bpar, phinew, aparnew, bparnew, istep)

FIXME : Add documentation

Arguments

Type IntentOptional Attributes Name
complex, intent(in), dimension (-ntgrid:,:,:) :: phi
complex, intent(in), dimension (-ntgrid:,:,:) :: apar
complex, intent(in), dimension (-ntgrid:,:,:) :: bpar
complex, intent(in), dimension (-ntgrid:,:,:) :: phinew
complex, intent(in), dimension (-ntgrid:,:,:) :: aparnew
complex, intent(in), dimension (-ntgrid:,:,:) :: bparnew
integer, intent(in) :: istep

private subroutine ensure_single_val_fields_pass(arr, force_all)

Ensure that linked boundary values of passed complex field are single valued (e.g. kperp2(ntgrid,ikx,iky) is equal to kperp2(-ntgrid,ikx_link,iky) as these correspond to the same location).

Read more…

Arguments

Type IntentOptional Attributes Name
complex, intent(inout), dimension (-ntgrid:,:,:) :: arr
logical, intent(in), optional :: force_all

private subroutine ensure_single_val_fields_pass_r(arr, force_all)

Ensure that linked boundary values of passed real field are single valued (e.g. kperp2(ntgrid,ikx,iky) is equal to kperp2(-ntgrid,ikx_link,iky) as these correspond to the same location).

Read more…

Arguments

Type IntentOptional Attributes Name
real, intent(inout), dimension (-ntgrid:,:,:) :: arr
logical, intent(in), optional :: force_all

private subroutine getan_from_dfn(g_in, antot, antota, antotp, local_only)

Compute velocity space integrals over :

Read more…

Arguments

Type IntentOptional Attributes Name
complex, intent(in), dimension(-ntgrid:, :, g_lo%llim_proc:) :: g_in
complex, intent(inout), dimension (-ntgrid:,:,:) :: antot
complex, intent(inout), dimension (-ntgrid:,:,:) :: antota
complex, intent(inout), dimension (-ntgrid:,:,:) :: antotp
logical, intent(in), optional :: local_only

public subroutine getan(antot, antota, antotp, local_only)

Compute velocity space integrals over :

Read more…

Arguments

Type IntentOptional Attributes Name
complex, intent(inout), dimension (-ntgrid:,:,:) :: antot
complex, intent(inout), dimension (-ntgrid:,:,:) :: antota
complex, intent(inout), dimension (-ntgrid:,:,:) :: antotp
logical, intent(in), optional :: local_only

public subroutine check_linked_boundaries_are_satisfied(g_array, pass_right, pass_left, identifier, tolerance)

Check if the passed distribution function shaped array has the same value at the duplicate theta points arising from the linked boundary conditions.

Read more…

Arguments

Type IntentOptional Attributes Name
complex, intent(in), dimension(-ntgrid:, :, g_lo%llim_proc:) :: g_array
type(redist_type), intent(inout) :: pass_right
type(redist_type), intent(inout) :: pass_left
character(len=*), intent(in), optional :: identifier
real, intent(in), optional :: tolerance

private subroutine init_fieldeq()

FIXME : Add documentation
DD>Make sure gamtots are single valued

Arguments

None

private subroutine getfieldeq1(phi, apar, bpar, antot, antota, antotp, fieldeq, fieldeqa, fieldeqp, local_only)

FIXME : Add documentation

Arguments

Type IntentOptional Attributes Name
complex, intent(in), dimension (-ntgrid:,:,:) :: phi
complex, intent(in), dimension (-ntgrid:,:,:) :: apar
complex, intent(in), dimension (-ntgrid:,:,:) :: bpar
complex, intent(in), dimension (-ntgrid:,:,:) :: antot
complex, intent(in), dimension (-ntgrid:,:,:) :: antota
complex, intent(in), dimension (-ntgrid:,:,:) :: antotp
complex, intent(inout), dimension (-ntgrid:,:,:) :: fieldeq
complex, intent(inout), dimension (-ntgrid:,:,:) :: fieldeqa
complex, intent(inout), dimension (-ntgrid:,:,:) :: fieldeqp
logical, intent(in), optional :: local_only

public subroutine getfieldeq(phi, apar, bpar, fieldeq, fieldeqa, fieldeqp, local_only)

FIXME : Add documentation

Arguments

Type IntentOptional Attributes Name
complex, intent(in), dimension (-ntgrid:,:,:) :: phi
complex, intent(in), dimension (-ntgrid:,:,:) :: apar
complex, intent(in), dimension (-ntgrid:,:,:) :: bpar
complex, intent(inout), dimension (-ntgrid:,:,:) :: fieldeq
complex, intent(inout), dimension (-ntgrid:,:,:) :: fieldeqa
complex, intent(inout), dimension (-ntgrid:,:,:) :: fieldeqp
logical, intent(in), optional :: local_only

public subroutine getfieldeq_nogath(phi, apar, bpar, fieldeq, fieldeqa, fieldeqp, local_only)

FIXME : Add documentation

Arguments

Type IntentOptional Attributes Name
complex, intent(in), dimension (-ntgrid:,:,:) :: phi
complex, intent(in), dimension (-ntgrid:,:,:) :: apar
complex, intent(in), dimension (-ntgrid:,:,:) :: bpar
complex, intent(inout), dimension (-ntgrid:,:,:) :: fieldeq
complex, intent(inout), dimension (-ntgrid:,:,:) :: fieldeqa
complex, intent(inout), dimension (-ntgrid:,:,:) :: fieldeqp
logical, intent(in), optional :: local_only

private subroutine getfieldeq1_nogath(phi, apar, bpar, antot, antota, antotp, fieldeq, fieldeqa, fieldeqp, local_only)

FIXME : Add documentation

Read more…

Arguments

Type IntentOptional Attributes Name
complex, intent(in), dimension (-ntgrid:,:,:) :: phi
complex, intent(in), dimension (-ntgrid:,:,:) :: apar
complex, intent(in), dimension (-ntgrid:,:,:) :: bpar
complex, intent(in), dimension (-ntgrid:,:,:) :: antot
complex, intent(in), dimension (-ntgrid:,:,:) :: antota
complex, intent(in), dimension (-ntgrid:,:,:) :: antotp
complex, intent(inout), dimension (-ntgrid:,:,:) :: fieldeq
complex, intent(inout), dimension (-ntgrid:,:,:) :: fieldeqa
complex, intent(inout), dimension (-ntgrid:,:,:) :: fieldeqp
logical, intent(in), optional :: local_only

public subroutine check_getan(antot, antota, antotp, tempantot, tempantota, tempantotp)

FIXME : Add documentation

Arguments

Type IntentOptional Attributes Name
complex, intent(inout), dimension (-ntgrid:ntgrid,ntheta0,naky) :: antot
complex, intent(inout), dimension (-ntgrid:ntgrid,ntheta0,naky) :: antota
complex, intent(inout), dimension (-ntgrid:ntgrid,ntheta0,naky) :: antotp
complex, intent(inout), dimension (-ntgrid:ntgrid,ntheta0,naky) :: tempantot
complex, intent(inout), dimension (-ntgrid:ntgrid,ntheta0,naky) :: tempantota
complex, intent(inout), dimension (-ntgrid:ntgrid,ntheta0,naky) :: tempantotp

private subroutine getan_nogath_from_dfn(g_in, antot, antota, antotp, local_only)

Getan_nogath has been substantially changed to enable gf_lo field calculations, it can now operate in 2 modes; using the standard integrate_species (integrate_species_sub in le_grids) when called from fields_local and gf_lo_integrate is false (which is teh default, or doing the integrate in place when called from fields_gf_local or from fields_local when gf_lo_integrate is true. Note, if this is called from fields_local and gf_lo_integrate is true then the calculation will be done locally but there is a function called after this has finished in fields_local that sends the data back (from gf_lo to g_lo layouts). When call with gf_lo_integrate = .true. this routine does a gather that converts the gnew array from g_lo data distribution to gf_lo data distribution and stores the result in gfarray. With gf_lo_integrate = .false. g_in is used instead and this is in g_lo data distribution.

Read more…

Arguments

Type IntentOptional Attributes Name
complex, intent(in), dimension (-ntgrid:, :, g_lo%llim_proc:) :: g_in
complex, intent(inout), dimension (-ntgrid:,:,:) :: antot
complex, intent(inout), dimension (-ntgrid:,:,:) :: antota
complex, intent(inout), dimension (-ntgrid:,:,:) :: antotp
logical, intent(in), optional :: local_only

public subroutine getan_nogath(antot, antota, antotp, local_only)

Calls getan_nogath_from_dfn to calculate antot arrays for current gnew value

Arguments

Type IntentOptional Attributes Name
complex, intent(inout), dimension (-ntgrid:,:,:) :: antot
complex, intent(inout), dimension (-ntgrid:,:,:) :: antota
complex, intent(inout), dimension (-ntgrid:,:,:) :: antotp
logical, intent(in), optional :: local_only

public subroutine calculate_potentials_from_nonadiabatic_dfn(f_in, phi, apar, bpar, gf_lo, local_only)

Calculates the potentials consistent with the passed nonadiabatic distribution function, f_in. Note this is not what GS2 usually evolves as g/gnew but the adjusted version.

Read more…

Arguments

Type IntentOptional Attributes Name
complex, intent(in), dimension(-ntgrid:, :, g_lo%llim_proc:) :: f_in
complex, intent(out), dimension(-ntgrid:, :, :) :: phi
complex, intent(out), dimension(-ntgrid:, :, :) :: apar
complex, intent(out), dimension(-ntgrid:, :, :) :: bpar
logical, intent(in), optional :: gf_lo
logical, intent(in), optional :: local_only

private subroutine setup_get_fields_direct_from_dfn_denominators(phi_denom, bpar_denom)

Precomputes constants used in the inversion of the field equations: gamtot * phi - gamtot1 * bpar = antot kperp2 * apar = antota beta/2 * gamtot1 * phi + (beta * gamtot2 + 1) * bpar = - beta * antotp

Read more…

Arguments

Type IntentOptional Attributes Name
real, intent(inout), dimension(:, :, :), allocatable :: phi_denom
real, intent(inout), dimension(:, :, :), allocatable :: bpar_denom

public subroutine get_fields_direct_from_dfn(g_in, phi, apar, bpar, gf_lo, local_only)

Inverts the field equations: gamtot * phi - gamtot1 * bpar = antot kperp2 * apar = antota beta/2 * gamtot1 * phi + (beta * gamtot2 + 1) * bpar = - beta * antotp

Read more…

Arguments

Type IntentOptional Attributes Name
complex, intent(in), dimension (:,:,:) :: g_in
complex, intent(out), dimension (-ntgrid:,:,:) :: phi
complex, intent(out), dimension (-ntgrid:,:,:) :: apar
complex, intent(out), dimension (-ntgrid:,:,:) :: bpar
logical, intent(in), optional :: gf_lo
logical, intent(in), optional :: local_only

public subroutine get_init_field(phi, apar, bpar, gf_lo)

Calls get_fields_direct_from_dfn to solve for fields consistent with current gnew

Arguments

Type IntentOptional Attributes Name
complex, intent(out), dimension (:,:,:) :: phi
complex, intent(out), dimension (:,:,:) :: apar
complex, intent(out), dimension (:,:,:) :: bpar
logical, intent(in), optional :: gf_lo

public subroutine get_field_inconsistency(g_in, phi_in, apar_in, bpar_in, phi_err, apar_err, bpar_err)

Calculates the potentials directly from the passed distribution function and compares the result to the passed potentials. Returns the maximum relative error for each potential.

Arguments

Type IntentOptional Attributes Name
complex, intent(in), dimension(:,:,:) :: g_in
complex, intent(in), dimension(:,:,:) :: phi_in
complex, intent(in), dimension(:,:,:) :: apar_in
complex, intent(in), dimension(:,:,:) :: bpar_in
real, intent(out) :: phi_err
real, intent(out) :: apar_err
real, intent(out) :: bpar_err

public subroutine dump_current_source_term(istep, phi, apar, bpar, phinew, aparnew, bparnew)

Routine to dump the current source term used in invert_rhs.

Read more…

Arguments

Type IntentOptional Attributes Name
integer, intent(in) :: istep
complex, intent(in), dimension (-ntgrid:,:,:) :: phi
complex, intent(in), dimension (-ntgrid:,:,:) :: apar
complex, intent(in), dimension (-ntgrid:,:,:) :: bpar
complex, intent(in), dimension (-ntgrid:,:,:) :: phinew
complex, intent(in), dimension (-ntgrid:,:,:) :: aparnew
complex, intent(in), dimension (-ntgrid:,:,:) :: bparnew

public subroutine dump_homogeneous_solution(force_passing)

Routine to dump the homogeneous solution

Arguments

Type IntentOptional Attributes Name
logical, intent(in), optional :: force_passing

private subroutine find_leftmost_link(iglo, iglo_left, ipleft)

FIXME : Add documentation

Arguments

Type IntentOptional Attributes Name
integer, intent(in) :: iglo
integer, intent(out) :: iglo_left
integer, intent(out) :: ipleft

private subroutine find_rightmost_link(iglo, iglo_right, ipright)

FIXME : Add documentation

Arguments

Type IntentOptional Attributes Name
integer, intent(in) :: iglo
integer, intent(out) :: iglo_right
integer, intent(out) :: ipright

public subroutine calculate_flux_surface_average(fl_avg, antot)

Calculate the flux surface average term for the adiabatic response.

Read more…

Arguments

Type IntentOptional Attributes Name
complex, intent(out), dimension (ntheta0, naky) :: fl_avg
complex, intent(in), dimension (-ntgrid:ntgrid,ntheta0,naky) :: antot

public subroutine set_dist_fn_config(dist_fn_config_in, source_config_in, dist_fn_species_config_in)

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

Arguments

Type IntentOptional Attributes Name
type(dist_fn_config_type), intent(in), optional :: dist_fn_config_in
type(source_config_type), intent(in), optional :: source_config_in
type(dist_fn_species_config_type), intent(in), optional, dimension(:), allocatable :: dist_fn_species_config_in

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

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

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

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

private subroutine read_source_config(self)

Reads in the source_knobs namelist and populates the member variables

Arguments

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

private subroutine write_source_config(self, unit)

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

Arguments

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

private subroutine reset_source_config(self)

Resets the config object to the initial empty state

Arguments

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

private subroutine broadcast_source_config(self)

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

Arguments

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

private subroutine read_dist_fn_species_config(self)

Reads in the dist_fn_species_knobs namelist and populates the member variables

Arguments

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

private subroutine write_dist_fn_species_config(self, unit)

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

Arguments

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

private subroutine reset_dist_fn_species_config(self)

Resets the config object to the initial empty state

Arguments

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

private subroutine broadcast_dist_fn_species_config(self)

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

Arguments

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