geo_utils Module

A module to provide utilities used in geometry calculations. Mainly to provide an abstract type used as a base for specific geometry implementations.


Uses


Contents


Variables

Type Visibility Attributes Name Initial
integer, public, parameter :: EQFILE_LENGTH = 800
integer, public, parameter :: geo_type_miller = 0
integer, public, parameter :: geo_type_global = 1
integer, public, parameter :: geo_type_generalized_elongation = 2
integer, public, parameter :: geo_type_fourier_series = 3
integer, public, parameter :: geo_type_miller_extended_harmonic = 4
integer, public, parameter :: mxh_max_moments = 5

Maximum number of moments for the Miller Extended Harmonic equilbrium


Interfaces

public interface flux_surface_type

  • public function new_flux_surface_type(geoType, Rmaj, R_geo, r, dr, aSurf, sHorz, sVert, delm, deln, delmp, delnp, thm, thn, q, shat, nt, mMode, nMode, n_mxh, c0_mxh, c_mxh, s_mxh, dc_mxh_dr, ds_mxh_dr) result(self)

    Arguments

    Type IntentOptional Attributes Name
    integer, intent(in) :: geoType
    real, intent(in), optional :: Rmaj
    real, intent(in), optional :: R_geo
    real, intent(in), optional :: r
    real, intent(in), optional :: dr
    real, intent(in), optional :: aSurf
    real, intent(in), optional :: sHorz
    real, intent(in), optional :: sVert
    real, intent(in), optional :: delm
    real, intent(in), optional :: deln
    real, intent(in), optional :: delmp
    real, intent(in), optional :: delnp
    real, intent(in), optional :: thm
    real, intent(in), optional :: thn
    real, intent(in), optional :: q
    real, intent(in), optional :: shat
    integer, intent(in), optional :: nt
    integer, intent(in), optional :: mMode
    integer, intent(in), optional :: nMode
    integer, intent(in), optional :: n_mxh
    real, intent(in), optional :: c0_mxh
    real, intent(in), optional, dimension(mxh_max_moments) :: c_mxh
    real, intent(in), optional, dimension(mxh_max_moments) :: s_mxh
    real, intent(in), optional, dimension(mxh_max_moments) :: dc_mxh_dr
    real, intent(in), optional, dimension(mxh_max_moments) :: ds_mxh_dr

    Return Value type(flux_surface_type)

interface

  • public function rtheta_interface(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

interface

  • public function rp_interface(self, rp)

    Arguments

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

    Return Value real

interface

  • public function pbar_interface(self, pbar)

    Arguments

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

    Return Value real

interface

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

    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

interface

  • public subroutine read_and_set_interface(self, inputs)

    Arguments

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

interface

  • public subroutine noargs_interface(self)

    Arguments

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

Derived Types

type, public ::  flux_surface_type

Helper type to wrap up some flux surface specific variables for analytic equilibrium type.

Components

Type Visibility Attributes Name Initial
real, public :: Rmaj

Flux surface major radius, , input variable: Rmaj

real, public :: R_geo

Location of reference magnetic field, , input variable: R_geo

real, public :: r

Minor radius, , input variable: rhoc

real, public :: dr

Step size for radial derivatives, , input variable: delrho

real, public :: aSurf

Minor radius of shaping surface, , input variable: aSurf

real, public :: sHorz

Horizontal Shafranov shift, , input variable: shift, Raxis

real, public :: sVert

Vertical Shafranov shift, , input variable: shiftVert, Zaxis

real, public :: delm

First shaping mode strength, , input variable: akappa, delta2, deltam

real, public :: deln

Second shaping mode strength, , input variable: tri, delta3, deltan

real, public :: delmp

First shaping mode derivative, , input variable: akappri, deltampri

real, public :: delnp

Second shaping mode derivative, , input variable: tripri, deltanpri

real, public :: thm

First shaping mode tilt angle, , input variable: thetak, theta2, thetam

real, public :: thn

Second shaping mode tilt angle, , input variable: thetad, theta2, thetan

real, public :: q

Safety factor, , input variable: qinp

real, public :: shat

Magnetic shear, , input variable: s_hat_input

integer, public :: nt

Number of points in theta, input variable: ntheta

integer, public :: geoType

Geometry specification type, input variable: geoType

integer, public :: mMode

The first poloidal mode number, input variable: mMode

integer, public :: nMode

The second poloidal mode number, input variable: nMode

integer, public :: n_mxh

Number of moments for MXH equilibrium, input variable: n_mxh

real, public :: c0_mxh

Zeroth cosine moment for MXH equilibrium, input variable: c0_mxh

real, public, dimension(mxh_max_moments) :: c_mxh

Cosine moments for MXH equilibrium, input variable: c_mxh

real, public, dimension(mxh_max_moments) :: s_mxh

Sine moments for MXH equilibrium, input variable: s_mxh

real, public, dimension(mxh_max_moments) :: dc_mxh_dr

Radial derivatives of cosine moments for MXH equilibrium, input variable: dc_mxh_dr

real, public, dimension(mxh_max_moments) :: ds_mxh_dr

Radial derivatives of sine moments for MXH equilibrium, input variable: ds_mxh_dr

Constructor

public function new_flux_surface_type (geoType, Rmaj, R_geo, r, dr, aSurf, sHorz, sVert, delm, deln, delmp, delnp, thm, thn, q, shat, nt, mMode, nMode, n_mxh, c0_mxh, c_mxh, s_mxh, dc_mxh_dr, ds_mxh_dr)

type, public ::  geo_input_type

A derived type used to hold the inputs to the geo initialisation routine. By encapsulating all possible inputs in this type we can avoid having to have multiple initialisation interfaces which all types have to define.

Components

Type Visibility Attributes Name Initial
character(len=EQFILE_LENGTH), public :: eqfile = 'EQFILE_NOT_SET'

Filename to read in for equilibria based on reading a file

integer, public :: big = -1

Upsampling factor used in efit, dfit and gs2d cases

character(len=EQFILE_LENGTH), public :: eqnormfile = ' EQNORMFILE_NOT_SET'

File containing normalisation factors for dfit

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

Target theta grid used for ideq

type(flux_surface_type), public :: surf

Used for analytic local equiliria

real, public :: thShift

Theta shift used in analytic local equiliria

type, public ::  abstract_geo_type

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 Subroutine
procedure (read_and_set_interface) , public :: read_and_set
procedure (noargs_interface) , public :: finish_setup
procedure (noargs_interface) , public :: finalise
procedure (rtheta_interface) , public :: rfun
procedure (rtheta_interface) , public :: psi
procedure (rtheta_interface) , public :: zpos
procedure (rtheta_interface) , public :: rpos
procedure (rp_interface) , public :: diameter
procedure (rp_interface) , public :: rcenter
procedure (pbar_interface) , public :: betafun
procedure (pbar_interface) , public :: dpfun
procedure (pbar_interface) , public :: pfun
procedure (pbar_interface) , public :: qfun
procedure (pbar_interface) , public :: dbtori
procedure (pbar_interface) , public :: btori
procedure , public , :: gradient Subroutine

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 (eqitem_interface) , public :: eqitem
procedure , public , :: calculate_gradients Subroutine
procedure , public , :: rhofun => rhofun_null Function
procedure , public , :: derm Subroutine
procedure , public , :: invR Function
procedure , public , :: eqdbish Subroutine
procedure , public , :: eqdcart Subroutine
procedure , public , :: dealloc_common_arrays Subroutine
procedure , public , :: alloc_common_arrays Subroutine
procedure , public , :: hahm_burrell Subroutine
procedure , public , :: dealloc_arrays Subroutine
procedure , public , :: alloc_arrays Subroutine
procedure , public , :: alloc_special_arrays => alloc_special_arrays_null Subroutine
procedure , public , :: dealloc_special_arrays => dealloc_special_arrays_null Subroutine

type, public, extends(abstract_geo_type) ::  abstract_eqfile_geo_type

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

character(len=EQFILE_LENGTH), public :: filename
type(spline), public :: btori_spl
type(spline), public :: qsf_spl
type(spline), public :: pressure_spl
type(spline), public :: beta_spl
type(spline), public :: diam_spl
type(spline), public :: rcenter_spl

Type-Bound Procedures

procedure , public , :: initialise Subroutine
procedure (read_and_set_interface) , public :: read_and_set
procedure , public , :: gradient Subroutine

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 , public , :: calculate_gradients Subroutine
procedure , public , :: rhofun => rhofun_null Function
procedure , public , :: derm Subroutine
procedure , public , :: invR Function
procedure , public , :: eqdbish Subroutine
procedure , public , :: eqdcart Subroutine
procedure , public , :: dealloc_common_arrays Subroutine
procedure , public , :: alloc_common_arrays Subroutine
procedure , public , :: hahm_burrell Subroutine
procedure , public , :: dealloc_arrays Subroutine
procedure , public , :: alloc_arrays Subroutine
procedure , public , :: alloc_special_arrays => alloc_special_arrays_null Subroutine
procedure , public , :: dealloc_special_arrays => dealloc_special_arrays_null Subroutine
procedure , public , :: finalise => finalise_eqfile Subroutine
procedure , public , :: finish_setup => finish_setup_eqfile Subroutine
procedure , public , :: setup_special_splines => setup_special_splines_eqfile_null Subroutine
procedure , public , :: delete_special_splines => delete_special_splines_eqfile_null Subroutine
procedure , public , :: setup_splines => setup_splines_eqfile Subroutine
procedure , public , :: delete_splines => delete_splines_eqfile Subroutine
procedure , public , :: dbtori => dbtori_eqfile Function
procedure , public , :: btori => btori_eqfile Function
procedure , public , :: betafun => betafun_eqfile Function
procedure , public , :: qfun => qfun_eqfile Function
procedure , public , :: dpfun => dpfun_eqfile Function
procedure , public , :: pfun => pfun_eqfile Function
procedure , public , :: rcenter => rcenter_eqfile Function
procedure , public , :: diameter => diameter_eqfile Function
procedure , public , :: rfun => psi_eqfile Function
procedure , public , :: psi => psi_eqfile Function
procedure , public , :: zpos => zpos_eqfile Function
procedure , public , :: rpos => rpos_eqfile Function
procedure , public , :: eqitem => eqitem_eqfile Function

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

character(len=EQFILE_LENGTH), public :: filename
type(spline), public :: btori_spl
type(spline), public :: qsf_spl
type(spline), public :: pressure_spl
type(spline), public :: beta_spl
type(spline), public :: diam_spl
type(spline), public :: rcenter_spl
integer, public :: nw
integer, public :: nh
real, public, allocatable, dimension(:) :: thetab
real, public, allocatable, dimension(:) :: r_bound
real, public, allocatable, dimension(:) :: eq_R
real, public, allocatable, dimension(:) :: eq_Z
type(periodic_spline), public :: rbound_spl

Type-Bound Procedures

procedure , public , :: initialise Subroutine
procedure (read_and_set_interface) , public :: read_and_set
procedure , public , :: gradient Subroutine

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 , public , :: calculate_gradients Subroutine
procedure , public , :: rhofun => rhofun_null Function
procedure , public , :: invR Function
procedure , public , :: eqdbish Subroutine
procedure , public , :: eqdcart Subroutine
procedure , public , :: dealloc_common_arrays Subroutine
procedure , public , :: alloc_common_arrays Subroutine
procedure , public , :: hahm_burrell Subroutine
procedure , public , :: dealloc_arrays Subroutine
procedure , public , :: alloc_arrays Subroutine
procedure , public , :: alloc_special_arrays => alloc_special_arrays_null Subroutine
procedure , public , :: dealloc_special_arrays => dealloc_special_arrays_null Subroutine
procedure , public , :: finalise => finalise_eqfile Subroutine
procedure , public , :: finish_setup => finish_setup_eqfile Subroutine
procedure , public , :: setup_special_splines => setup_special_splines_eqfile_null Subroutine
procedure , public , :: delete_special_splines => delete_special_splines_eqfile_null Subroutine
procedure , public , :: setup_splines => setup_splines_eqfile Subroutine
procedure , public , :: delete_splines => delete_splines_eqfile Subroutine
procedure , public , :: dbtori => dbtori_eqfile Function
procedure , public , :: btori => btori_eqfile Function
procedure , public , :: betafun => betafun_eqfile Function
procedure , public , :: qfun => qfun_eqfile Function
procedure , public , :: dpfun => dpfun_eqfile Function
procedure , public , :: pfun => pfun_eqfile Function
procedure , public , :: rcenter => rcenter_eqfile Function
procedure , public , :: shared_setup => shared_setup_cart Subroutine
procedure , public , :: zbrent Function
procedure , public , :: rfun Function
procedure , public , :: bound => bound_eqfile_cart Function
procedure , public , :: zpos => zpos_eqfile_cart Function
procedure , public , :: rpos => rpos_eqfile_cart Function
procedure , public , :: psi => psi_eqfile_cart Function
procedure , public , :: diameter => diameter_eqfile_cart Function
procedure , public , :: eqitem => eqitem_cart Function
procedure , public , :: derm => derm_cart Subroutine

Functions

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

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

public function eqitem_eqfile(self, r_in, theta_in, f, char) result(fstar)

Calculates fstar which is f interpolated at the location (r,theta). Here r is the normalised poloidal flux coordinate rp (= psi_pN + psi_0N) and theta_in is theta. f is a grid of values of f as a function of psi_p,theta First we find the radial and theta indices bounding our requested point and we then interpolate within the bound rectangle.

Arguments

Type IntentOptional Attributes Name
class(abstract_eqfile_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

public function btori_eqfile(self, pbar) result(btori)

Arguments

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

Return Value real

public function dbtori_eqfile(self, pbar) result(dbtori)

at the given normalised

Arguments

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

Return Value real

public function qfun_eqfile(self, pbar) result(qfun)

Arguments

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

Return Value real

public function pfun_eqfile(self, pbar) result(pfun)

Arguments

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

Return Value real

public function dpfun_eqfile(self, pbar) result(dpfun)

Arguments

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

Return Value real

public function diameter_eqfile(self, rp) result(diameter)

Return the diameter of the flux surface at a given major radius

Arguments

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

Return Value real

public function rcenter_eqfile(self, rp) result(rcenter)

Return the major radius of the centre of a given flux surface

Arguments

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

Return Value real

public function psi_eqfile(self, r, theta) result(psi)

Arguments

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

Return Value real

public function betafun_eqfile(self, pbar) result(betafun)

Arguments

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

Return Value real

public function rpos_eqfile(self, r, theta) result(rpos)

Arguments

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

Return Value real

public function zpos_eqfile(self, r, theta) result(zpos)

Arguments

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

Return Value real

public function eqitem_cart(self, r_in, theta_in, f, char) result(fstar)

fstar is f(R,Z) interpolated at the values (r,thetain). The parameter r is the distance to the magnetic axis.

Arguments

Type IntentOptional Attributes Name
class(abstract_eqfile_cart_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

public pure function find_lower_bound(val, array, default) result(bound)

Arguments

Type IntentOptional Attributes Name
real, intent(in) :: val
real, intent(in), dimension(:) :: array
integer, intent(in) :: default

Return Value integer

public pure function bilinear_interpolate(f, dim_1, dim_2, istar, jstar, d1, d2) result(fstar)

use opposite area stencil to interpolate to point bound by [istar,istar+1] and [jstar, jstar + 1].

Arguments

Type IntentOptional Attributes Name
real, intent(in), dimension(:, :) :: f
real, intent(in), dimension(:) :: dim_1
real, intent(in), dimension(:) :: dim_2
integer, intent(in) :: istar
integer, intent(in) :: jstar
real, intent(in) :: d1
real, intent(in) :: d2

Return Value real

public function bound_eqfile_cart(self, theta) result(bound)

Find the value of the major radius on the plasma boundary at given geometric theta.

Arguments

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

Return Value real

public pure function rpos_eqfile_cart(self, r, theta) result(rpos)

Arguments

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

Return Value real

public pure function zpos_eqfile_cart(self, r, theta) result(zpos)

Arguments

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

Return Value real

public function psi_eqfile_cart(self, r, theta) result(psi)

Arguments

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

Return Value real

public function diameter_eqfile_cart(self, rp) result(diameter)

Arguments

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

Return Value real

public elemental function mod2pi(theta)

Put theta into the range

Arguments

Type IntentOptional Attributes Name
real, intent(in) :: theta

Return Value real

public function rfun(self, r, theta)

Returns the distance to the magnetic axis as a function of rp (the normalised poloidal flux variable) and theta.

Arguments

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

Return Value real

public function zbrent(self, x1, x2, rootval, thetroot, tol)

FIXME : Add documentation

Arguments

Type IntentOptional Attributes Name
class(abstract_eqfile_cart_geo_type), intent(in) :: self
real, intent(in) :: x1
real, intent(in) :: x2
real, intent(in) :: rootval
real, intent(in) :: thetroot
real, intent(in) :: tol

Return Value real

public function new_flux_surface_type(geoType, Rmaj, R_geo, r, dr, aSurf, sHorz, sVert, delm, deln, delmp, delnp, thm, thn, q, shat, nt, mMode, nMode, n_mxh, c0_mxh, c_mxh, s_mxh, dc_mxh_dr, ds_mxh_dr) result(self)

Arguments

Type IntentOptional Attributes Name
integer, intent(in) :: geoType
real, intent(in), optional :: Rmaj
real, intent(in), optional :: R_geo
real, intent(in), optional :: r
real, intent(in), optional :: dr
real, intent(in), optional :: aSurf
real, intent(in), optional :: sHorz
real, intent(in), optional :: sVert
real, intent(in), optional :: delm
real, intent(in), optional :: deln
real, intent(in), optional :: delmp
real, intent(in), optional :: delnp
real, intent(in), optional :: thm
real, intent(in), optional :: thn
real, intent(in), optional :: q
real, intent(in), optional :: shat
integer, intent(in), optional :: nt
integer, intent(in), optional :: mMode
integer, intent(in), optional :: nMode
integer, intent(in), optional :: n_mxh
real, intent(in), optional :: c0_mxh
real, intent(in), optional, dimension(mxh_max_moments) :: c_mxh
real, intent(in), optional, dimension(mxh_max_moments) :: s_mxh
real, intent(in), optional, dimension(mxh_max_moments) :: dc_mxh_dr
real, intent(in), optional, dimension(mxh_max_moments) :: ds_mxh_dr

Return Value type(flux_surface_type)


Subroutines

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

public pure subroutine alloc_arrays(self)

Arguments

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

public pure subroutine dealloc_arrays(self)

Arguments

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

public pure subroutine alloc_special_arrays_null(self)

Arguments

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

public pure subroutine dealloc_special_arrays_null(self)

Arguments

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

public pure subroutine alloc_common_arrays(self)

Arguments

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

public pure subroutine dealloc_common_arrays(self)

Arguments

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

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

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

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

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

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

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

public subroutine setup_splines_eqfile(self)

Arguments

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

public subroutine delete_splines_eqfile(self)

Arguments

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

public subroutine setup_special_splines_eqfile_null(self)

Arguments

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

public subroutine delete_special_splines_eqfile_null(self)

Arguments

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

public subroutine finalise_eqfile(self)

Arguments

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

public subroutine finish_setup_eqfile(self)

Arguments

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

public pure subroutine derm_cart(self, f, dfm, char)

Calculate the derivative of f w.r.t. R, Z - dfm(:,:,1) is deriv w.r.t. R - dfm(:,:,2) is deriv w.r.t. Z

Arguments

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

public subroutine shared_setup_cart(self, nw_in, nh_in, spsi_bar, sefit_R, sefit_Z, f, p, q, sefit_psi, nbbbs, rbbbs, zbbbs, bcentr, rleft, rwid, zoffset, zhei, big, calc_aminor)

Arguments

Type IntentOptional Attributes Name
class(abstract_eqfile_cart_geo_type), intent(inout) :: self
integer, intent(in) :: nw_in
integer, intent(in) :: nh_in
real, intent(in), dimension(:) :: spsi_bar
real, intent(in), dimension(:) :: sefit_R
real, intent(in), dimension(:) :: sefit_Z
real, intent(in), dimension(:) :: f
real, intent(in), dimension(:) :: p
real, intent(in), dimension(:) :: q
real, intent(in), dimension(:, :) :: sefit_psi
integer, intent(in) :: nbbbs
real, intent(inout), dimension(:) :: rbbbs
real, intent(inout), dimension(:) :: zbbbs
real, intent(in) :: bcentr
real, intent(in) :: rleft
real, intent(in) :: rwid
real, intent(in) :: zoffset
real, intent(in) :: zhei
integer, intent(in) :: big
logical, intent(in) :: calc_aminor

public subroutine a_minor(r, z, Z_mag, a)

FIXME : Add documentation | Designed for eeq/gs2deq only

Arguments

Type IntentOptional Attributes Name
real, intent(in), dimension(:) :: r
real, intent(in), dimension(:) :: z
real, intent(in) :: Z_mag
real, intent(out) :: a

public pure subroutine sort(a, b, c, d)

FIXME : Add documentation

Read more…

Arguments

Type IntentOptional Attributes Name
real, intent(inout), dimension(:) :: a
real, intent(inout), dimension(:) :: b
real, intent(inout), dimension(:) :: c
real, intent(inout), dimension(:) :: d