PlasmaCalcs.mhd.elements.Element

class PlasmaCalcs.mhd.elements.Element(name=None, i=None, *, m=None, ionize_ev=None, saha_g1g0=None, abundance=None)

Bases: Fluid

Fluid corresponding to an element, including ions AND neutrals.
CAUTION: some code assumes (without checking) that Element objects are immutable.
Changing an Element after creating it could lead to unexpected behavior.
name: None or str
name of this element. None –> name unknown.
defaults assume names will be title-case element symbol, e.g. ‘H’, ‘He’;
using different names is allowed but will prevent default lookups.
i: None or int
index of this element (within an ElementList). None –> index unknown.
m: None or number
mass, in atomic mass units. E.g., ~1 for H.
ionize_ev: None or number
first ionization potential [eV]. E.g., ~13.6 for H.
saha_g1g0: None or number
ratio of g (degeneracy of states) for g1 (ions) to g0 (neutrals). E.g., 0.5 for H.
abundance: None or number
abundance of this element relative to H:
A(elem) = 12 + log10(n(elem) / n(H)), n = number density.
if not provided, trying to get abundance-related quantities will crash.
internally, q=None always, because elements have no charge info.
__init__(name=None, i=None, *, m=None, ionize_ev=None, saha_g1g0=None, abundance=None)

Methods

__init__([name, i, m, ionize_ev, saha_g1g0, ...])

copy(**kw_init)

deserialize(serial)

equal_except_i(v)

from_dict(d)

get_element(*args__None, **kw__None)

get_elements(*args__None, **kw__None)

ion([q])

is_charged()

is_electron()

is_ion()

is_neutral()

lookup_dict()

n_per_nH()

neutral(**kw_specie)

r_per_nH()

register_type(cls_to_register[, ...])

saha_list(*[, istart])

serialize()

to_dict()

with_i(i)

Attributes

SERIAL_TYPES

element

get_I

get_II

name

ndim

size

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]
property element
alias to self. because self (an Element) is the element corresponding to self.
element_cls

alias of Element

equal_except_i(v)
returns whether self == v (another DimensionValue), ignoring i.
equal if v is an instance of type(self) and
all 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.
property get_I
alias to neutral
property get_II
alias to ion
get_element(*args__None, **kw__None)
return self (because self is an Element…).
(ElementHaver-related logic expects this method to exist.)
get_elements(*args__None, **kw__None)
return [self] (because self is an Element…).
(ElementHaver-related logic expects this method to exist.)
ion(q=1, **kw_specie)
return ionized Specie of self.get_element()

q: charge in elementary charge units. (default: +1)

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)
n_per_nH()
return n(elem)/n(H) for this element. n = number density
property name
alias to s
neutral(**kw_specie)
return neutral Specie of self.get_element().
r_per_nH()
return r(elem)/n(H) for this element. r = mass density
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_cls

alias of Specie

specie_list_cls

alias of SpecieList

to_dict()
return dictionary of info about self. Attribute values for keys in self._kw_def.
e.g. if _kw_def={‘s’, ‘i’}: result = {‘s’: self.s, ‘i’: self.i}
with_i(i)
return copy of self with i=i, or self if self.i==i already.