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:
values
()Dict-like values iteration
with_units
(c)Apply units to each quantity in turn and return a new
Coords
.Attributes
Boolean flag denoting whether this run evolves the \(A_\parallel\) field (component of the magnetic vector potential running parallel to the field line)
Ratio of plasma pressure to magnetic pressure
Boolean flag denoting whether this run evolves the \(B_\parallel\) field (component of the magnetic flux density running parallel to the field line)
Tuple containing the names of each supplied field (those that aren't
None
).Initial time step, in units of
lref / vref
Perpendicular ExB shearing rate
vref / lref
Value of \(k_x\rho\)
Value of \(k_y\rho\)
Time step, in units of
lref / vref
Names of all quantities held by this dataclass
Number of elements in the energy grid
Number of elements in the velocity-space \(k_x\) grid
Number of elements in the velocity-space \(k_y\) grid
Boolean flag noting whether this run includes non-linear features
Number of \(2\pi\) segments in the toroidal direction.
Number of elements in the pitch grid
Number of elements in the \(\theta\) (poloidal) grid
Boolean flag denoting whether this run evolves the \(\phi\) field (electric potential).
The ballooning angle (the point at which the radial wavenumber is zero)
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)
-
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
).
- 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 readoverwrite_metadata (
bool
, defaultFalse
) – Take ownership of the Json data, overwriting attributes such as ‘title’, ‘software_name’, ‘date_created’, etc.overwrite_title (
Optional[str]
) – Ifoverwrite_metadata
isTrue
, this is used to set thetitle
attribute inself._metadata
. If unset, the class name is used.**kwargs (
Any
) – Keyword arguments forwarded tojson.loads
Examples
with open("my_numerics.json", "r") as f: my_numerics = Numerics.from_json(f.read())
-
phi:
bool
= True# Boolean flag denoting whether this run evolves the \(\phi\) field (electric potential).
-
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 tojson.dumps
- Return type:
Examples
with open("my_numerics.json", "w") as f: # Use indent=4 for pretty print f.write(my_numerics.to_json(indent=4))