pyrokinetics.gk_code.gk_input.GKInput#

class pyrokinetics.gk_code.gk_input.GKInput(filename=None)[source]#

Bases: AbstractFileReader, ReadableFromFile

Base for classes that store gyrokinetics code input files in a dict-like format. They faciliate translation between input files on disk, and Numerics, LocalGeometry, and LocalSpecies objects.

GKInput differs from GKOutput, Equilibrium and Kinetics in that it is both the ‘reader’ and the ‘readable’. Each subclass should define the methods read_from_file and verify_file_type. read_from_file should populate self.data and return this information as a dict.

Parameters:

filename (PathLike | str | None)

__init__(filename=None)[source]#
Parameters:

filename (PathLike | str | None)

Methods

__init__([filename])

add_flags(flags)

Add extra flags to a GK code 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()

get local geometry object from self.data

get_local_species()

get local species object from self.data

get_numerics()

get numerical info (grid spacing, time steps, etc) from self.data

is_linear()

is_nonlinear()

Return true if the GKCode is nonlinear, otherwise return False

read_dict(gk_dict[, detect_norm])

Reads in dictionary equivalent of a GK input file and stores as internal dictionary.

read_from_file(filename[, detect_norm])

Reads in GK input file to store as internal dictionary.

read_str(input_string[, detect_norm])

Reads in GK input file as a string, stores as internal dictionary.

set(local_geometry, local_species, numerics)

Build self.data from geometry/species/numerics objects.

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 file is valid for a given GK input type.

write(filename[, float_format, local_norm])

Writes self.data to an input file

Attributes

norm_convention

Convention used for normalising this code's quantities

abstract add_flags(flags)[source]#

Add extra flags to a GK code input file

Default version assumes a Fortran90 namelist

Return type:

None

classmethod from_str(input_string)[source]#
Parameters:

input_string (str)

abstract get_local_geometry()[source]#

get local geometry object from self.data

Return type:

LocalGeometry

abstract get_local_species()[source]#

get local species object from self.data

Return type:

LocalSpecies

abstract get_numerics()[source]#

get numerical info (grid spacing, time steps, etc) from self.data

Return type:

Numerics

is_linear()[source]#
Return type:

bool

abstract is_nonlinear()[source]#

Return true if the GKCode is nonlinear, otherwise return False

Return type:

bool

norm_convention: str = 'pyrokinetics'#

Convention used for normalising this code’s quantities

abstract read_dict(gk_dict, detect_norm=True)[source]#

Reads in dictionary equivalent of a GK input file and stores as internal dictionary. Sets self.data and also returns a dict

Default version assumes a dict

Return type:

Dict[str, Any]

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

Reads in GK input file to store as internal dictionary. Sets self.data and also returns a dict

Default version assumes a Fortran90 namelist

Return type:

Dict[str, Any]

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

Reads in GK input file as a string, stores as internal dictionary. Sets self.data and also returns a dict

Default version assumes a Fortran90 namelist

Return type:

Dict[str, Any]

Parameters:
  • input_string (str)

  • detect_norm (bool)

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

Build self.data from geometry/species/numerics objects. If self.data does not exist prior to calling this, populates defaults using template_file.

Parameters:
classmethod verify_expected_keys(filename, keys)[source]#

Checks that the expected keys are present at the top level of self.data. Results True if all are present, otherwise returns False.

Return type:

None

Parameters:
abstract verify_file_type(filename)[source]#

Ensure file is valid for a given GK input type. Reads file, but does not perform processing.

Return type:

None

Parameters:

filename (PathLike | str)

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

Writes self.data to an input file

Default version assumes a Fortran90 namelist

Parameters: