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)

__init__(**fields) None[source]

Constructor

No longer accepts attribution addition

Methods

__init__(**fields)

Constructor

apply(fun[, inplace, metadata])

Overriding the LabeledCollection.apply method

as_empty()

overriding the LabeledCollection.as_empty method

copy()

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.

subset_B_bound()

Extract subset of B field at the boundary.

subset_B_bound_cyl()

Extract subset of B field at the boundary, cylindrical coordinates.

subset_B_equator()

Extract subset of B field on equatorial plane.

subset_mag()

Extract subset of magnetic quantities.

subset_moments()

Extract subset of magnetic moments.

vorticity()

Extract vorticity equation.

Attributes

cg_field_names

iter_filter

iter_filter: bool determines whether None fields are skipped.

iter_name

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_filter[source]

iter_filter: bool determines whether None fields are skipped.

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:
  • sub_map (dict) – a substitution map

  • inplace (bool) – whether the change is made in place; default is False

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 are sympy.Expr type. Then, this method calls apply internally to substitute all the variables.

subset_B_bound()[source]

Extract subset of B field at the boundary.

subset_B_bound_cyl()[source]

Extract subset of B field at the boundary, cylindrical coordinates.

subset_B_equator()[source]

Extract subset of B field on equatorial plane.

subset_mag()[source]

Extract subset of magnetic quantities.

subset_moments()[source]

Extract subset of magnetic moments.

vorticity()[source]

Extract vorticity equation. Basically an alias as Psi