EbysusFluid
- class PlasmaCalcs.hookups.ebysus.ebysus_dimensions.EbysusFluid(name=None, i=None, *, m=None, q=None, SL, element=None, atomfile=None)
Bases:
Fluida single Fluid for Ebysus. Similar to Fluid but also knows more details.
Electrons have SL=(0,0), element=’e-’, and atomfile=None.SL: None or (ispecie, ilevel).SL will always internally be stored as tuple(SL).element: None or strelement name, e.g. ‘H’, ‘He’, ‘C’, ‘Fe’.atomfile: None, str, or EbysusAtomfileatomfile associated with this fluid.(multiple fluids might share the same atomfile object.)SL[1] corresponds to the level number within this atomfile.Fluid docstring copied below for convenience:———————————————fluid… unchanging properties of the fluid.name: the name (str) of the fluid. if None, cannot convert to str.i: the index (int) of the fluid (within a FluidList). if None, cannot convert to int.other inputs should be in “elementary” units, i.e.:m: mass, in atomic mass units (1 for H+)q: charge, in elementary charge units (1 for H+; -1 for e-)Methods
__eq__(v)return self==v.
__init_subclass__(*[, _serial_typename])register cls as a subclass of XarrayIoSerializable.
array_equals(other)return whether self == other (which is assumed to be a numpy array or xarray.DataArray).
copy(**kw_init)return a copy of self.
deserialize(serial)creates an XarrayIoSerializable object from a serialized representation.
electron([name, i, m])create an electron EbysusFluid (with q=-1, SL=(0,0), element='e-', atomfile=None).
returns whether self == v (another DimensionValue), ignoring i.
from_dict(d)return cls from dict d.
tells whether self is a charged fluid.
tells whether self is an electron.
is_ion()tells whether self is an ion.
tells whether self is a neutral fluid.
tells whether self is not an electron, i.e. self.q >= 0.
returns dict for looking up self within a DimensionValueList, given int, str, or self.
register_type(cls_to_register[, ...])register cls_to_register as a serializable subclass of XarrayIoSerializable.
return dict of info about self, including 'typename' key.
to_dict()return dictionary of info about self.
with_i(i)return copy of self with i=i, or self if self.i==i already.
_assert_array_equals(other)raise DimensionValueError unless self.array_equals(other).
_assert_single(vals, *[, meaning])assert len(vals)==1.
contents used by self.__repr__
return simple repr for self: Classname(s, i).
Attributes
FLUIDS_WITH_LLFLUIDS_WITH_SLFLUIDS_WITH_SSFLUID_WITH_LLFLUID_WITH_SLFLUID_WITH_SSLalias to L
SSERIAL_TYPESalias to S
alias to self.atomfile.abundance
alias to s
ndimsize- property LL
alias to L
- property SS
alias to S
- __eq__(v)
return self==v. 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, just compares self.s==v.s and self.i==v.i.Subclasses may add more kwargs to compare by altering _kw_def.- or, self.s == v or self.i == v, and v is not another DimensionValue- or, v is a DimensionSingleValueSpecifier and v.checker(self) gives True.Not equal if v is a DimensionValue but not an instance of type(self),e.g. class Fluid(DimensionValue):…; class Snap(DimensionValue):…;Fluid(‘H’, 0) != Snap(‘H’, 0).
- classmethod __init_subclass__(*, _serial_typename=None, **kw)
register cls as a subclass of XarrayIoSerializable.
_serial_typename: None or str
name to use for this type, for serialization purposes.None –> use cls.__name__.This method also sets cls._serial_typename = _serial_typename.
- _assert_array_equals(other)
raise DimensionValueError unless self.array_equals(other).
- classmethod _assert_single(vals, *, meaning='value')
assert len(vals)==1. Raise DimensionKeyError if len==0; DimensionValueError if len>=2.
meaning can be provided to clarify what vals should represent, in case of crash;error message will be ‘expected exactly 1 {meaning}, but got {len(vals)}’.This check tends to make more sense coming from a DimensionValueList,but it is convenient to attach here too in case of using isel from an array.
- _dimension_key_error
alias of
FluidKeyError
- _dimension_value_error
alias of
FluidValueError
- _repr_contents()
contents used by self.__repr__
- _repr_simple()
return simple repr for self: Classname(s, i).
if s is None, use Classname(i) instead.if i is None, use Classname(s, i=None) instead.Called when using PlasmaCalcs.tools.repr_simple.
- property abundance
alias to self.atomfile.abundance
- array_equals(other)
return whether self == other (which is assumed to be a numpy array or xarray.DataArray).
return False if other.size != 1. Else, compare to other.item().(Extremely convenient if comparing to xarray DataArray or numpy array,with potentially unknown size / dimensionality.Also, convenient if “self” might be DimensionValueList instead,because DimensionValueList also provides an array_equals method.)
- 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)
create an electron EbysusFluid (with q=-1, SL=(0,0), element=’e-’, atomfile=None).
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.
- 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.
- is_nonelectron()
tells whether self is not an electron, 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
- static register_type(cls_to_register, _serial_typename=None)
register cls_to_register as a serializable subclass of XarrayIoSerializable.
_serial_typename: str or Nonename to use for serialization. if None, use cls_to_register.__name__.
- serialize()
return dict of info about self, including ‘typename’ key.
- 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.