eeq Module

This module is a submodule of geometry which handles reading from the ascii EQDSK format output by EFIT, but also now by other codes. This file contains psi on an R,Z grid, as well as other quantities such as q (safety factor), I (a.k.a. f) and p (pressure) on a psi grid.

The normalising field is set to the field on axis; the normalising length is set to the half-diameter of the LCFS.


Uses


Contents


Derived Types

type, private, extends(abstract_eqfile_cart_geo_type) ::  eeq_base_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
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 , :: finalise => finalise_eqfile Subroutine
procedure , public , :: finish_setup => finish_setup_eqfile 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 , :: 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
procedure , public , :: delete_special_splines Subroutine
procedure , public , :: setup_special_splines Subroutine
procedure , public , :: dealloc_special_arrays Subroutine
procedure , public , :: rcenter Function

type, public, extends(eeq_base_type) ::  eeq_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
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 , 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 , :: finalise => finalise_eqfile Subroutine
procedure , public , :: finish_setup => finish_setup_eqfile 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 , :: 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
procedure , public , :: delete_special_splines Subroutine
procedure , public , :: setup_special_splines Subroutine
procedure , public , :: dealloc_special_arrays Subroutine
procedure , public , :: rcenter Function
procedure , public , :: read_and_set => efit_read_and_set Subroutine

type, public, extends(eeq_base_type) ::  gs2d_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
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 , 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 , :: finalise => finalise_eqfile Subroutine
procedure , public , :: finish_setup => finish_setup_eqfile 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 , :: 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
procedure , public , :: delete_special_splines Subroutine
procedure , public , :: setup_special_splines Subroutine
procedure , public , :: dealloc_special_arrays Subroutine
procedure , public , :: rcenter Function
procedure , public , :: read_and_set => gs2d_read_and_set Subroutine

Functions

private function rcenter(self, rp)

FIXME : Add documentation

Arguments

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

Return Value real


Subroutines

private subroutine gs2d_read_and_set(self, inputs)

This subroutine reads a GS2D output file containing the axisymmetric magnetic field geometry on a rectangular domain defined by the coordinates (R,Z).

Arguments

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

private subroutine efit_read_and_set(self, inputs)

This subroutine reads an EFIT output file containing the axisymmetric magnetic field geometry on a rectangular domain defined by the coordinates (R,Z). It reads and stores the following quantities (among others).

Read more…

Arguments

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

private pure subroutine dealloc_special_arrays(self)

FIXME : Add documentation

Arguments

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

private subroutine setup_special_splines(self)

Arguments

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

private subroutine delete_special_splines(self)

Arguments

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