pyrokinetics.gk_code.cgyro.GKOutputReaderCGYRO#

class pyrokinetics.gk_code.cgyro.GKOutputReaderCGYRO[source]#

Bases: FileReader

__init__()#

Methods

__init__()

infer_path_from_input_file(filename)

Given path to input file, guess at the path for associated output files.

load_momentum_components(pyro)

Load additional momentum-flux outputs from bin.cgyro.ky_flux_mom.

read_from_file(filename, norm[, ...])

Read and process the data from a file.

verify_file_type(dirname)

Perform a series of checks on the file to ensure it is valid.

Attributes

fields = ['phi', 'apar', 'bpar']#
file_type: ClassVar[str] = 'CGYRO'#
static infer_path_from_input_file(filename)[source]#

Given path to input file, guess at the path for associated output files. For CGYRO, simply returns dir of the path.

Return type:

Path

Parameters:

filename (PathLike | str)

static load_momentum_components(pyro)[source]#

Load additional momentum-flux outputs from bin.cgyro.ky_flux_mom. This file can be generated by setting MOMENTUM_PRINT_FLAG = 1 in the CGYRO input file, support for which is available from CGYRO commit

534ebc786c83fa1f1ed8dc1ad15193c20d421f72

The returned data has shape

(field, momentum_component, species, ky, time)

where momentum_component contains:

  • "parallel"

    Contribution from the parallel-flow and centrifugal terms.

  • "perpendicular"

    Contribution from perpendicular flows.

  • "electromagnetic"

    Contribution from electromagnetic-field terms in the momentum-transport equation, related to the Maxwell stress.

Notes

The sum of the "parallel" and "perpendicular" components reproduce the standard momentum-flux outputs natively supported by Pyrokinetics.

moments = ['n', 'e', 'v']#
read_from_file(filename, norm, output_convention='pyrokinetics', load_fields=True, load_fluxes=True, load_moments=False, downsample={})[source]#

Read and process the data from a file.

Parameters:
  • filename (PathLike) – The file to be read.

  • *args – Additional positional arguments used by the derived file reader.

  • **kwargs – Keyword arguments used by the derived file reader.

  • norm (SimulationNormalisation)

  • output_convention (str)

  • downsample (Dict[str, Any])

Returns:

Derived classes may return any type of data from this function.

Return type:

Any

Notes

Rather than accepting *args and/or **kwargs, it is recommended that derived classes should specify their keywords explicitly.

verify_file_type(dirname)[source]#

Perform a series of checks on the file to ensure it is valid. Raises an exception if the file is of the wrong type. Exits normally if the file is valid.

The default implementation simply reads the file, performs the usual processing, and discards the results. This is rarely the best way to verify a file type, so this should be overridden is most cases. In particular, the default implementation should not be used if:

  • Reading and processing the whole file is computationally expensive.

  • The read function depends upon keyword arguments.

  • The read function can read multiple related file types and further information is needed to differentiate between them. For example, multiple gyrokinetics codes use Fortran namelists as input files, so a specialised verify method is needed to check the names stored within to determine which code the input file belongs to.

  • An exception raised when reading from file should halt the program.

Parameters:
  • filename (PathLike) – The file to be read.

  • dirname (PathLike | str)