abstract_geo_type Derived Type

type, public, abstract :: abstract_geo_type


Contents

Source Code


Components

Type Visibility Attributes Name Initial
character(len=:), public, allocatable :: type_name

Name of the specific implementation

logical, public :: initialised = .false.

Has this instance been initialised

logical, public :: has_full_theta_range = .false.

Does this implementation have the full or half theta grid? If only half then we assume up-down symmetry and use this to set gradients etc.

integer, public :: nr

Typically the number of radial and theta grid points.

integer, public :: nt

Typically the number of radial and theta grid points.

real, public :: psi_0
real, public :: psi_a
real, public :: B_T
real, public :: beta_0
real, public :: R_mag
real, public :: Z_mag
real, public :: aminor
real, public, allocatable, dimension(:,:) :: R_psi

2D map of co-ordinates to R, Z or B

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

2D map of co-ordinates to R, Z or B

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

2D map of co-ordinates to R, Z or B

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

2D maps of theta and eqpsi

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

2D maps of theta and eqpsi

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

Minor radius gradient in cylindrical coordinates

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

Theta gradient in cylindrical coordinates

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

B gradient in cylindrical coordinates

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

Minor radius gradient in Bishop coordinates

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

Theta gradient in Bishop coordinates

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

B gradient in Bishop coordinates

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

Equilibrium psi (not normalised) and pressure grids

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

Equilibrium psi (not normalised) and pressure grids

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

Normalised psi, fp, q, beta, diameter and R_centre values on grid

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

Normalised psi, fp, q, beta, diameter and R_centre values on grid

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

Normalised psi, fp, q, beta, diameter and R_centre values on grid

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

Normalised psi, fp, q, beta, diameter and R_centre values on grid

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

Normalised psi, fp, q, beta, diameter and R_centre values on grid

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

Normalised psi, fp, q, beta, diameter and R_centre values on grid


Type-Bound Procedures

procedure, public, :: initialise

  • public subroutine initialise(self, inputs, psi_0_out, psi_a_out, rmaj, B_T0, avgrmid)

    Arguments

    Type IntentOptional Attributes Name
    class(abstract_geo_type), intent(inout) :: self
    type(geo_input_type), intent(in) :: inputs
    real, intent(out) :: psi_0_out
    real, intent(out) :: psi_a_out
    real, intent(out) :: rmaj
    real, intent(out) :: B_T0
    real, intent(out) :: avgrmid

procedure(read_and_set_interface), public, deferred :: read_and_set

  • subroutine read_and_set_interface(self, inputs) Prototype

    Arguments

    Type IntentOptional Attributes Name
    class(abstract_geo_type), intent(inout) :: self
    type(geo_input_type), intent(in) :: inputs

procedure(noargs_interface), public, deferred :: finish_setup

  • subroutine noargs_interface(self) Prototype

    Arguments

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

procedure(noargs_interface), public, deferred :: finalise

  • subroutine noargs_interface(self) Prototype

    Arguments

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

procedure(rtheta_interface), public, deferred :: rfun

  • function rtheta_interface(self, r, theta) Prototype

    Arguments

    Type IntentOptional Attributes Name
    class(abstract_geo_type), intent(in) :: self
    real, intent(in) :: r
    real, intent(in) :: theta

    Return Value real

procedure(rtheta_interface), public, deferred :: psi

  • function rtheta_interface(self, r, theta) Prototype

    Arguments

    Type IntentOptional Attributes Name
    class(abstract_geo_type), intent(in) :: self
    real, intent(in) :: r
    real, intent(in) :: theta

    Return Value real

procedure(rtheta_interface), public, deferred :: zpos

  • function rtheta_interface(self, r, theta) Prototype

    Arguments

    Type IntentOptional Attributes Name
    class(abstract_geo_type), intent(in) :: self
    real, intent(in) :: r
    real, intent(in) :: theta

    Return Value real

procedure(rtheta_interface), public, deferred :: rpos

  • function rtheta_interface(self, r, theta) Prototype

    Arguments

    Type IntentOptional Attributes Name
    class(abstract_geo_type), intent(in) :: self
    real, intent(in) :: r
    real, intent(in) :: theta

    Return Value real

procedure(rp_interface), public, deferred :: diameter

  • function rp_interface(self, rp) Prototype

    Arguments

    Type IntentOptional Attributes Name
    class(abstract_geo_type), intent(in) :: self
    real, intent(in) :: rp

    Return Value real

procedure(rp_interface), public, deferred :: rcenter

  • function rp_interface(self, rp) Prototype

    Arguments

    Type IntentOptional Attributes Name
    class(abstract_geo_type), intent(in) :: self
    real, intent(in) :: rp

    Return Value real

procedure(pbar_interface), public, deferred :: betafun

  • function pbar_interface(self, pbar) Prototype

    Arguments

    Type IntentOptional Attributes Name
    class(abstract_geo_type), intent(in) :: self
    real, intent(in) :: pbar

    Return Value real

procedure(pbar_interface), public, deferred :: dpfun

  • function pbar_interface(self, pbar) Prototype

    Arguments

    Type IntentOptional Attributes Name
    class(abstract_geo_type), intent(in) :: self
    real, intent(in) :: pbar

    Return Value real

procedure(pbar_interface), public, deferred :: pfun

  • function pbar_interface(self, pbar) Prototype

    Arguments

    Type IntentOptional Attributes Name
    class(abstract_geo_type), intent(in) :: self
    real, intent(in) :: pbar

    Return Value real

procedure(pbar_interface), public, deferred :: qfun

  • function pbar_interface(self, pbar) Prototype

    Arguments

    Type IntentOptional Attributes Name
    class(abstract_geo_type), intent(in) :: self
    real, intent(in) :: pbar

    Return Value real

procedure(pbar_interface), public, deferred :: dbtori

  • function pbar_interface(self, pbar) Prototype

    Arguments

    Type IntentOptional Attributes Name
    class(abstract_geo_type), intent(in) :: self
    real, intent(in) :: pbar

    Return Value real

procedure(pbar_interface), public, deferred :: btori

  • function pbar_interface(self, pbar) Prototype

    Arguments

    Type IntentOptional Attributes Name
    class(abstract_geo_type), intent(in) :: self
    real, intent(in) :: pbar

    Return Value real

procedure, public, :: gradient

Calculate the derivative of rp w.r.t. R and Z and return the modulus sqrt(drp/dR ^ 2 + drp/dZ^2). I.e. return |grad rp|. Parameters are: - rgrid: Submodule radial grid (r_circ for EFIT, rp otherwise) - theta: grid of theta - gradf(:,1): |grad psi| - gradf(:,2): 0.0 - char: if char = 'R', return |grad pressure| instead - char: if char = 'T', then return theta gradient in bishop form - gradf(:,1): (dtheta/dZ d rp/dR - dtheta/dR drp/dZ)/ |grad rp| - gradf(:,2): (dtheta/dR d rp/dR + dtheta/dZ drp/dZ)/ |grad rp| - rp: value of rp on the flux surface where we want the grad - nth: number of theta points - ntgrid: lower index of theta array is -ntgrid

  • public subroutine gradient(self, rgrid, theta, grad, char, rp, nth_used, ntm, use_bishop)

    Arguments

    Type IntentOptional Attributes Name
    class(abstract_geo_type), intent(in) :: self
    real, intent(in), dimension (-ntm:) :: rgrid
    real, intent(in), dimension (-ntm:) :: theta
    real, intent(out), dimension (-ntm:,:) :: grad
    character(len=1), intent(in) :: char
    real, intent(in) :: rp
    integer, intent(in) :: nth_used
    integer, intent(in) :: ntm
    logical, intent(in) :: use_bishop

procedure(eqitem_interface), public, deferred :: eqitem

  • function eqitem_interface(self, r_in, theta_in, f, char) result(fstar) Prototype

    Arguments

    Type IntentOptional Attributes Name
    class(abstract_geo_type), intent(in) :: self
    real, intent(in) :: r_in
    real, intent(in) :: theta_in
    real, intent(in), dimension(:, :) :: f
    character(len=1), intent(in) :: char

    Return Value real

procedure, public, :: calculate_gradients

  • public pure subroutine calculate_gradients(self)

    Given theta, R, Z, B and psi on 2D grids calculate the index space derivatives in the two grid dimensions and use these to find gradients in cartesian and Bishop space.

    Arguments

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

procedure, public, :: rhofun => rhofun_null

  • public function rhofun_null(self, pbar) result(rhofun)

    Arguments

    Type IntentOptional Attributes Name
    class(abstract_geo_type), intent(in) :: self
    real, intent(in) :: pbar

    Return Value real

procedure, public, :: derm

  • public pure subroutine derm(self, f, dfm, char)

    Calculate the derivative of f w.r.t to the radial and poloidal indexes (i.e. calculate the finite differences without dividing by delta psi and delta theta). - dfm(:,:,1) is the psi derivative - dfm(:,:,2) is the theta derivative - char specifies the periodicity in theta - 'E', 'O' mean continuous at theta = +/- pi - 'T' means a jump of 2 pi at theta = +/- pi

    Arguments

    Type IntentOptional Attributes Name
    class(abstract_geo_type), intent(in) :: self
    real, intent(in), dimension(:,:) :: f
    real, intent(out), dimension(:,:,:) :: dfm
    character(len=1), intent(in) :: char

procedure, public, :: invR

  • public function invR(self, r, theta)

    Arguments

    Type IntentOptional Attributes Name
    class(abstract_geo_type), intent(in) :: self
    real, intent(in) :: r
    real, intent(in) :: theta

    Return Value real

procedure, public, :: eqdbish

  • public pure subroutine eqdbish(self, dcart, dpcart, dbish)

    Convert gradients of a function f w.r.t. R,Z into bishop form. Note that dbish(1, :, :) is not valid

    Arguments

    Type IntentOptional Attributes Name
    class(abstract_geo_type), intent(in) :: self
    real, intent(in), dimension(:, :, :) :: dcart

    dcart(:,:,1) is gradient of f w.r.t. R; dcart(:,:,2) is gradient of f w.r.t. Z

    real, intent(in), dimension(:, :, :) :: dpcart

    dcart(:,:,1) is gradient of f w.r.t. R; dcart(:,:,2) is gradient of f w.r.t. Z

    real, intent(out), dimension(:, :, :) :: dbish

    dbish(:,:,1) is set to (df/dR dpsi/dR + df/dZ dpsi/dZ)/|grad psi|; dbish(:,:,2) is set to (-df/dR dpsi/dZ + df/dZ dpsi/dR)/|grad psi|. Note that in the special case where f=psi: dbish(:,:,1) is |grad psi|; dbish(:,:,2) is 0

procedure, public, :: eqdcart

  • public pure subroutine eqdcart(self, dfm, drm, dzm, dfcart)

    Converts derivatives w.r.t. (psi_index,theta_index) to derivatives w.r.t. (R,Z). Note that dfcart(1, :, :) is not valid

    Arguments

    Type IntentOptional Attributes Name
    class(abstract_geo_type), intent(in) :: self
    real, intent(in), dimension (:,:,:) :: dfm

    dfm(:,:,1) is deriv w.r.t. psi_index (i.e. (df/dpsi)_theta * delta psi); dfm(:,:,2) is deriv w.r.t. theta_index

    real, intent(in), dimension (:,:,:) :: drm

    dfm(:,:,1) is deriv w.r.t. psi_index (i.e. (df/dpsi)_theta * delta psi); dfm(:,:,2) is deriv w.r.t. theta_index

    real, intent(in), dimension (:,:,:) :: dzm

    dfm(:,:,1) is deriv w.r.t. psi_index (i.e. (df/dpsi)_theta * delta psi); dfm(:,:,2) is deriv w.r.t. theta_index

    real, intent(out), dimension (:,:,:) :: dfcart

    dfcart(:,:,1) is deriv w.r.t. R; dfcart(:,:,2) is deriv w.r.t. Z

procedure, public, :: dealloc_common_arrays

procedure, public, :: alloc_common_arrays

procedure, public, :: hahm_burrell

  • public subroutine hahm_burrell(self, a)

    FIXME : Add documentation

    Arguments

    Type IntentOptional Attributes Name
    class(abstract_geo_type), intent(in) :: self
    real, intent(in) :: a

procedure, public, :: dealloc_arrays

procedure, public, :: alloc_arrays

procedure, public, :: alloc_special_arrays => alloc_special_arrays_null

procedure, public, :: dealloc_special_arrays => dealloc_special_arrays_null

Source Code

  type, abstract :: abstract_geo_type
     !> Name of the specific implementation
     character(len=:), allocatable :: type_name
     !> Has this instance been initialised
     logical :: initialised = .false.
     !> Does this implementation have the full or half theta grid? If only half
     !> then we assume up-down symmetry and use this to set gradients etc.
     logical :: has_full_theta_range = .false.
     !> Typically the number of radial and theta grid points.
     integer :: nr, nt
     real :: psi_0, psi_a, B_T, beta_0, R_mag, Z_mag, aminor
     !> 2D map of co-ordinates to R, Z or B
     real, allocatable, dimension(:,:) :: R_psi, Z_psi, B_psi
     !> 2D maps of theta and eqpsi
     real, allocatable, dimension(:,:) :: eqth, eqpsi_2d
     !> Minor radius gradient in cylindrical coordinates \((\hat{e}_R,
     !> \hat{e}_Z, \hat{e}_\zeta)\)
     real, allocatable, dimension (:,:,:) :: dpcart
     !> Theta gradient in cylindrical coordinates \((\hat{e}_R, \hat{e}_Z, \hat{e}_\zeta)\)
     real, allocatable, dimension (:,:,:) :: dtcart
     !> B gradient in cylindrical coordinates \((\hat{e}_R, \hat{e}_Z, \hat{e}_\zeta)\)
     real, allocatable, dimension (:,:,:) :: dbcart
     !> Minor radius gradient in Bishop coordinates \((\hat{e}_{r_\psi}, \hat{e}_l, \hat{e}_\zeta)\)
     real, allocatable, dimension (:,:,:) :: dpbish
     !> Theta gradient in Bishop coordinates \((\hat{e}_{r_\psi}, \hat{e}_l, \hat{e}_\zeta)\)
     real, allocatable, dimension (:,:,:) :: dtbish
     !> B gradient in Bishop coordinates \((\hat{e}_{r_\psi}, \hat{e}_l, \hat{e}_\zeta)\)
     real, allocatable, dimension (:,:,:) :: dbbish
     !> Equilibrium psi (not normalised) and pressure grids
     real, allocatable, dimension(:) :: eqpsi, pressure
     !> Normalised psi, fp, q, beta, diameter and R_centre values on grid
     real, allocatable, dimension(:) :: psi_bar, fp, qsf, beta, diam, rc
   contains
     procedure :: initialise
     procedure(read_and_set_interface), deferred :: read_and_set
     procedure(noargs_interface), deferred :: finalise, finish_setup
     procedure(rtheta_interface), deferred :: rpos, zpos, psi, rfun
     procedure(rp_interface), deferred :: rcenter, diameter
     procedure(pbar_interface), deferred :: btori, dbtori, qfun, pfun, dpfun, betafun
     !> Calculate the derivative of rp w.r.t. R and Z and return
     !> the modulus sqrt(drp/dR ^ 2 + drp/dZ^2). I.e. return |grad rp|.
     !> Parameters are:
     !>   - rgrid: Submodule radial grid (r_circ for EFIT, rp otherwise)
     !>   - theta: grid of theta
     !>   - gradf(:,1): |grad psi|
     !>   - gradf(:,2): 0.0
     !>   - char: if char = 'R', return |grad pressure| instead
     !>   - char: if char = 'T', then return theta gradient in bishop form
     !>    - gradf(:,1): (dtheta/dZ d rp/dR - dtheta/dR drp/dZ)/ |grad rp|
     !>    - gradf(:,2): (dtheta/dR d rp/dR + dtheta/dZ drp/dZ)/ |grad rp|
     !>   - rp: value of rp on the flux surface where we want the grad
     !>   - nth: number of theta points
     !>   - ntgrid: lower index of theta array is -ntgrid
     procedure :: gradient
     procedure(eqitem_interface), deferred :: eqitem
     procedure :: calculate_gradients
     procedure :: eqdcart, eqdbish, invR, derm, rhofun => rhofun_null
     procedure :: alloc_common_arrays, dealloc_common_arrays
     procedure :: alloc_arrays, dealloc_arrays, hahm_burrell
     procedure :: alloc_special_arrays => alloc_special_arrays_null
     procedure :: dealloc_special_arrays => dealloc_special_arrays_null
  end type abstract_geo_type