pyrokinetics.gk_code.gs2.GKInputGS2#

class pyrokinetics.gk_code.gs2.GKInputGS2(filename=None)[source]#

Bases: GKInput, FileReader

Class that can read GS2 input files, and produce Numerics, LocalSpecies, and LocalGeometry objects

Parameters:

filename (PathLike | str | None)

__init__(filename=None)#
Parameters:

filename (PathLike | str | None)

Methods

__init__([filename])

add_flags(flags)

Add extra flags to GS2 input file

from_file(path[, file_type])

Read a file from disk, returning an instance of this class.

from_str(input_string)

get_local_geometry()

Returns local geometry.

get_local_geometry_miller()

Load Basic Miller object from GS2 file

get_local_geometry_mxh()

Load MXH object from GS2 file

get_local_species()

Load LocalSpecies object from GS2 file

get_ne_te_normalisation()

get_numerics()

Gather numerical info (grid spacing, time steps, etc)

get_reference_values(local_norm)

Reads in reference values from input file

is_linear()

is_nonlinear()

Return true if the GKCode is nonlinear, otherwise return False

read_dict(input_dict[, detect_norm])

Reads GS2 input file given as dict Uses default read_dict, which assumes input is a dict

read_from_file(filename[, detect_norm])

Reads GS2 input file into a dictionary

read_str(input_string[, detect_norm])

Reads GS2 input file given as string Uses default read_str, which assumes input_string is a Fortran90 namelist

set(local_geometry, local_species, numerics)

Set self.data using LocalGeometry, LocalSpecies, and Numerics.

supported_file_types()

Returns a list of all registered file types.

verify_expected_keys(filename, keys)

Checks that the expected keys are present at the top level of self.data.

verify_file_type(filename)

Ensure this file is a valid gs2 input file, and that it contains sufficient info for Pyrokinetics to work with

write(filename[, float_format, local_norm, ...])

Writes self.data to an input file

Attributes

add_flags(flags)[source]#

Add extra flags to GS2 input file

Return type:

None

code_name = 'GS2'#
default_file_name = 'input.in'#
file_type: ClassVar[str] = 'GS2'#
get_local_geometry()[source]#

Returns local geometry. Delegates to more specific functions

Return type:

LocalGeometry

get_local_geometry_miller()[source]#

Load Basic Miller object from GS2 file

Return type:

LocalGeometryMiller

get_local_geometry_mxh()[source]#

Load MXH object from GS2 file

Return type:

LocalGeometryMXH

get_local_species()[source]#

Load LocalSpecies object from GS2 file

get_ne_te_normalisation()[source]#
get_numerics()[source]#

Gather numerical info (grid spacing, time steps, etc)

Return type:

Numerics

get_reference_values(local_norm)[source]#

Reads in reference values from input file

Return type:

Dict[str, Any]

Parameters:

local_norm (SimulationNormalisation)

is_nonlinear()[source]#

Return true if the GKCode is nonlinear, otherwise return False

Return type:

bool

norm_convention: str = 'gs2'#

Convention used for normalising this code’s quantities

pyro_gs2_miller = {'Rmaj': ['theta_grid_parameters', 'rmaj'], 'beta_prime': ['theta_grid_eik_knobs', 'beta_prime_input'], 'dZ0dr': ['theta_grid_parameters', 'shiftvert'], 'kappa': ['theta_grid_parameters', 'akappa'], 'q': ['theta_grid_parameters', 'qinp'], 'rho': ['theta_grid_parameters', 'rhoc'], 'shat': ['theta_grid_eik_knobs', 's_hat_input'], 'shift': ['theta_grid_parameters', 'shift']}#
pyro_gs2_miller_defaults = {'Rmaj': 3.0, 'beta_prime': 0.0, 'dZ0dr': 0.0, 'kappa': 1.0, 'q': 1.5, 'rho': 0.5, 'shat': 0.0, 'shift': 0.0}#
pyro_gs2_mxh = {'Rmaj': ['theta_grid_parameters', 'rmaj'], 'beta_prime': ['theta_grid_eik_knobs', 'beta_prime_input'], 'cn': ['theta_grid_parameters', 'c_mxh'], 'dZ0dr': ['theta_grid_parameters', 'shiftvert'], 'dcndr': ['theta_grid_parameters', 'dc_mxh_dr'], 'dsndr': ['theta_grid_parameters', 'ds_mxh_dr'], 'kappa': ['theta_grid_parameters', 'akappa'], 'n_moments': ['theta_grid_parameters', 'n_mxh'], 'q': ['theta_grid_parameters', 'qinp'], 'rho': ['theta_grid_parameters', 'rhoc'], 'shat': ['theta_grid_eik_knobs', 's_hat_input'], 'shift': ['theta_grid_parameters', 'shift'], 'sn': ['theta_grid_parameters', 's_mxh']}#
pyro_gs2_mxh_defaults = {'Rmaj': 3.0, 'beta_prime': 0.0, 'cn': [0.0, 0.0, 0.0, 0.0, 0.0], 'dZ0dr': 0.0, 'dcndr': [0.0, 0.0, 0.0, 0.0, 0.0], 'dsndr': [0.0, 0.0, 0.0, 0.0, 0.0], 'kappa': 1.0, 'n_moments': 5, 'q': 1.5, 'rho': 0.5, 'shat': 0.0, 'shift': 0.0, 'sn': [0.0, 0.0, 0.0, 0.0, 0.0]}#
pyro_gs2_species = {'dens': 'dens', 'inverse_ln': 'fprim', 'inverse_lt': 'tprim', 'mass': 'mass', 'nu': 'vnewk', 'temp': 'temp', 'z': 'z'}#
read_dict(input_dict, detect_norm=True)[source]#

Reads GS2 input file given as dict Uses default read_dict, which assumes input is a dict

Return type:

Dict[str, Any]

Parameters:
read_from_file(filename, detect_norm=True)[source]#

Reads GS2 input file into a dictionary

Return type:

Dict[str, Any]

Parameters:
read_str(input_string, detect_norm=True)[source]#

Reads GS2 input file given as string Uses default read_str, which assumes input_string is a Fortran90 namelist

Return type:

Dict[str, Any]

Parameters:
  • input_string (str)

  • detect_norm (bool)

set(local_geometry, local_species, numerics, local_norm=None, template_file=None, code_normalisation=None, **kwargs)[source]#

Set self.data using LocalGeometry, LocalSpecies, and Numerics. These may be obtained via another GKInput file, or from Equilibrium/Kinetics objects.

Parameters:
verify_file_type(filename)[source]#

Ensure this file is a valid gs2 input file, and that it contains sufficient info for Pyrokinetics to work with

Parameters:

filename (PathLike | str)

write(filename, float_format='', local_norm=None, code_normalisation=None)[source]#

Writes self.data to an input file

Default version assumes a Fortran90 namelist

Parameters: