ballstab Module

A small module used to calculate ideal ballooning stability. Based on the original ball program in geo/ball.f90 of GS2 but tweaked to integrate closer to full GS2 runs etc.



Contents


Variables

Type Visibility Attributes Name Initial
logical, private :: make_salpha
integer, private :: n_shat
integer, private :: n_beta
real, private :: shat_min
real, private :: shat_max
real, private :: theta0
real, private :: beta_mul
real, private :: beta_div
real, private, dimension(:), allocatable :: shat_arr
real, private, dimension(:), allocatable :: beta_arr
real, private, dimension(:), allocatable :: dbdrho_arr
integer, public, dimension(:,:), allocatable :: stability
real, private :: diff
logical, private :: initialised = .false.
character(len=14), private :: namelist_name = "ballstab_knobs"
type(ballstab_config_type), private :: ballstab_config

Derived Types

type, public, extends(abstract_config_type) ::  ballstab_config_type

Used to represent the input configuration of ballstab

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 :: beta_div = 1.0

The minimum in scans is beta_prime_equilibrium/beta_div

real, public :: beta_mul = 1.0

The maximum in scans is beta_prime_equilibrium*beta_mul

real, public :: diff = 0.0

Controls decentring used in the numerical integration used for solving the ballooning equation. Recommended values are either 0 (default) or 1/3.

logical, public :: make_salpha = .false.

Not currently used for anything.

Read more…
integer, public :: n_beta = 1

How many values should be used in s-alpha type scans.

integer, public :: n_shat = 1

How many values should be used in s-alpha type scans.

real, public :: shat_max = 0.0

The maximum value of to use in s-alpha type scans.

Read more…
real, public :: shat_min = 0.0

The minimum value of to use in s-alpha type scans.

Read more…
real, public :: theta0 = 0.0

The theta0 value to use in solving the ideal ballooning problem. We don't currently provide a means to study multiple theta0 in a single run. This may change in the future.

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 , 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_ballstab_config Subroutine
procedure , public :: write => write_ballstab_config Subroutine
procedure , public :: reset => reset_ballstab_config Subroutine
procedure , public :: broadcast => broadcast_ballstab_config Subroutine
procedure , public , nopass :: get_default_name => get_default_name_ballstab_config Function
procedure , public , nopass :: get_default_requires_index => get_default_requires_index_ballstab_config Function

Functions

public pure function is_unstable(ntgrid, theta, bmag, dbetadrho, gradpar, gds2, gds21, gds22, cvdrift, cvdrift0, theta0_in) result(is_unstable_out)

Test stability of current system for passed theta0 and geometry -- return integer

Read more…

Arguments

Type IntentOptional Attributes Name
integer, intent(in) :: ntgrid
real, intent(in), dimension(-ntgrid:ntgrid) :: theta
real, intent(in), dimension(-ntgrid:ntgrid) :: bmag
real, intent(in) :: dbetadrho
real, intent(in), dimension(-ntgrid:ntgrid) :: gradpar
real, intent(in), dimension(-ntgrid:ntgrid) :: gds2
real, intent(in), dimension(-ntgrid:ntgrid) :: gds21
real, intent(in), dimension(-ntgrid:ntgrid) :: gds22
real, intent(in), dimension(-ntgrid:ntgrid) :: cvdrift
real, intent(in), dimension(-ntgrid:ntgrid) :: cvdrift0
real, intent(in), optional :: theta0_in

DD> NEED TO IMPROVE VARIABLE NAMES

Return Value integer

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

Get the module level config instance

Arguments

None

Return Value type(ballstab_config_type)


Subroutines

public subroutine init_ballstab(ballstab_config_in)

Initialise grids, other modules etc.

Arguments

Type IntentOptional Attributes Name
type(ballstab_config_type), intent(in), optional :: ballstab_config_in

public subroutine finish_ballstab()

Finalise this module Deallocate

Arguments

None

private subroutine real_init_ballstab(ballstab_config_in)

Initialise this module

Arguments

Type IntentOptional Attributes Name
type(ballstab_config_type), intent(in), optional :: ballstab_config_in

private subroutine read_parameters(ballstab_config_in)

Read parameters

Arguments

Type IntentOptional Attributes Name
type(ballstab_config_type), intent(in), optional :: ballstab_config_in

private subroutine verify_parameters()

Check parameters are consistent etc.

Arguments

None

private subroutine setup_arrays()

Allocate+populate arrays

Arguments

None

private subroutine dealloc_arrays()

Deallocate arrays

Arguments

None

public subroutine wnml_ballstab(unit)

Write a namelist based on current values

Arguments

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

private subroutine get_shat(shat_out)

Gets the current value of shat

Arguments

Type IntentOptional Attributes Name
real, intent(out) :: shat_out

private subroutine set_shat(shat_in)

Sets the value of shat

Arguments

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

private subroutine get_beta_prime(bp_out)

Gets the current value of beta_prime (or equivalent var) Really just gets the variable that we can use to control the pressure gradient.

Arguments

Type IntentOptional Attributes Name
real, intent(out) :: bp_out

private subroutine set_beta_prime(bp_in)

Sets the current value of beta_prime (or equivalent var) Really just sets the variable that we can use to control the pressure gradient.

Arguments

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

public subroutine run_stability_check()

Runs the stability check scan for the module level shat/beta array values

Arguments

None

public subroutine write_stability_ascii_1d()

Routine to write out stability data to 1D ascii file

Arguments

None

public subroutine write_stability_ascii_2d()

Routine to write out stability data to 2D ascii file + 1d axis data

Arguments

None

private subroutine check_stability(shat_in, beta_prime_in, dbetadrho_out, iunstable, theta0, restore)

Test if given shat/beta is unstable

Arguments

Type IntentOptional Attributes Name
real, intent(in) :: shat_in
real, intent(in) :: beta_prime_in
real, intent(out) :: dbetadrho_out
integer, intent(out) :: iunstable
real, intent(in), optional :: theta0
logical, intent(in), optional :: restore

public subroutine set_ballstab_config(ballstab_config_in)

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

Arguments

Type IntentOptional Attributes Name
type(ballstab_config_type), intent(in), optional :: ballstab_config_in

private subroutine read_ballstab_config(self)

Reads in the ballstab_knobs namelist and populates the member variables

Arguments

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

private subroutine write_ballstab_config(self, unit)

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

Arguments

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

private subroutine reset_ballstab_config(self)

Resets the config object to the initial empty state

Arguments

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

private subroutine broadcast_ballstab_config(self)

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

Arguments

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