pyrokinetics.gk_code.gk_input.GKInput#
- class pyrokinetics.gk_code.gk_input.GKInput(filename=None)[source]#
Bases:
AbstractFileReader,ReadableFromFileBase for classes that store gyrokinetics code input files in a dict-like format. They faciliate translation between input files on disk, and
Numerics,LocalGeometry, andLocalSpeciesobjects.GKInputdiffers fromGKOutput,EquilibriumandKineticsin that it is both the ‘reader’ and the ‘readable’. Each subclass should define the methodsread_from_fileandverify_file_type.read_from_fileshould populateself.dataand return this information as a dict.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 object from self.data
get local species object from self.data
get numerical info (grid spacing, time steps, etc) from self.data
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
Conventionused 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:
- abstract get_numerics()[source]#
get numerical info (grid spacing, time steps, etc) from self.data
- Return type:
- abstract is_nonlinear()[source]#
Return true if the GKCode is nonlinear, otherwise return False
- Return type:
-
norm_convention:
str= 'pyrokinetics'# Conventionused 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
- 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
- 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
- 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:
local_geometry (LocalGeometry)
local_species (LocalSpecies)
numerics (Numerics)
local_norm (SimulationNormalisation | None)
- 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.