init_g Module

This module contains the subroutines which set the initial value of the fields and the distribution function.



Contents


Variables

Type Visibility Attributes Name Initial
integer, private :: ginitopt_switch
integer, private, parameter :: ginitopt_default = 1
integer, private, parameter :: ginitopt_xi = 3
integer, private, parameter :: ginitopt_xi2 = 4
integer, private, parameter :: ginitopt_rh = 5
integer, private, parameter :: ginitopt_zero = 6
integer, private, parameter :: ginitopt_test3 = 7
integer, private, parameter :: ginitopt_convect = 8
integer, private, parameter :: ginitopt_restart_file = 9
integer, private, parameter :: ginitopt_noise = 10
integer, public, parameter :: ginitopt_restart_many = 11
integer, private, parameter :: ginitopt_continue = 12
integer, private, parameter :: ginitopt_nl = 13
integer, private, parameter :: ginitopt_kz0 = 14
integer, private, parameter :: ginitopt_restart_small = 15
integer, private, parameter :: ginitopt_nl2 = 16
integer, private, parameter :: ginitopt_nl3 = 17
integer, private, parameter :: ginitopt_nl4 = 18
integer, private, parameter :: ginitopt_nl5 = 19
integer, private, parameter :: ginitopt_alf = 20
integer, private, parameter :: ginitopt_kpar = 21
integer, private, parameter :: ginitopt_nl6 = 22
integer, private, parameter :: ginitopt_nl7 = 23
integer, private, parameter :: ginitopt_gs = 24
integer, private, parameter :: ginitopt_recon = 25
integer, private, parameter :: ginitopt_nl3r = 26
integer, private, parameter :: ginitopt_smallflat = 27
integer, private, parameter :: ginitopt_harris = 28
integer, private, parameter :: ginitopt_recon3 = 29
integer, private, parameter :: ginitopt_ot = 30
integer, private, parameter :: ginitopt_zonal_only = 31
integer, private, parameter :: ginitopt_single_parallel_mode = 32
integer, private, parameter :: ginitopt_all_modes_equal = 33
integer, private, parameter :: ginitopt_default_odd = 34
integer, public, parameter :: ginitopt_restart_memory = 35
integer, private, parameter :: ginitopt_restart_eig = 36
integer, private, parameter :: ginitopt_no_zonal = 37
integer, private, parameter :: ginitopt_stationary_mode = 38
integer, private, parameter :: ginitopt_cgyro = 39
integer, private, parameter :: ginitopt_random_sine = 40
integer, private, parameter :: ginitopt_constant = 41
real, public :: width0
real, private :: dphiinit
real, private :: phiinit
real, private :: imfac
real, private :: refac
real, private :: zf_init
real, private :: phifrac
real, private :: den0
real, private :: upar0
real, private :: tpar0
real, private :: tperp0
real, private :: den1
real, private :: upar1
real, private :: tpar1
real, private :: tperp1
real, private :: den2
real, private :: upar2
real, private :: tpar2
real, private :: tperp2
real, public :: tstart
real, private :: scale
real, private :: apar0
logical, private :: chop_side
logical, private :: clean_init
logical, private :: left
logical, private :: even
logical, public :: new_field_init
logical, public :: initial_condition_is_nonadiabatic_dfn
character(len=run_name_size), public :: restart_file
character(len=150), private :: restart_dir
integer, private, dimension(2) :: ikk
integer, private, dimension(2) :: itt
integer, private, dimension(3) :: ikkk
integer, private, dimension(3) :: ittt
complex, private, dimension (6) :: phiamp
complex, private, dimension (6) :: aparamp
integer, private :: restart_eig_id
integer, private :: max_mode
integer, private :: ikpar_init
real, private :: kpar_init
integer, private :: ikx_init

This is used in linear runs with flow shear in order to track the evolution of a single Lagrangian mode.

real, private :: phiinit0
real, private :: phiinit_rand
real, private :: a0
real, private :: b0
logical, private :: null_phi
logical, private :: null_bpar
logical, private :: null_apar
integer, private :: adj_spec
character(len=20), private :: eq_type = ''
real, private :: prof_width = -.05
integer, private :: eq_mode_n = 0
integer, private :: eq_mode_u = 1
logical, private :: input_check_recon = .false.
complex, private :: ukxy_pt(3)
logical, private :: constant_random_flag

Whether to use the constant_random number generator, which always gives the same random numbers. Used for testing.

logical, private, parameter :: debug = .false.
logical, private :: initialized = .false.
logical, private :: exist
type(init_g_config_type), private :: init_g_config

Derived Types

type, public, extends(abstract_config_type) ::  init_g_config_type

Used to represent the input configuration of init_g

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 :: a0 = 0.0

Amplitude of equilibrium Apara: if a0 is non-zero, is rescaled to give this Apara amplitude

integer, public :: adj_spec = 0

Used by ginit_option "recon3": adjust input parameter of this species; if = 0, just warn if given conditions are not satisfied

Read more…
real, public :: apar0 = 0.0

Used by ginit_option "nl3r": set amplitude of apar if width0 is negative

complex, public, dimension(6) :: aparamp = cmplx(0.0, 0.0)

Used in initialization for the Orszag-Tang 2D vortex problem (ginit_option "ot"). Controls size of jpar term. FIXME: Reference equations?

real, public :: b0 = 0.0

Amplitude of equilibrium By: if b0 is non-zero, is rescaled to give this By amplitude by overriding a0

logical, public :: chop_side = .true.

Rarely needed. Forces asymmetry into initial condition. Warning: This does not behave as one may expect in flux tube simulations (see clean_init), this can be important as the default is to use chop_side

logical, public :: clean_init = .true.

Used with ginit_option "noise". Ensures that in flux tube simulations the connected boundary points are initialised to the same value. Also allows for chop_side to behave correctly in flux tube simulations.

logical, public :: constant_random_flag = .false.

Use the constant_random number generator, which always gives the same random numbers. Useful for testing.

real, public :: den0 = 1.0

Amplitude of zeroth density perturbation for ginit_option options:

Read more…
real, public :: den1 = 0.0

Amplitude of first density perturbation for ginit_option options:

Read more…
real, public :: den2 = 0.0

Amplitude of second density perturbation for ginit_option options:

Read more…
real, public :: dphiinit = 1.0

Amplitude of for "nl7" (see ginit_nl7)

integer, public :: eq_mode_n = 0

Mode number in for the sinusoidal equilbrium option of ginit_option "recon3" (see ginit_recon3), applies to density and temperatures

integer, public :: eq_mode_u = 1

Mode number in for the sinusoidal equilbrium option of ginit_option "recon3" (see ginit_recon3), applies to parallel velocity

character(len=20), public :: eq_type = 'sinusoidal'

Equilbrium choice for ginit_option "recon3" (see ginit_recon3). Choices are:

Read more…
logical, public :: even = .true.

Sometimes initial conditions have definite parity; this picks the parity in those cases. Affects the following choices of ginit_option:

Read more…
character(len=20), public :: ginit_option = "default"

Method for initialising g. There are many possible options, but the typical ones are:

Read more…
integer, public, dimension(2) :: ikk = [1, 2]

indices of two modes to initialise for certain options

integer, public, dimension(3) :: ikkk = [1, 2, 2]

indices of three modes to initialise for certain options

integer, public :: ikpar_init = 0

Parallel mode number to initialise for ginit_option "single_parallel_mode" with periodic boundary conditions

integer, public :: ikx_init = -1

If greater than zero, initialise only the given with ginit_option "noise". This is useful for linear runs with flow shear, to track the evolution of a single Lagrangian mode.

real, public :: imfac = 0.0

Amplitude of imaginary part of for various ginit_option options

logical, public :: include_explicit_source_in_restart = .true.

Do we want to include the explicit source terms and related timesteps when saving/restoring from the restart file.

logical, public :: initial_condition_is_nonadiabatic_dfn = .false.

If true then the initial condition is used to set the non-adiabatic distribution function rather than the g evolved by GS2.

logical, public :: input_check_recon = .false.

Print some debug information for ginit_option "recon3"

integer, public, dimension(2) :: itt = [1, 2]

indices of two modes to initialise for certain options

integer, public, dimension(3) :: ittt = [1, 2, 2]

indices of three modes to initialise for certain options

real, public :: kpar_init = 0.0

Parallel mode number to initialise for ginit_option "single_parallel_mode" with linked boundary conditions

logical, public :: left = .true.

If chop_side is true, chop out left side in theta if true, right side if false. Applies to: FIXME: list of initial conditions

integer, public :: max_mode = 128

The maximum mode number to initialise for ginit_option "random_sine". Actual maximum used will be lower of max_mode and ntheta/8

logical, public :: new_field_init = .true.

Change fields implicit initialisation somehow

Read more…
logical, public :: null_apar = .false.

"Nullify fields". Used by ginit_option "recon3"

Read more…
logical, public :: null_bpar = .false.

"Nullify fields". Used by ginit_option "recon3"

Read more…
logical, public :: null_phi = .false.

"Nullify fields". Used by ginit_option "recon3"

Read more…
complex, public, dimension(6) :: phiamp = cmplx(0.0, 0.0)

Used in initialization for the Orszag-Tang 2D vortex problem.

Read more…
real, public :: phifrac = 0.1

If doing multiple flux tube calculations, multiply phiinit by (job * phifrac + 1). Allows for ensemble averaging of multiple flux tube calculations

real, public :: phiinit = 1.0

Average amplitude of initial perturbation of each Fourier mode. Used by most ginit_option options

real, public :: phiinit0 = 0.0

Amplitude of equilibrium. Used by ginit_option "recon3"

real, public :: phiinit_rand = 0.0

Amplitude of random perturbation. Used by ginit_option "recon3"

integer, public :: proc_to_save_fields = 0

Which processor is responsible for saving/reading potentials to/from restart files. If <0 then all procs write to restart files. If >= nproc then set to proc_to_save_fields = mod(proc_to_save_fields, nproc)

real, public :: prof_width = -0.1

Width of "porcelli", "doubleharris" profiles in ginit_option "recon3". If negative, this gives the ratio to the box size

logical, public :: read_many = .false.

Restart from many restart files. If false, use a single restart file: this requires GS2 to have been built with parallel netCDF.

real, public :: refac = 1.0

Amplitude of real part of for various ginit_option options

character(len=150), public :: restart_dir = "./"

Directory to read/write restart files to/from. Make sure this exists before running (see file_safety_check)

integer, public :: restart_eig_id = 0

Used to select with eigensolver generated restart file to load. Sets <id> in restart_file//eig_<id>//.<proc> string used to set filename. Note that this is zero indexed.

character(len=run_name_size), public :: restart_file = "restart_file_not_set.nc"

Basename of restart files

Read more…
real, public :: scale = 1.0

Rescale amplitudes of fields for restart ginit_option options such as "restart". Note that if scale is negative, the fields are scaled by -scale / max(abs(phi))!

real, public :: tpar0 = 0.0

Amplitude of zeroth parallel temperature perturbation for ginit_option options:

Read more…
real, public :: tpar1 = 0.0

Amplitude of first parallel temperature perturbation for ginit_option options:

Read more…
real, public :: tpar2 = 0.0

Amplitude of second parallel temperature perturbation for ginit_option options:

Read more…
real, public :: tperp0 = 0.0

Amplitude of zeroth perpendicular temperature perturbation for ginit_option options:

Read more…
real, public :: tperp1 = 0.0

Amplitude of first perpendicular temperature perturbation for ginit_option options:

Read more…
real, public :: tperp2 = 0.0

Amplitude of second perpendicular temperature perturbation for ginit_option options:

Read more…
real, public :: tstart = 0.0

Force t = tstart at beginning of run

complex, public, dimension(3) :: ukxy_pt = cmplx(0., 0.)

Perturbation amplitude of parallel velocity? Used by ginit_option "recon3"

Read more…
real, public :: upar0 = 0.0

Amplitude of zeroth parallel velocity perturbation for ginit_option options:

Read more…
real, public :: upar1 = 0.0

Amplitude of first parallel velocity perturbation for ginit_option options:

Read more…
real, public :: upar2 = 0.0

Amplitude of second parallel velocity perturbation for ginit_option options:

Read more…
real, public :: width0 = -3.5

Width of initial perturbation Gaussian envelope in

real, public :: zf_init = 1.0

Amplitude of initial zonal flow perturbations relative to other modes

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_init_g_config Subroutine
procedure , public :: write => write_init_g_config Subroutine
procedure , public :: reset => reset_init_g_config Subroutine
procedure , public :: broadcast => broadcast_init_g_config Subroutine
procedure , public , nopass :: get_default_name => get_default_name_init_g_config Function
procedure , public , nopass :: get_default_requires_index => get_default_requires_index_init_g_config Function

Functions

public function get_init_g_config()

Get the module level config instance

Arguments

None

Return Value type(init_g_config_type)

public function get_restart_dir()

Returns the value of restart_dir

Arguments

None

Return Value character(len=:), allocatable

private function get_default_name_init_g_config()

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 wnml_init_g(unit)

FIXME : Add documentation

Arguments

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

public subroutine check_init_g(report_unit)

FIXME : Add documentation

Arguments

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

public subroutine init_init_g(init_g_config_in)

FIXME : Add documentation
DD>Only let proc0 do this and then broadcast as other procs don't know phiinit,phifrac etc.

Arguments

Type IntentOptional Attributes Name
type(init_g_config_type), intent(in), optional :: init_g_config_in

public subroutine ginit(restarted, override_ginitopt_switch)

FIXME : Add documentation

Arguments

Type IntentOptional Attributes Name
logical, intent(out) :: restarted
integer, intent(in), optional :: override_ginitopt_switch

private subroutine set_gnew_from_nonadiabatic_dfn()

Take the existing gnew value and, assuming it is the nonadiabatic dfn, calculate the consistent potentials to set the true gnew value.

Arguments

None

private subroutine read_parameters(init_g_config_in)

FIXME : Add documentation

Arguments

Type IntentOptional Attributes Name
type(init_g_config_type), intent(in), optional :: init_g_config_in

private subroutine ginit_default()

Set initial condition to gaussian in

Read more…

Arguments

None

private subroutine ginit_default_odd()

Set initial condition to gaussian in

Read more…

Arguments

None

private subroutine ginit_kz0()

Initialise with only the kparallel = 0 mode.

Arguments

None

private subroutine single_initial_kx(phi)

FIXME : Add documentation

Arguments

Type IntentOptional Attributes Name
complex, intent(inout), dimension (-ntgrid:ntgrid,ntheta0,naky) :: phi

private subroutine ginit_noise()

Initialise the distribution function with random noise. This is the recommended initialisation option. Each different mode is given a random amplitude between zero and one.

Arguments

None

private subroutine ginit_single_parallel_mode()

Initialise only with a single parallel mode specified by either ikpar_init for periodic boundary conditions or kpar_init for linked boundary conditions. Only makes sense for linear calculations. doc> reality condition for ky = 0 component:

Arguments

None

private subroutine ginit_all_modes_equal()

Initialize with every parallel and perpendicular mode having equal amplitude. Only makes sense in a linear calculation. k_parallel is specified with kpar_init or with ikpar_init when periodic boundary conditions are used. EGH doc> reality condition for ky = 0 component:

Arguments

None

private subroutine ginit_nl()

"nl": Two modes set to constant amplitude. Controlled by:

Read more…

Arguments

None

private subroutine ginit_nl2()

"nl2": Two modes proportional to . Controlled by:

Read more…

Arguments

None

private subroutine ginit_nl3()

"nl3": Two modes with a Gaussian envelope, and perturbation in fields of form , except for parallel velocity which uses is 90 degrees out of phase and uses . Density, parallel velocity, and perpendicular and parallel temperatures can all be controlled independently. Controlled by:

Read more…

Arguments

None

private subroutine ginit_nl3r()

FIXME : Add documentation

Arguments

None

private subroutine ginit_harris()

FIXME : Add documentation

Arguments

None

private subroutine ginit_recon()

FIXME : Add documentation

Arguments

None

private subroutine ginit_nl4()

FIXME : Add documentation

Read more…

Arguments

None

private subroutine ginit_nl5()

FIXME : Add documentation

Arguments

None

private subroutine ginit_nl6()

FIXME : Add documentation

Arguments

None

private subroutine ginit_nl7()

FIXME : Add documentation

Arguments

None

private subroutine ginit_ot()

Orszag-Tang 2D vortex problem phi, jpar are local !! $ phi(:,1,2) = phiinit * cmplx(2.0, 0.0) ! 2 cos(y) $ phi(:,2,1) = phiinit * cmplx(1.0, 0.0) ! 2 cos(x) $ jpar(:,1,2) = apar0 * cmplx(2.0, 0.0) ! 2 cos(y) $ jpar(:,3,1) = apar0 * cmplx(2.0, 0.0) ! 4 cos(2x)

Arguments

None

private subroutine ginit_kpar()

FIXME : Add documentation

Arguments

None

private subroutine ginit_gs()

FIXME : Add documentation
DD>Should this be triggered for kt_grids::reality=.true. only?

Arguments

None

private subroutine ginit_xi()

FIXME : Add documentation

Arguments

None

private subroutine ginit_xi2()

FIXME : Add documentation

Arguments

None

private subroutine ginit_rh()

FIXME : Add documentation

Arguments

None

private subroutine ginit_alf()

FIXME : Add documentation

Arguments

None

private subroutine ginit_zero()

FIXME : Add documentation

Arguments

None

private subroutine ginit_test3()

FIXME : Add documentation

Arguments

None

private subroutine ginit_convect()

FIXME : Add documentation

Arguments

None

private subroutine ginit_recon3()

FIXME : Add documentation
! adjust input parameters to kill initial field if wanted

Read more…

Arguments

None

private subroutine ginit_restart_file()

FIXME: This is identical to ginit_restart_many? Remove?

Arguments

None

private subroutine ginit_restart_many()

Restore g from restart files. Note that the timestep and simulation time are restored by read_t0_from_restart_file

Arguments

None

private subroutine ginit_restart_eig()

Uses the restart files written by the eigensolver. File to read is set by restart_eig_id

Arguments

None

private subroutine ginit_restart_memory()

FIXME : Add documentation

Arguments

None

private subroutine ginit_restart_small()

Restores g from restart files on top of a background from ginit_noise.

Read more…

Arguments

None

private subroutine ginit_restart_smallflat()

Similar to "small", restores fields from restart files on top of a random background

Arguments

None

private subroutine ginit_restart_zonal_only()

Restart but set all non-zonal components of the potential and the distribution function to 0. Noise can be added to these other components by setting phiinit > 0. The size of the zonal flows can be adjusted using zf_init.

Read more…

Arguments

None

private subroutine ginit_restart_no_zonal()

Restart but remove the zonal flow (ky = 0) component upon restarting.

Read more…

Arguments

None

private subroutine ginit_stationary_mode()

The stationary mode test case is a method of testing the geometry implementation by initializing the distribution function in a particular way For collisionless runs with ky=0, we expect the solution to be time-independent (see section 3.3.1 of Ball MIT Masters thesis)

Read more…

Arguments

None

private subroutine ginit_cgyro()

Sets g to a constant value everywhere except zonal component which is 0 Default initial conditions for CGYRO

Read more…

Arguments

None

private subroutine ginit_random_sine()

Construct the initial condition from a sum of sine waves scaled with random amplitude up to phiinit (ky > 0) or zf_init (ky == 0). Use mode numbers up to minimum of max_mode or last resolved wave (i.e. ntheta/8).

Read more…

Arguments

None

private subroutine ginit_constant()

Initialise the distribution function to a constant but satisfying forbidden regions. Can scale the zonal component separately as usual.

Arguments

None

public subroutine reset_init(from_file)

FIXME : Add documentation

Arguments

Type IntentOptional Attributes Name
logical, intent(in) :: from_file

private subroutine flae(g, gavg)

FIXME : Add documentation

Arguments

Type IntentOptional Attributes Name
complex, intent(in), dimension (-ntgrid:,:,g_lo%llim_proc:) :: g
complex, intent(out), dimension (-ntgrid:,:,g_lo%llim_proc:) :: gavg

public subroutine init_vnmult(vnm)

FIXME : Add documentation

Arguments

Type IntentOptional Attributes Name
real, intent(inout), dimension (2) :: vnm

public subroutine finish_init_g()

FIXME : Add documentation

Arguments

None

public subroutine set_init_g_config(init_g_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(init_g_config_type), intent(in), optional :: init_g_config_in

private subroutine read_init_g_config(self)

Reads in the init_g_knobs namelist and populates the member variables

Arguments

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

private subroutine write_init_g_config(self, unit)

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

Arguments

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

private subroutine reset_init_g_config(self)

Resets the config object to the initial empty state

Arguments

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

private subroutine broadcast_init_g_config(self)

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

Arguments

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