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

TypeVisibility AttributesNameInitial
logical, private :: make_salpha
integer, private :: n_shat
integer, private :: n_beta
real, private :: shat_min
real, private :: shat_max
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

TypeVisibility AttributesNameInitial
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…

Type-Bound Procedures

procedure, public :: is_initialised => is_initialised_generic
procedure, public :: init => init_generic
procedure, public :: setup => setup_generic
procedure, public :: write_namelist_header
procedure, public :: get_name => get_name_generic
procedure, public :: get_requires_index => get_requires_index_generic
procedure, public, nopass :: write_namelist_footer
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
procedure, public :: write => write_ballstab_config
procedure, public :: reset => reset_ballstab_config
procedure, public :: broadcast => broadcast_ballstab_config
procedure, public, nopass :: get_default_name => get_default_name_ballstab_config
procedure, public, nopass :: get_default_requires_index => get_default_requires_index_ballstab_config

Functions

public function is_unstable()

Test stability of current system -- return integer

Read more…

Arguments

None

Return Value integer

public function get_ballstab_config()

Get the module level config instance

Arguments

None

Return Value type(ballstab_config_type)

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


Subroutines

public subroutine init_ballstab(ballstab_config_in)

Initialise grids, other modules etc.

Arguments

Type IntentOptional AttributesName
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 AttributesName
type(ballstab_config_type), intent(in), optional :: ballstab_config_in

private subroutine read_parameters(ballstab_config_in)

Read parameters

Arguments

Type IntentOptional AttributesName
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

private subroutine wnml_ballstab(unit)

Write a namelist based on current values

Arguments

Type IntentOptional AttributesName
integer, intent(in) :: unit

private subroutine check_ballstab(report_unit)

Check value consistency etc.

Arguments

Type IntentOptional AttributesName
integer, intent(in) :: report_unit

private subroutine get_shat(shat_out)

Gets the current value of shat

Arguments

Type IntentOptional AttributesName
real, intent(out) :: shat_out

private subroutine set_shat(shat_in)

Sets the value of shat

Arguments

Type IntentOptional AttributesName
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 AttributesName
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 AttributesName
real, intent(in) :: bp_in

public subroutine run_stability_check()

Runs the stability check scan

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, ib, iunstable, restore)

Test if given shat/beta is unstable

Arguments

Type IntentOptional AttributesName
real, intent(in) :: shat_in
real, intent(in) :: beta_prime_in
integer, intent(in) :: ib
integer, intent(out) :: iunstable
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 AttributesName
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 AttributesName
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 AttributesName
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 AttributesName
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 AttributesName
class(ballstab_config_type), intent(inout) :: self