pg_utils.pg_model.base.CollectionConjugate
- class pg_utils.pg_model.base.CollectionConjugate(**fields)[source]
Bases:
LabeledCollection
Base class for the collection of conjugate variables
These correspond to the conjugate counterpart of PG variables, fields and equations.
The field names are pre-defined, and arranged in the following way
Stream function (Psi)
- Conjugate variables of the quadratic moments of magnetic field
(M_1, M_p, M_m, M_zp, M_zm, zM_1, zM_p, zM_m)
- Conjugate variables of the magnetic fields in the equatorial plane
(B_ep, B_em, Bz_e, dB_dz_ep, dB_dz_em)
- Magnetic fields at the boundary
(Br_b, B_pp, B_pm, Bz_p, B_mp, B_mm, Bz_m)
Methods
__init__
(**fields)Constructor
apply
(fun[, inplace, metadata])Overriding the
LabeledCollection.apply
methodas_empty
()overriding the
LabeledCollection.as_empty
methodcopy
()Deep copy
deserialize
(obj[, parser])Deserialize object
generate_collection
(index_array)Generate a new collection based on indices
load_json
(fp[, parser])Load CollectionConjugate object from json
save_json
(fp[, serializer])Serialize the object in string format and save to json file
serialize
([serializer])Serialize the object
subs
(sub_map[, inplace])Substitute variables iteratively in all fields.
Extract subset of B field at the boundary.
Extract subset of B field at the boundary, cylindrical coordinates.
Extract subset of B field on equatorial plane.
Extract subset of magnetic quantities.
Extract subset of magnetic moments.
Extract vorticity equation.
Attributes
cg_field_names
iter_filter: bool determines whether None fields are skipped.
iter_name: bool determines whether the string of the field is also returned.
- apply(fun: Callable[[...], Any], inplace: bool = False, metadata: bool = False) CollectionConjugate [source]
Overriding the
LabeledCollection.apply
method
- as_empty() CollectionConjugate [source]
overriding the
LabeledCollection.as_empty
method
- copy() CollectionConjugate [source]
Deep copy
overriding the
LabeledCollection.copy
method
- static deserialize(obj: ~typing.List[tuple], parser: ~typing.Callable[[str], ~typing.Any] = <function CollectionConjugate.<lambda>>) CollectionConjugate [source]
Deserialize object
overriding the
LabeledCollection.deserialize
method
- generate_collection(index_array: List[bool]) LabeledCollection [source]
Generate a new collection based on indices
- Parameters:
index_array (List[bool]) – array of booleans indicating whether a field is to be included in the new collection
- Returns:
new collection with elements specified by index_array
- property iter_name[source]
iter_name: bool determines whether the string of the field is also returned.
- static load_json(fp: ~typing.TextIO, parser: ~typing.Callable[[str], ~typing.Any] = <function CollectionConjugate.<lambda>>) CollectionConjugate [source]
Load CollectionConjugate object from json
overriding the
LabeledCollection.load_json
method
- save_json(fp: ~typing.TextIO, serializer: ~typing.Callable[[~typing.Any], str] = <class 'str'>) None [source]
Serialize the object in string format and save to json file
- Parameters:
fp (TextIO) – file handle of the output file
serializer (Callable[[Any], str]) – a callable that maps an element to a string. Default is the
str
method.
- serialize(serializer: ~typing.Callable[[~typing.Any], str] = <class 'str'>) List[tuple] [source]
Serialize the object
- Parameters:
serializer (Callable[[Any],str]) – a callable that maps an element to a string. Default is the
str
method.- Returns:
a list of serialized objects, in the format [(fname_1, serialized_element_1), (fname_2, serialized_element_2), …]
- subs(sub_map: dict, inplace: bool = False)[source]
Substitute variables iteratively in all fields. This utility is for collections with sympy.Expr elements. See warning below.
- Parameters:
Warning
To use this method, all elements in the collection need to have implemented the
subs
method. This is intended for a collection of which all elements aresympy.Expr
type. Then, this method callsapply
internally to substitute all the variables.