CopapicInputDeck

class PlasmaCalcs.hookups.copapic.copapic_input_deck.CopapicInputDeck(params, distributions, *, filename=None, **kw_super)

Bases: DictlikeFromKeysAndGetitem

info from copapic.json file, in a class.

Use CopapicInputDeck.from_file() to create an instance from a file.
Units are “SI”.
params: dict
values of params
distributions: dict or CopapicDistList
dict of {distribution number: CopapicDist}, or an already-created CopapicDistList.
if dict, will be internally stored as CopapicDistList.from_dict(distributions), instead.
filename: str
path to copapic.json file
str will be internally stored as os.path.abspath(filename), instead.
Examples:
cpid = CopapicInputDeck.from_file(‘copapic.json’)
cpid[1] # CopapicDist for distribution 1
cpid[‘nz’] # number of grid points in z direction
cpid.params # dict of all global params
cpid.dists # CopapicDistList of all the distributions
cpid.dists.get(‘e’) # get CopapicDist with name ‘e’
cpid.dists.get(0) # get CopapicDist number 0 from this list
cpid[2][‘m’] # mass parameter for distribution 2
cpid[0][‘coll_rate’] # collision rate parameter for distribution 0
cpid.keys() # available keys
cpid.items() # available (key, value) pairs
cpid[0].keys() # available keys for distribution 0
cpid.get(‘k’, 7) # eid[‘k’] if it exists, else 7.

Methods

__getitem__(key)

return self.params[key] if key in self.params, else self.dists[key].

__iter__()

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

from_file(filename, *[, dist_names])

return CopapicInputDeck from copapic.json file.

get(key[, default])

return self[key].

get_coord(xstr)

get coordinate array [raw units] for this dimension.

get_dspace(xstr)

get d{x} [raw units] between output cells.

get_dspace_max()

return max of self.Dx, self.Dy, self.Dz.

get_dspace_min()

return min of self.Dx, self.Dy, self.Dz.

get_nspace(xstr)

get number of cells in {x} dimension, accounting for nout_avg and nsubdomains.

get_space_coords()

return dict of {x: xcoord array} for x in self.maindims(), a subset of ('x', 'y', 'z').

get_units_manager(*[, u_l, u_t, u_n, ne_si])

return UnitsManagerPIC for this input deck

is_quasineutral()

return whether this input deck is in quasineutral mode.

items()

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

keys()

return tuple of keys to access self.dists or self.params

maindims()

returns tuple of main dimensions in this input deck.

values()

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

_get_nspace_simple(xstr)

get "simple" number of cells in {x} dimension.

_init_neutral_fluid(dists)

sets self.neutral and self.neutrals based on each distribution.

Attributes

Dx

dx between adjacent output cells [raw units]

Dy

dy between adjacent output cells [raw units]

Dz

dz between adjacent output cells [raw units]

Nx

actual total number of grid cells in the x dimension.

Ny

actual total number of grid cells in the y dimension.

Nz

actual total number of grid cells in the z dimension.

dirname

os.path.dirname(self.filename).

dists

alias to distributions

output_dir

return directory where output files are stored.

property Dx

dx between adjacent output cells [raw units]

property Dy

dy between adjacent output cells [raw units]

property Dz

dz between adjacent output cells [raw units]

property Nx

actual total number of grid cells in the x dimension.

property Ny

actual total number of grid cells in the y dimension.

property Nz

actual total number of grid cells in the z dimension.

__getitem__(key)

return self.params[key] if key in self.params, else self.dists[key].

__iter__()

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

_get_nspace_simple(xstr)

get “simple” number of cells in {x} dimension. == n{x} // nout_avg

xstr should be ‘x’, ‘y’, or ‘z’.
See also: self._get_nspace.
_init_neutral_fluid(dists)

sets self.neutral and self.neutrals based on each distribution.

dists: CopapicDistList
list of distributions.
property dirname

os.path.dirname(self.filename).

if self.filename is None, raise FileNotFoundError.
dist_type

alias of CopapicDist

property dists

alias to distributions

dlist_type

alias of CopapicDistList

classmethod from_file(filename, *, dist_names=None, **kw__init)

return CopapicInputDeck from copapic.json file.

filename: str
path to copapic.json file.
abspath(filename) will be saved to result, for easier bookkeeping.
dist_names: None or dict
{N: name for distribution N} for any number of distributions in filename.
None –> infer from file.
get(key, default=UNSET)

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

get_coord(xstr)

get coordinate array [raw units] for this dimension.

xstr: str
dimension name. ‘x’, ‘y’, or ‘z’.
get_dspace(xstr)

get d{x} [raw units] between output cells.

get_dspace_max()

return max of self.Dx, self.Dy, self.Dz.

get_dspace_min()

return min of self.Dx, self.Dy, self.Dz.

get_nspace(xstr)

get number of cells in {x} dimension, accounting for nout_avg and nsubdomains.

See also: Nx, Ny, Nz.
get_space_coords()

return dict of {x: xcoord array} for x in self.maindims(), a subset of (‘x’, ‘y’, ‘z’).

get_units_manager(*, u_l=None, u_t=None, u_n=None, ne_si=None, **kw_u_from_pic)

return UnitsManagerPIC for this input deck

is_quasineutral()

return whether this input deck is in quasineutral mode.

as a proxy, guessing quasineutral iff any dist.is_hybrid() for dist in self.dists.
items()

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

keys()

return tuple of keys to access self.dists or self.params

maindims()

returns tuple of main dimensions in this input deck.

inferred from self[‘nx’], ‘ny’, ‘nz’, and ‘ndim_space’
neutral_type

alias of CopapicNeutral

nlist_type

alias of CopapicNeutralList

property output_dir

return directory where output files are stored.

values()

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