PlasmaCalcs.mhd.multifluid.mhd_fluids.Specie
- class PlasmaCalcs.mhd.multifluid.mhd_fluids.Specie(name=UNSET, i=None, *, q, m=UNSET, element=None)
Bases:
ElementHaverFluid corresponding to a specie, e.g. H_I, H_II, e, Fe_II.(code uses ‘specie’ as singular of ‘species’, to clarify singular vs plural.)- CAUTION: some code assumes (without checking) that Specie objects are immutable.
- Changing a Specie after creating it could lead to unexpected behavior.
species usually have a name. Every specie has a charge (possibly charge=0)non-electron species should also have an associated Element.- name: UNSET, None, or str
- name of this specie.UNSET –> infer from element and q; None if no element.inferred name will be element name + roman numeral based on q,e.g. H_I for neutral H, H_II for H+.None –> cannot convert self to str.
- i: None or int
- the index of this specie (within a SpecieList).None –> cannot convert self to int.
- q: number
- charge, in elementary charge units (e.g. -1 for electrons, +1 for H_II)
- m: UNSET, None, or number
- mass, in atomic mass units (e.g. ~1 for H_I or H_II).UNSET –> use element.m.None –> cannot get self.m
- element: None, dict, or Element
- Element associated with this specie.dict –> convert to Element via Element.from_dict(element).
- __init__(name=UNSET, i=None, *, q, m=UNSET, element=None)
Methods
__init__([name, i, m, element])copy(**kw_init)deserialize(serial)electron([name, i, m])from_dict(d)from_element(element[, i])get_element([default])get_elements([default])ion(element[, i, q])is_ion()neutral(element[, i])register_type(cls_to_register[, ...])saha_list(*[, istart])to_dict(*[, element_to_dict])with_i(i)Attributes
SERIAL_TYPESndimsize- copy(**kw_init)
- return a copy of self. Can provide new kwargs here to override old values in result.E.g. self.copy(i=7) makes a copy of self but with i=7 instead of self.i.
- static deserialize(serial)
- creates an XarrayIoSerializable object from a serialized representation.
- serial: dict or str
- str –> convert to dict via ast.literal_eval.dict must contain ‘typename’ key.
The output here will be an instance of XarrayIoSerializable.SERIAL_TYPES[typename]
- classmethod electron(name='e', i=None, *, m=UNSET, **kw_init)
- create an electron Specie (with q=-1).
m: if UNSET, use physical value: DEFAULTS.PHYSICAL.CONSTANTS_SI[‘me amu-1’]
- equal_except_i(v)
- returns whether self == v (another DimensionValue), ignoring i.equal if v is an instance of type(self) andall kw from both self._kw_eq and v._kw_eq have the same values.(any kw missing attrs will be treated as UNSET.)For DimensionValue: self.s==v.s and self.i==v.i. Subclasses may add more.
- classmethod from_dict(d)
- return cls from dict d.If ‘d’ contains ‘typename’, result is like cls.deserialize(d) instead,however, first require that result is an instance of cls (or subclass of cls).E.g. Fluid.from_dict(dict(typename=’EppicDist’, …)) returns EppicDist,but Snap.from_dict(dict(typename=’EppicDist’, …)) crashes with InputError.Subclasses wishing to alter deserialize behavior will probably override this method instead.
- classmethod from_element(element, i=None, *, q, **kw_init)
- create a Specie from this Element (& charge q [elementary charge units]).name and m inferred from element and q, unless provided explicitly here.
- property get_I
- alias to neutral
- property get_II
- alias to ion
- get_element(default=NO_VALUE)
- return self.element if it exists and is not None, else crash with FluidKeyError.
- default: NO_VALUE or any value.
- If provided, when element missing or None, return default instead of crash.
- get_elements(default=NO_VALUE)
- return list of elements in self.The implementation here just returns [self.get_element(default=default)].
- classmethod ion(element, i=None, *, q=1, **kw_init)
- create an ion Specie from element and q [elementary charge units]
element: Element object. Used to infer name and m, by default.
- is_charged()
- tells whether self is a charged fluid. i.e. self.q != 0.if self.q is None, returns None instead of bool.
- is_electron()
- tells whether self is an electron. i.e. self.q < 0.if self.q is None, returns None instead of bool.
- is_ion()
- tells whether self is an ion. i.e. self.q > 0.if self.q is None, returns None instead of bool.
- is_neutral()
- tells whether self is a neutral fluid. i.e. self.q == 0.if self.q is None, returns None instead of bool.
- lookup_dict()
- returns dict for looking up self within a DimensionValueList, given int, str, or self.(used by DimensionValueList.lookup_dict)
- property name
- alias to s
- classmethod neutral(element, i=None, **kw_init)
- create a neutral Specie (with q=0) from element.
element: Element object. Used to infer name and m, by default.
- static register_type(cls_to_register, _serial_typename=None)
- register cls_to_register as a serializable subclass of XarrayIoSerializable.
- _serial_typename: str or None
- name to use for serialization. if None, use cls_to_register.__name__.
- saha_list(*, istart=0, **kw_specie)
- return SpecieList of neutral & once-ionized ions of self.get_element().
istart: start index for the SpecieList. Index affects conversion to int.
- serialize()
- return dict of info about self, including ‘typename’ key.
- specie_list_cls
alias of
SpecieList
- to_dict(*, element_to_dict=True)
- return dictionary of info about self. Attribute values for keys in self._kw_def.e.g. if _kw_def={‘name’, ‘i’, ‘m’}, then result = {‘name’: self.name, ‘i’: self.i, ‘m’: self.m}
- element_to_dict: bool, default True
- whether to also convert result[‘element’].to_dict() too, if non-None ‘element’ in result.
- with_i(i)
- return copy of self with i=i, or self if self.i==i already.