dist_fn_arrays Module

A container for the arrays that are used to store the distribution function among other things.

These need to be accessible at a lower dependency level than the dist_fn module itself. These arrays are allocated in the function dist_fn::allocate_arrays.


Contents


Variables

Type Visibility Attributes Name Initial
complex, public, dimension (:,:,:), allocatable :: g
complex, public, dimension (:,:,:), allocatable :: gnew
complex, public, dimension (:,:,:), allocatable :: g_restart_tmp
complex, public, dimension (:,:,:), allocatable :: g_work
complex, public, dimension (:,:,:), allocatable :: gexp_1
complex, public, dimension (:,:,:), allocatable :: gexp_2
complex, public, dimension (:,:,:), allocatable :: gexp_3
real, public, dimension(:), allocatable :: kx_shift
real, public, dimension(:), allocatable :: theta0_shift
real, public, dimension (:,:,:), allocatable :: vpa
real, public, dimension (:,:,:), allocatable :: vpac
real, public, dimension (:,:,:,:,:), allocatable :: vpa_gf
real, public, dimension (:,:,:,:), allocatable :: vperp2_gf
real, public, dimension (:,:), allocatable :: vperp2
real, public, dimension (:,:), allocatable :: aj0
real, public, dimension (:,:), allocatable :: aj1
real, public, dimension (:,:,:,:,:), allocatable :: aj0_gf
real, public, dimension (:,:,:,:,:), allocatable :: aj1_gf
complex, public, dimension (:,:,:,:,:), allocatable :: c_rate
complex, public, dimension (:,:,:), allocatable :: antot
complex, public, dimension (:,:,:), allocatable :: antota
complex, public, dimension (:,:,:), allocatable :: antotp
complex, public, dimension (:,:,:), allocatable :: fieldeq
complex, public, dimension (:,:,:), allocatable :: fieldeqa
complex, public, dimension (:,:,:), allocatable :: fieldeqp
type(g_adjust_direction_type), public, parameter :: to_g_gs2 = g_adjust_direction_type(.true.)
type(g_adjust_direction_type), public, parameter :: from_g_gs2 = g_adjust_direction_type(.false.)

Interfaces

public interface g_adjust

g_adjust transforms between representations of perturbed dist'n func'n. = g_wesson J0(Z) - q phi/T F_m where <> = gyroaverage g_gs2 = g_wesson - q phi/T J0(Z) F_m - m v_||^2/T B_||/B J1(Z)/Z F_m For numerical convenience the GS2 variable g uses the form g_gs2. g_wesson (see Wesson's book, Tokamaks) is often a more convenient form: e.g. for handling collisions, calculating v-space moments in real space.

To transform gnew from g_gs2 to g_wesson form: call g_adjust(gnew,phinew,bparnew,fphi,fbpar) or call g_adjust(gnew,phinew,bparnew, to_g_gs2 = .false.) or transform from gnew from g_wesson to g_gs2 form: call g_adjust(gnew,phinew,bparnew,-fphi,-fbpar) or call g_adjust(gnew,phinew,bparnew, to_g_gs2 = .true. ) CMR, 17/4/2012:

  • private subroutine g_adjust_floats(g, phi, bpar, facphi, facbpar)

    Transform between g_gs2 and g_wesson with direction indicated by passed floats [facphi] and [facbpar].

    Arguments

    Type IntentOptional Attributes Name
    complex, intent(inout), dimension (-ntgrid:,:,g_lo%llim_proc:) :: g
    complex, intent(in), dimension (-ntgrid:,:,:) :: phi
    complex, intent(in), dimension (-ntgrid:,:,:) :: bpar
    real, intent(in) :: facphi
    real, intent(in) :: facbpar
  • private subroutine g_adjust_direction(g, phi, bpar, direction)

    Transform between g_gs2 and g_wesson with direction indicated by passed logical [to_g_gs2].

    Arguments

    Type IntentOptional Attributes Name
    complex, intent(inout), dimension (:,:,:) :: g
    complex, intent(in), dimension (:,:,:) :: phi
    complex, intent(in), dimension (:,:,:) :: bpar
    type(g_adjust_direction_type), intent(in) :: direction

Derived Types

type, private ::  g_adjust_direction_type

Components

Type Visibility Attributes Name Initial
logical, private :: to_g_gs2

Functions

public pure function get_adjust(ig, it, ik, ie, is, iglo, facphi, facbpar, phi, bpar) result(adjust)

Return the offset between g and h at a specific set of indices

Arguments

Type IntentOptional Attributes Name
integer, intent(in) :: ig
integer, intent(in) :: it
integer, intent(in) :: ik
integer, intent(in) :: ie
integer, intent(in) :: is
integer, intent(in) :: iglo
real, intent(in) :: facphi
real, intent(in) :: facbpar
complex, intent(in), dimension(-ntgrid:, :, :) :: phi
complex, intent(in), dimension(-ntgrid:, :, :) :: bpar

Return Value complex

public pure function file_and_line_id(filename, line_no)

A small helper function which constructs and returns the string ' : '. Intended for use in producing the identifier string passed to the check routines of this module. Might be worth finding a better location for this generic utility.

Read more…

Arguments

Type IntentOptional Attributes Name
character(len=*), intent(in) :: filename
integer, intent(in) :: line_no

Return Value character(len=:), allocatable


Subroutines

private subroutine g_adjust_direction(g, phi, bpar, direction)

Transform between g_gs2 and g_wesson with direction indicated by passed logical [to_g_gs2].

Arguments

Type IntentOptional Attributes Name
complex, intent(inout), dimension (:,:,:) :: g
complex, intent(in), dimension (:,:,:) :: phi
complex, intent(in), dimension (:,:,:) :: bpar
type(g_adjust_direction_type), intent(in) :: direction

private subroutine g_adjust_floats(g, phi, bpar, facphi, facbpar)

Transform between g_gs2 and g_wesson with direction indicated by passed floats [facphi] and [facbpar].

Arguments

Type IntentOptional Attributes Name
complex, intent(inout), dimension (-ntgrid:,:,g_lo%llim_proc:) :: g
complex, intent(in), dimension (-ntgrid:,:,:) :: phi
complex, intent(in), dimension (-ntgrid:,:,:) :: bpar
real, intent(in) :: facphi
real, intent(in) :: facbpar

public subroutine check_g_bouncepoints(g, ik, it, il, ie, is, err, tol)

This routine checks trapped particle bounce conditions: g(thetab,1:ik,it,il,ie,is)=g(thetab,2:ik,it,il,ie,is) and flags fractional errors exceeding a threshold tolerance, tol. CMR, 3/10/2013:

Arguments

Type IntentOptional Attributes Name
complex, intent(in), dimension(-ntgrid:,:,g_lo%llim_proc:) :: g
integer, intent(in) :: ik
integer, intent(in) :: it
integer, intent(in) :: il
integer, intent(in) :: ie
integer, intent(in) :: is
real, intent(out) :: err
real, intent(in), optional :: tol

public subroutine set_h_zero(g, phi, bpar, iglo)

Assign $g$ a value corresponding to $h$ (g_wesson of CMR's note in g_adjust) of $h = 0$ in order to be consistent with g_adjust. The correct function call to set h = 0 is call set_h_zero(g, phi, bpar, iglo)

Read more…

Arguments

Type IntentOptional Attributes Name
complex, intent(inout), dimension (-ntgrid:, :, g_lo%llim_proc:) :: g
complex, intent(in), dimension (-ntgrid:, :, :) :: phi
complex, intent(in), dimension (-ntgrid:, :, :) :: bpar
integer, intent(in) :: iglo

public subroutine check_is_zero_in_forbidden_region(g_array, identifier)

Check if the passed distribution function shaped array is non-zero in the forbidden region. If it is then trigger an abort.

Read more…

Arguments

Type IntentOptional Attributes Name
complex, intent(in), dimension(-ntgrid:, :, g_lo%llim_proc:) :: g_array
character(len=*), intent(in), optional :: identifier

public subroutine check_are_bouncepoint_values_consistent(g_array, identifier, tolerance)

Check if the passed distribution function shaped array has the same value at bounce points for both signs of v||. This provides similar functionality to check_g_bouncepoints but is intended to offer a quieter approach which could be used more routinely (i.e. throughout a run).

Read more…

Arguments

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