pyrokinetics.numerics.Numerics#

class pyrokinetics.numerics.Numerics(ntheta=32, nperiod=1, nenergy=8, npitch=8, nky=1, nkx=1, ky=0.1, kx=0.0, delta_time=0.001, max_time=500.0, theta0=0.0, phi=True, apar=False, bpar=False, beta=None, nonlinear=False, gamma_exb=None, _metadata=None, title=None, _already_warned=False)[source]#

Bases: object

Stores information describing numerical features common to most gyrokinetics solvers, such as the dimensions of numerical grids, the presence of electromagnetic field components, and time steps. Numerics is not used to store special flags belonging to only one gyrokinetics code.

Parameters:
__init__(ntheta=32, nperiod=1, nenergy=8, npitch=8, nky=1, nkx=1, ky=0.1, kx=0.0, delta_time=0.001, max_time=500.0, theta0=0.0, phi=True, apar=False, bpar=False, beta=None, nonlinear=False, gamma_exb=None, _metadata=None, title=None, _already_warned=False)#

Methods

__init__([ntheta, nperiod, nenergy, npitch, ...])

from_json(json_str[, overwrite_metadata, ...])

Creates a new Numerics from a previously saved Numerics json.

items()

Dict-like items iteration

to_json(**kwargs)

Converts self to json string.

units(name, c)

rtype:

Unit

values()

Dict-like values iteration

with_units(c)

Apply units to each quantity in turn and return a new Coords.

Attributes

apar

Boolean flag denoting whether this run evolves the \(A_\parallel\) field (component of the magnetic vector potential running parallel to the field line)

beta

Ratio of plasma pressure to magnetic pressure

bpar

Boolean flag denoting whether this run evolves the \(B_\parallel\) field (component of the magnetic flux density running parallel to the field line)

coords

Tuple containing the names of each supplied field (those that aren't None).

delta_time

Initial time step, in units of lref / vref

gamma_exb

Perpendicular ExB shearing rate vref / lref

kx

Value of \(k_x\rho\)

ky

Value of \(k_y\rho\)

max_time

Time step, in units of lref / vref

names

Names of all quantities held by this dataclass

nenergy

Number of elements in the energy grid

nkx

Number of elements in the velocity-space \(k_x\) grid

nky

Number of elements in the velocity-space \(k_y\) grid

nonlinear

Boolean flag noting whether this run includes non-linear features

nperiod

Number of \(2\pi\) segments in the toroidal direction.

npitch

Number of elements in the pitch grid

ntheta

Number of elements in the \(\theta\) (poloidal) grid

phi

Boolean flag denoting whether this run evolves the \(\phi\) field (electric potential).

theta0

The ballooning angle (the point at which the radial wavenumber is zero)

title

Title to be written to _metadata.

apar: bool = False#

Boolean flag denoting whether this run evolves the \(A_\parallel\) field (component of the magnetic vector potential running parallel to the field line)

beta: Optional[float] = None#

Ratio of plasma pressure to magnetic pressure

bpar: bool = False#

Boolean flag denoting whether this run evolves the \(B_\parallel\) field (component of the magnetic flux density running parallel to the field line)

property coords: Tuple[str, ...]#

Tuple containing the names of each supplied field (those that aren’t None).

delta_time: float = 0.001#

Initial time step, in units of lref / vref

classmethod from_json(json_str, overwrite_metadata=False, overwrite_title=None, **kwargs)[source]#

Creates a new Numerics from a previously saved Numerics json.

Parameters:
  • json_str (str) – Json string to read

  • overwrite_metadata (bool, default False) – Take ownership of the Json data, overwriting attributes such as ‘title’, ‘software_name’, ‘date_created’, etc.

  • overwrite_title (Optional[str]) – If overwrite_metadata is True, this is used to set the title attribute in self._metadata. If unset, the class name is used.

  • **kwargs (Any) – Keyword arguments forwarded to json.loads

Examples

with open("my_numerics.json", "r") as f:
    my_numerics = Numerics.from_json(f.read())
gamma_exb: Optional[float] = None#

Perpendicular ExB shearing rate vref / lref

items()[source]#

Dict-like items iteration

Return type:

Generator[Tuple[str, Any], None, None]

kx: float = 0.0#

Value of \(k_x\rho\)

ky: float = 0.1#

Value of \(k_y\rho\)

max_time: float = 500.0#

Time step, in units of lref / vref

property names: Tuple[str, ...]#

Names of all quantities held by this dataclass

nenergy: int = 8#

Number of elements in the energy grid

nkx: int = 1#

Number of elements in the velocity-space \(k_x\) grid

nky: int = 1#

Number of elements in the velocity-space \(k_y\) grid

nonlinear: bool = False#

Boolean flag noting whether this run includes non-linear features

nperiod: int = 1#

Number of \(2\pi\) segments in the toroidal direction.

npitch: int = 8#

Number of elements in the pitch grid

ntheta: int = 32#

Number of elements in the \(\theta\) (poloidal) grid

phi: bool = True#

Boolean flag denoting whether this run evolves the \(\phi\) field (electric potential).

theta0: float = 0.0#

The ballooning angle (the point at which the radial wavenumber is zero)

title: InitVar = None#

Title to be written to _metadata. Defined as an ‘InitVar’ meaning this isn’t a variable stored by the dataclass, but instead is an optional argument to the constructor. It is used in the __post_init__ function. If unset, this defaults to the class name.

to_json(**kwargs)[source]#

Converts self to json string. Includes metadata describing the current Pyrokinetics session.

Parameters:

**kwargs (Any) – Parameters passed on to json.dumps

Return type:

str

Examples

with open("my_numerics.json", "w") as f:
    # Use indent=4 for pretty print
    f.write(my_numerics.to_json(indent=4))
units(name, c)[source]#
Return type:

Unit

Parameters:
values()[source]#

Dict-like values iteration

Return type:

Generator[Any, None, None]

with_units(c)[source]#

Apply units to each quantity in turn and return a new Coords. If units are already applied, renormalises according to the convention supplied.

Parameters:

c (ConventionNormalisation)