Ebysus_mfParamTable

class PlasmaCalcs.hookups.ebysus.ebysus_io_tools.Ebysus_mfParamTable(filename)

Bases: EbysusParamTable

multifluid params table for Ebysus, from mf_param_file (e.g. mf_params.in).

instance behaves like dict of params:
self[key] <–> self.params[key]
self.params.keys() <–> self.params.keys()
self.raw saves basic cleaned file contents,
while self.params is more ready-to-use and has slightly different names,
e.g. convert ints to ints, and rename keys to:
‘nspecies_max’ (NSPECIES_MAX), ‘species’ (SPECIES), ‘eos_tables’ (EOS_TABLES),
‘rec_tables’ (REC_TABLES), ‘ion_tables’ (ION_TABLES),
‘collcross_tables’ (CROSS_SECTIONS_TABLES), ‘coll_keys’ (COLL_KEYS), ‘emask’ (EMASK).
also note ‘coll_keys’ becomes a dict of sets, mapping (SS, jSS) to set of CKEYs,
and saved as a SymmetricPairMapping internally (after confirming it is symmetric,
i.e. for each (S0, S1) in coll_keys, must have same CKEYs for (S1, S0)).
filename: str
path to file. Internally stored as abspath.
Parsed as follows (ignoring comments (# or ;), trimming whitespace and blank lines):
KEY
SOME WHITESPACE SEPARATED VALUES # repeated any number of times, same size each time.
# repeat any number of times (different key each time). Keys can be in any order.
# do NOT include quotation marks, even for string-valued quantities like file paths.
Here is a description of possible keys and the expected formats within each:
NSPECIES_MAX: (required) maximum number of spcies allowed. Also determines “map” shapes in file.
N # (only 1 integer, only 1 row.) Example: N=10
SPECIES: (required) species (e.g. elements; not individual levels) indexes, names, and atomfiles.
SS NAME ATOMFILE
01 H hydrogen.atom # (example)
02 He He_3_2.atom # (example)
EOS_TABLES: equation of state tables
SS EOSFILE
01 H_EOS.dat # (example)
REC_TABLES: recombination tables
SS RECFILE
01 H_REC.dat # (example)
ION_TABLES: ionization tables
SS IONFILE
01 H_ION.dat # (example)
CROSS_SECTIONS_TABLES: collision cross section tables (neutral-neutral and ion-neutral).
SS jSS jLL CROSSFILE # (examples below)
01 01 02 h-p-bruno-fits.txt
01 02 01 he-h-bruno-fits.txt
01 02 02 hep-h-bruno-fits.txt
02 01 01 he-h-bruno-fits.txt # this is allowed, but redundant with the 01 02 01 line.
02 01 02 he-p-bruno-fits.txt
02 02 02 he-hep-bruno-fits.txt
# LL is any neutral level for SS.
# e.g., if (1,1)=H_I, (1,2)=H_II, (2,1)=He_I, (2,2)=He_II, then (H_I,H_II) uses h-p-bruno-fits.txt,
# (H_I,He_II) uses hep-h-bruno-fits.txt, and (H_I,He_I) uses he-h-bruno-fits.txt.
# (Just picked some examples; others are defined too.) Note that order “doesn’t matter”
# for picking table, e.g. above says that (He_II,H_I) should also use hep-h-bruno-fits.txt.
# For pairs with table not provided here, default to “hopefully-reasonable” formulas instead.
COLL_KEYS: collision types to enable between species.
SS jSS CKEY # (examples below)
01 01 EL
01 02 EL
01 02 CL
02 01 EL
02 01 CL
02 02 MX
02 02 EL
# CKEY can be CL (“coulomb”), EL (“elastic”), or MX (“maxwell”).
# For ion-ion collisions, only check CL; collide if CL enabled.
# For neutral-neutral collisions, only check EL; collide if EL enabled.
# For ion-neutral (or neutral-ion) collisions, check EL and MX;
# use whichever are enabled (add results together if both enabled).
# EL uses lookup tables if they exist, else a (probably-bad) guess.
# MX uses a pre-set formula which is hopefully decent in most cases.
# The implementation here will crash if COLL_KEYS are not symmetric,
# i.e. for ((S0, S1), CKEYS01) in COLL_KEYS,
# must have ((S1, S0), CKEYS10) in COLL_KEYS with CKEYS01 == CKEYS10.
#
COLISIONS_MAP: obsolete. Will still be read into self.raw, if it exists.
For backwards compatibility, ensure it is the “default” value,
i.e. N rows with N columns, with N=NSPECIEX_MAX,
with all values along the diagonal and upper triangle greater than 0,
and all values in the lower triangle less than 0.
COLISIONS_MAP_N: obsolete. Same idea as COLISIONS_MAP, but slightly different default;
the default here instead has all values on the diagonal less than 0.
COLISIONS_MAP_I: obsolete. Same idea as COLISIONS_MAP, but slightly different default;
the default here instead has all values on the diagonal less than 0.
EMASK: flags telling something about energy for each species, not sure what. [TODO]
FLAG1 FLAG2 FLAG3 … # must have NSPECIES_MAX flags in total.
# will only check “flag > 0” for each flag.
# index determines species mapping; species SS is mapped to flags[SS].
# indices with no corresponding species are ignored.

Methods

__getitem__(key)

return self.params[key].

__iter__()

raises TypeError; use .keys(), .values(), or .items() instead.

__repr__()

repr(self).

__setitem__(key, value)

set self.params[key] = value.

get(key[, default])

return self[key].

init_from_raw()

initialize stuff from self.raw.

init_params()

initialize self.params.

items()

return tuple of (key, value) pairs corresponding to self.keys() and self.values().

keys()

return keys of self.params.

parse_file()

parse file, returning dict of list of lists of values.

values()

return tuple of values corresponding to self.keys().

_assert_default_colmap(key[, diagonal_positive])

asserts this colmap produces the same behavior as the default value, else crash.

_assert_ncols_matches_nspecies_max(key)

asserts (ncols for this key) == NSPECIES_MAX, else raise FileContentsConflictError.

Attributes

n_species

number of species in self.

nspecies_max

alias to self['nspecies_max'], equivalent to self.params['nspecies_max'].

sizes

dict of lengths of keys' values from self, except for nspecies_max.

__getitem__(key)

return self.params[key].

__iter__()

raises TypeError; use .keys(), .values(), or .items() instead.

__repr__()

repr(self).

__setitem__(key, value)

set self.params[key] = value.

_assert_default_colmap(key, diagonal_positive=False)

asserts this colmap produces the same behavior as the default value, else crash.

_assert_ncols_matches_nspecies_max(key)

asserts (ncols for this key) == NSPECIES_MAX, else raise FileContentsConflictError.

get(key, default=UNSET)

return self[key]. if default is provided and self[key] doesn’t exist, return default.

init_from_raw()

initialize stuff from self.raw.

init_params()

initialize self.params. Includes ‘nspecies_max’ key.

All other keys expected to be added by subclass during init_from_raw().
items()

return tuple of (key, value) pairs corresponding to self.keys() and self.values().

keys()

return keys of self.params.

property n_species

number of species in self. Determined by len(self[‘species’]).

Easily can be less than NSPECIES_MAX from file.
Can be less than largest species number if skipped any,
e.g. if species 1,2,5,7, would have n_species=4.
property nspecies_max

alias to self[‘nspecies_max’], equivalent to self.params[‘nspecies_max’].

parse_file()

parse file, returning dict of list of lists of values.

property sizes

dict of lengths of keys’ values from self, except for nspecies_max.

values()

return tuple of values corresponding to self.keys().