Inputs
The GX input file
The main GX input file is parsed with toml. Input file names should be suffixed with .in, such as example.in. Such an input file can be run via
[/path/to/]gx example.in
This will generate an output file in NetCDF format called example.nc.
The toml standard allows one to group related input variables. There are multiple ways to specify such groupings. Since there are sample input files provided with GX, here we will pick one particular syntactical pattern. Users are free to use anything that is compatible with the toml standard.
Example input files can be found in the Getting started with GX pages, and in the benchmarks directory in the GX repository.
A typical input file will be of the form
debug = false
[Dimensions]
nx = ...
...
[Domain]
...
...
Most of the parameters belong to groups, e.g. [Dimensions] or [Domain].
In the following we describe each possible input parameter in each group. In practice, many of these parameters can be left unspecified so that default values are used.
debug is a special parameter that does not belong to a group, and must be specified at the top of the input file before any groups:
Group |
Variable |
Description |
Default |
|---|---|---|---|
none |
|
If true, print debug information to standard out |
false |
Dimensions
The [Dimensions] group controls the number of grid-points/spectral basis functions in each dimension, and the number of evolved kinetic species.
Group |
Variable |
Description |
Default |
|---|---|---|---|
|
|
The number of real-space grid points in the x direction. Related to the number of de-aliased Fourier modes |
|
|
|
The number of real-space grid points in the y direction. Related to the number of de-aliased Fourier modes |
|
|
|
The number of (de-aliased) Fourier modes in the x direction. Recommended for linear calculations (instead of |
|
|
|
The number of (de-aliased) Fourier modes in the y direction. Recommended for linear calculations (instead of |
|
|
|
The number of grid points used in the z direction. |
32 |
|
|
The number of Hermite basis functions used (\(v_\parallel\) resolution) |
4 |
|
|
The number of Laguerre basis functions used (\(\mu B\) resolution) |
2 |
|
|
The number of kinetic species used. |
1 |
|
|
The number of poloidal turns used. |
1 |
Domain
The [Domain] group controls the physical extents of the simulation domain and the boundary conditions.
Group |
Variable |
Description |
Default |
|---|---|---|---|
|
|
Controls box length in the binormal coordinate \(y\) via \(L_y = 2\pi \texttt{y0}\) (in units of \(\rho_\mathrm{ref}\)). Also controls the minimum \(k_y\), so that \(k_{y\,\mathrm{min}}\rho_\mathrm{ref} = 1/\texttt{y0}\). |
10.0 |
|
|
The twist-and-shift boundary condition is controlled by |
If finite magnetic shear: \(\texttt{round}(2\pi\texttt{shat})\) If zero magnetic shear: \(2\, \texttt{nx}\) |
|
|
Controls box length in the radial coordinate \(x\) via \(L_x = 2\pi \texttt{x0}\) (in units of \(\rho_\mathrm{ref}\)). Also controls the minimum \(k_x\), so that \(k_{x\,\mathrm{min}}\rho_\mathrm{ref} = 1/\texttt{x0}\). Typically |
If finite magnetic shear: \(\texttt{y0}\,\texttt{jtwist}/(2\pi\texttt{shat})\) If zero magnetic shear: \(\texttt{y0}\) |
|
|
Controls the boundary condition in the \(z\) (parallel) direction. The following options are possible:
-
"linked": twist-and-shift BC, with generalization for non-axisymmetric geometry (Martin et al 2018).-
"forced periodic" (or simply "periodic"): use periodic BCs with no cutting of flux tube.-
"exact periodic": cut flux tube at a location where gds21 = 0, and then use periodic BCs (currently for VMEC geometry only).-
"continuous drifts": cut flux tube at a location where gbdrift0 = 0, and then use (generalized) twist-and-shift BC (currently for VMEC geometry only).-
"fix aspect": cut flux tube at a location where y0/x0 takes the desired value, and then use (generalized) twist-and-shift BC (VMEC geometry only). |
“linked” |
|
|
Number of \(2\pi\) segments in the \(z\) (parallel) direction. Usually |
\(2\,\texttt{nperiod}-1\) |
Physics
Parameters that control physics options are specified in the [Physics] group:
Group |
Variable |
Description |
Default |
|---|---|---|---|
|
|
This is the reference beta value, \(\beta_\mathrm{ref} = 8\pi n_\mathrm{ref} T_\mathrm{ref}/B^2\). Typically it would be approximately
half of the total beta. If |
0.0 |
|
|
Set to true to include nonlinear terms in the equations. |
false |
|
|
Factor multiplying electrostatic potential \(\Phi\) |
1.0 |
|
|
Factor multiplying electromagnetic vector potential \(A_\parallel\) |
0.0 |
|
|
Factor multiplying electromagnetic compressional fluctuation \(\delta B_\parallel\) |
0.0 |
Time
Parameters that control the time-stepping are set in the [Time] group:
Group |
Variable |
Description |
Default |
|---|---|---|---|
|
|
The maximum timestep allowed. The actual timestep will be set by stability constraints. |
0.05 |
|
|
The number of timesteps to take. Set this or |
|
|
|
End time of the simulation, in code units. Set this or |
|
|
|
If restarting the simulation, run for an additional |
|
|
|
This string variable chooses the time-stepping scheme to be used. Choices are:
"rk3": 3rd order Runge-Kutta (recommended)"rk4": 4th order Runge-Kutta"sspx3": 3rd order SSP Runge-Kutta with extended stability"k10": Ketcheson’s 10 stage, 4th order low-storage method. Useful for problems with memory constraints. |
“rk3” |
|
|
The number of Runge-Kutta stages to be used for certain time-stepping schemes. Not relevant
for most choices of |
10 |
|
|
Safety cushion factor on timestep size. The timestep used will be the computed allowable timestep multiplied by |
0.9 |
Initialization
The [Initialization] group controls the initial conditions.
Group |
Variable |
Description |
Default |
|---|---|---|---|
|
|
The initial perturbation is applied to this component of the distribution function. |
“density” |
|
|
The amplitude of the initial perturbation. |
1.0e-5 |
|
|
Parallel wavenumber of the initial perturbation |
0 |
|
|
Only apply initial perturbations to electrons (when using a kinetic electron species) |
false |
|
|
Use completely random initial conditions (e.g. no mode structure in \(z\)) |
false |
|
|
Use a gaussian initial condition in \(z\) with an envelope of \(a + b*sin(z-z0)\) |
false |
|
|
Coefficient \(a\) in the above expression for gaussian initial condition |
1.0 |
|
|
Coefficient \(b\) in the above expression for gaussian initial condition |
0.0 |
|
|
Width (in z) of the gaussian initial condition |
0.5 |
Geometry
The [Geometry] group controls the simulation geometry.
Group |
Variable |
Description |
Default |
|---|---|---|---|
|
|
String specifying the geometry setup. Options are |
“miller” |
Each geo_option has some parameters that control the geometry specification. The following groups of parameters are the parameters that can/should be specified for a particular choice of geo_option. All parameters live in the [Geometry] block. Note that some parameters overlap between different geo_option’s.
geo_option = “miller”
This option specifies a local Miller equilibrium for a tokamak.
Group |
Variable |
Description |
Default |
|---|---|---|---|
|
|
The ratio of the major radius at the center of the flux surface to the equilibrium-scale reference length, \(R/L_\mathrm{ref}\).
The choice of |
1.0 |
|
|
The magnetic safety factor, \(q = (r/R)(B_t/B_p)\). |
1.4 |
|
|
The global magnetic shear, \(\hat{s} = (r/q) dq/dr\). |
0.8 |
|
|
This characterizes the Shafranov shift and is sometimes called alpha. It should normally be a non-negative number. |
0.0 |
|
|
Flux surface label given by ratio of midplane diameter to the reference length, \(\rho = r/L_\mathrm{ref}\). |
|
|
|
Major radius of magnetic field reference point, normalized to \(L_\mathrm{ref}\) (i.e. \(B_t(R_\mathrm{geo}) = B_\mathrm{ref}\)). |
|
|
|
Elongation of flux surface. |
|
|
|
Radial gradient of elongation of flux surface. |
|
|
|
Triangularity of flux surface. |
|
|
|
Radial gradient of triangularity of flux surface. |
|
|
|
Radial gradient of equilibrium pressure. Used in the calculation of the Shafranov shift. |
geo_option = “vmec”
This option generates the geometry from a VMEC equilibrium output file in NetCDF format. This is typically used for stellarators. See also the boundary parameter in [Domain], where some options are only available for VMEC geometry.
Group |
Variable |
Description |
Default |
|---|---|---|---|
|
|
(Path to) the VMEC equilibrium NetCDF output file. |
|
|
|
Field line label. |
0.0 |
|
|
Number of poloidal turns. May be reduced based on |
1.0 |
|
|
Flux surface label given by \(\rho = \sqrt{\Psi/\Psi_{LCFS}}\), where \(\Psi\) is the toroidal flux. |
0.25 |
|
|
Controls how the flux surface is chosen. 0 = use exact radius requested. 1 = use nearest value of the VMEC half grid. 2 = use nearest value of the VMEC full grid. |
0 |
|
|
For |
-1 |
|
|
Set to 1 to print lots of information from VMEC geometry module. |
0 |
geo_option = “eik”
Read the geometry arrays from a text file in GS2’s eik.out format.
Group |
Variable |
Description |
Default |
|---|---|---|---|
|
|
(Path to) eik geometry file. |
“eik.out” |
geo_option = “nc”
Read the geometry arrays from a NetCDF file.
Group |
Variable |
Description |
Default |
|---|---|---|---|
|
|
(Path to) NetCDF geometry file. |
geo_option = “s-alpha”, geo_option = “const-curv”
Group |
Variable |
Description |
Default |
|---|---|---|---|
|
|
Flux surface label given by the inverse aspect ratio of the surface in question, \(\epsilon = r/R\). |
0.167 |
|
|
The ratio of the major radius at the center of the flux surface to the equilibrium-scale reference length, \(R/L_\mathrm{ref}\). The choice of |
1.0 |
|
|
The magnetic safety factor, \(q = (r/R)(B_t/B_p)\). |
1.4 |
|
|
The global magnetic shear, \(\hat{s} = (r/q) dq/dr\). |
0.8 |
|
|
This characterizes the Shafranov shift and is sometimes called alpha. It should normally be a non-negative number. |
0.0 |
geo_option = “gs2_geo”
This option calls GS2’s eiktest executable to run GS2’s geometry module directly. This is useful for generating geometry from a g-eqdsk equilibrium file, which is currently not natively supported in GX. This option requires separately building GS2’s eiktest and setting GS2_PATH in the Makefile. For parameter definitions, see the GS2 documentation, or see the comments at the top of src/geo/geometry.f90 in the GS2 source code.
Group |
Variable |
Description |
Default |
|---|---|---|---|
|
|
Value of flux surface label \(\rho\), depending on choice of |
0.5 |
|
|
Choose flux surface label:
case (1) :: sqrt(toroidal flux)/sqrt(toroidal flux of LCFS)
case (2) :: diameter/(diameter of LCFS). recommended
case (3) :: poloidal flux/(poloidal flux of LCFS)
|
2 |
|
|
(Path to) numerical equilibrium file to read |
|
|
|
Use |
0 |
|
|
0 |
|
|
|
0.01 |
|
|
|
0 |
|
|
|
0 |
|
|
|
1.0 |
|
|
|
-2.0 |
|
|
|
5.0 |
|
|
|
0.0 |
|
|
|
Set true to use an EFIT (e.g. g-eqdsk) equilibrium. |
false |
|
|
false |
|
|
|
false |
|
|
|
false |
|
|
|
false |
|
|
|
false |
|
|
|
false |
|
|
|
false |
|
|
|
false |
Species
The [species] group specifies parameters like charge, mass, and gradients of each kinetic species. For each parameter, an array is provided with entries for each species. Note that only the first nspecies elements will be read. For example, a typical [species] group might look like
# it is okay to have extra species data here; only the first nspecies elements of each item are used
[species]
z = [ 1.0, -1.0 ] # charge (normalized to Z_ref)
mass = [ 1.0, 2.7e-4 ] # mass (normalized to m_ref)
dens = [ 1.0, 1.0 ] # density (normalized to dens_ref)
temp = [ 1.0, 1.0 ] # temperature (normalized to T_ref)
tprim = [ 2.49, 2.49 ] # temperature gradient, L_ref/L_T
fprim = [ 0.8, 0.8 ] # density gradient, L_ref/L_n
vnewk = [ 0.0, 0.0 ] # collision frequency
type = [ "ion", "electron" ] # species type
If nspecies=1, only the first values of each table will be used (to set up the ion species). If nspecies=2 the electron data will be used as well.
Group |
Variable |
Description |
Default |
|---|---|---|---|
|
|
The charge (normalized to \(Z_\mathrm{ref}\)) |
|
|
|
The mass (normalized to \(m_\mathrm{ref}\)) |
|
|
|
The density (normalized to \(n_\mathrm{ref}\)) |
|
|
|
The temperature (normalized to \(T_\mathrm{ref}\)) |
1.0 |
|
|
Temperature gradient, \(L_\mathrm{ref}/L_T\) |
|
|
|
Density gradient, \(L_\mathrm{ref}/L_n\) |
|
|
|
The collision frequency |
0.0 |
|
|
The type of species, such as |
“ion” |
Boltzmann
The [Boltzmann] group sets up a Boltzmann species, which can be either electrons (e.g. for ITG calculations) or ions (e.g. for ETG calculations).
Group |
Variable |
Description |
Default |
|---|---|---|---|
|
|
If true, include a species with a Boltzmann response |
false |
|
|
Specify the Boltzmann species type. Choose either |
“electrons” |
|
|
Set the value of \(\tau = T_\mathrm{ref}/T_\mathrm{Boltzmann}\) (which is usually \(\tau = T_\mathrm{kinetic}/T_\mathrm{Boltzmann}\)). |
1.0 |
Dissipation
The [Dissipation] group controls numerical dissipation parameters, including (mostly experimental) closure models. For more details, see Numerical dissipation and Closures.
Group |
Variable |
Description |
Default |
|---|---|---|---|
|
|
If true, use hypercollision model to provide hyper-dissipation at grid-scales in velocity space. For details, see Numerical dissipation. |
false |
|
|
If |
0.5 |
|
|
If |
0.5 |
|
|
If |
6 |
|
|
If |
6 |
|
|
If true, use a simple hyperdiffusivity model to provide hyper-dissipation at grid-scales in the perpendicular dimensions. Recommended only for nonlinear calculations. For details, see Numerical dissipation. |
false |
|
|
If |
0.5 |
|
|
If |
2 |
|
|
If true, use the Hammett-Belli hyperdiffusivity model to provide hyper-dissipation at grid-scales in the perpendicular dimensions. Recommended only for nonlinear calculations. For details, see Numerical dissipation. |
false |
|
|
If |
1.0 |
|
|
If |
0.0 |
|
|
If |
2 |
|
|
Closure model to use. For options, see Closures. |
“none” |
|
|
A parameter for |
3 |
|
|
A parameter for |
3 |
Restart
The [Restart] group controls reading and writing of data for restarting (continuing) from previous runs. Warning: restart capability is currently limited. See this issue.
Group |
Variable |
Description |
Default |
|---|---|---|---|
|
|
Set to true to continue the simulation from a previous run. The simulation will be initialized to the previous state by reading data from the file specified by |
false |
|
|
Set to true to write information needed for a future restart. File is written every |
true |
|
|
Filename to write data needed for restarting the present run. |
“[input_stem].restart.nc” |
|
|
Filename for a file written from a previous run, to be read and used to continue (restart) the previous run. |
“[input_stem].restart.nc” |
|
|
Restart data will be written every |
max(1, \(\texttt{nstep}\)/10) |
|
|
Multiply all variables in the restart data by a factor of |
1.0 |
Diagnostics
The [Diagnostics] group controls the diagnostic quantities that are computed and written to the NetCDF output file. For more details about diagnostic quantities and options, see Diagnostics and the NetCDF file.
Group |
Variable |
Description |
Default |
|---|---|---|---|
|
omega |
Write instantaneous estimates of the complex frequency for each Fourier component of the electrostatic potential. |
false |
|
free_energy |
Write the total free energy (integrated over the phase-space domain and summed over species) as a function of time. |
true |
|
fluxes |
Write the turbulent fluxes for each species. |
false |
|
fixed_amplitude |
Periodically rescale amplitude of phi to avoid overflow. Only for linear calculations. |
false |
|
all_zonal_scalars |
Write quantities such as the RMS value of the zonal component of the ExB velocity as function of time. This is a shortcut for turning on all such writes, instead of specifying them individually (below). |
false |
|
avg_zvE |
Write the RMS value of the zonal component of ExB velocity as a function time. |
false |
|
avg_zkvE |
Write the RMS value of the zonal component of the shear of the ExB velocity as a function time. |
false |
|
avg_zkden |
Write the RMS value of the zonal component of the guiding center radial density gradient as a function of time. |
false |
|
avg_zkUpar |
Write the RMS value of the zonal component of the guiding center parallel velocity as a function of time. |
false |
|
avg_zkTpar |
Write the RMS value of the zonal component of the guiding center parallel temperature as a function of time. |
false |
|
avg_zkTperp |
Write the RMS value of the zonal component of the guiding center perpendicular temperature as a function of time. |
false |
|
avg_zkqpar |
Write the RMS value of the zonal component of the guiding center parallel-parallel heat flux as a function of time. |
false |
|
all_zonal |
Write quantities such as the zonal component of the ExB velocity as function of x and time. This is a shortcut for turning on all such writes, instead of specifying them individually (below). |
false |
|
vE |
Write the zonal component of ExB velocity as a function of x and time. |
false |
|
kvE |
Write the zonal component of the shear of the ExB velocity as a function of x and time. |
false |
|
kden |
Write the zonal component of the radial gradient of the guiding center density as a function of x and time. |
false |
|
kUpar |
Write the zonal component of the radial gradient of the guiding center parallel velocity as a function of x and time. |
false |
|
kTpar |
Write the zonal component of the radial gradient of the guiding center parallel temperature as a function of x and time. |
false |
|
kTperp |
Write the zonal component of the radial gradient of the guiding center perpendicular temperature as a function of x and time. |
false |
|
kqpar |
Write the zonal component of the radial gradient of the guiding center parallel-parallel heat flux as a function of x and time. |
false |
|
all_non_zonal |
Write quantities such as the non-zonal y-component of the ExB velocity as function of x and time. This is a shortcut for turning on all such writes, instead of specifying them individually (below). |
false |
|
xyvEx |
Write the x-component of the ExB velocity as a function of x, y, and time. |
false |
|
xyvEy |
Write the non-zonal y-component of the ExB velocity as a function of x, y, and time. |
false |
|
xykvE |
Write the non-zonal part of the shear of the y-component of the ExB velocity as a function of x and time. |
false |
|
xyden |
Write the non-zonal component of the guiding center density as a function of x and time. |
false |
|
xyUpar |
Write the non-zonal component of the guiding center parallel velocity as a function of x and time. |
false |
|
xyTpar |
Write the non-zonal component of the guiding center parallel temperature as a function of x and time. |
false |
|
xyTperp |
Write the non-zonal component of the guiding center perpendicular temperature as a function of x and time. |
false |
|
xyqpar |
Write the non-zonal component of the guiding center parallel-parallel heat flux as a function of x and time. |
false |
The [Wspectra] group controls writes of various slices of \(W_s(k_x,k_y,z, \ell, m) = |G_{\ell,m\,s}|^2\), the moment component of the free energy.
Group |
Variable |
Description |
Default |
|---|---|---|---|
|
species |
W as a function of species |
false |
|
kx |
W as a function of kx |
false |
|
ky |
W as a function of ky |
false |
|
kz |
W as a function of kz |
false |
|
z |
W as a function of z |
false |
|
laguerre |
W as a function of the Laguerre index |
false |
|
hermite |
W as a function of the Hermite index |
false |
|
hermite_laguerre |
W as a function of both Hermite and Laguerre indices |
false |
|
kperp |
W as a function of the magnitude of kperp. Not yet implemented. |
false |
|
kxky |
W as a function of the magnitude of kx and ky. |
false |
The [Pspectra] group controls writes of various slices of \(P_s(k_x,k_y,z) = [1-\Gamma_0(b_s)] |\Phi|^2\), the field component of the free energy.
Group |
Variable |
Description |
Default |
|---|---|---|---|
|
species |
P as a function of species |
false |
|
kx |
P as a function of kx |
false |
|
ky |
P as a function of ky |
false |
|
kz |
P as a function of kz |
false |
|
z |
P as a function of z |
false |
|
kperp |
P as a function of the magnitude of kperp. Not yet implemented. |
false |
|
kxky |
P as a function of the magnitude of kx and ky. |
false |
The [Qspectra] group controls writes of various slices of \(Q_s(k_x,k_y,z)\), the heat flux.
Group |
Variable |
Description |
Default |
|---|---|---|---|
|
species |
Q as a function of species |
false |
|
kx |
Q as a function of kx |
false |
|
ky |
Q as a function of ky |
false |
|
kz |
Q as a function of kz |
false |
|
z |
Q as a function of z |
false |
|
kperp |
Q as a function of the magnitude of kperp. Not yet implemented. |
false |
|
kxky |
Q as a function of the magnitude of kx and ky. |
false |
The [Gamspectra] group controls writes of various slices of \(\Gamma_s(k_x,k_y,z)\), the particle flux.
Group |
Variable |
Description |
Default |
|---|---|---|---|
|
species |
\(\Gamma\) as a function of species |
false |
|
kx |
\(\Gamma\) as a function of kx |
false |
|
ky |
\(\Gamma\) as a function of ky |
false |
|
kz |
\(\Gamma\) as a function of kz |
false |
|
z |
\(\Gamma\) as a function of z |
false |
|
kperp |
\(\Gamma\) as a function of the magnitude of kperp. Not yet implemented. |
false |
|
kxky |
\(\Gamma\) as a function of the magnitude of kx and ky. |
false |
Expert
The [Expert] group controls parameters reserved for expert users.
Group |
Variable |
Description |
Default |
|---|---|---|---|
|
i_share |
An integer related to the shared memory block used for the inner loop of the linear solver. |
8 |
|
nreal |
Enforce the reality condition every |
1 |
|
dealias_kz |
If true, dealias in \(k_z\). Only available for |
false |
|
local_limit |
If true, run calculation in local limit, where \(k_z\) is a scalar parameter given by \(k_z = 1.0/\texttt{zp}\). |
false |
|
init_single |
Only initialize a single Fourier mode if true |
false |
|
ikx_single |
Index of the kx mode to be initialized if |
0 |
|
iky_single |
Index of the ky mode to be initialized if |
1 |
|
eqfix |
Do not evolve some particular Fourier harmonic |
false |
|
ikx_fixed |
Index of the kx mode to be fixed in time if |
-1 |
|
iky_fixed |
Index of the ky mode to be fixed in time if |
-1 |
|
phi_ext |
Value of phi to use for a Rosenbluth-Hinton test |
0.0 |
|
source |
Used to specify various kinds of tests |
“default” |
|
t0 |
The time at which to start changing |
-1.0 |
|
tf |
The time at which to stop changing |
-1.0 |
|
tprim0 |
The value of |
-1.0 |
|
tprimf |
The value of |
-1.0 |
Forcing
Add forcing with the [Forcing] group. Not generally implemented.
Group |
Variable |
Description |
Default |
|---|---|---|---|
|
forcing_type |
Picks among the forcing options |
“Kz” |
|
stir_field |
Determines which moment of the GK equation is forced |
“density” |
|
forcing_amp |
Amplitude of the forcing |
1.0 |
|
forcing_index |
Index of the forcing |
1 |
|
no_fields |
Turn off the field terms in the GK equation if this is true |
false |