PlasmaCalcs.hookups.eppic.eppic_choose_params.EppicChooseParams

class PlasmaCalcs.hookups.eppic.eppic_choose_params.EppicChooseParams(ec, var=None, *, values={}, **kw_call_self)

Bases: EppicChooseParamsBase

class to help with choosing parameters for eppic.i file.
ec: EppicCalculator object
the EppicCalculator to use for getting values and directory of original eppic.i file.
var: None, str, or list of strings
tells which getters to use when getting values. See self.GETTERS.keys() for options.
None –> use all vars in self.GETTERS.
str –> use this var.
list –> use these vars.
Use [] to use no vars, i.e. initialize only with user-provided values.
if getting vars gives keys also provided in `values``, use the value from ``values` instead.
values: dict
{varname: value} for pairs to update in new eppic.i file.
Can also provide {dist number: dict of {varname: value} pairs to update for this dist}
(inside of dist number dicts, varname can end with dist number or not;
assume it does end with dist number in the file itself though)
Will be immediately converted to self.values_flat format.
additional kwargs:
passed as self(var, **kw_call) when determining initial values.
Examples:
Basic usage:
choices = EppicChooseParams(eppic_calculator_object) # create instance;
# ^ will also fill choices with defaults based on calculations,
# e.g. including vtherm calculated from temperatures, and dx from ldebye from electrons.
choices.update(…) # any choices of params you specifically want to set can go here.
choices.write(…) # write a new eppic.i file based on the original, and choices.
Other common use case - learn info about timescales:
choices.timescales() # EppicTimescales object
__init__(ec, var=None, *, values={}, **kw_call_self)
create EppicChooseParameters by reading values from EppicCalculator.get_vals_for_inputs()

Methods

__init__(ec[, var, values])

check([var, mode])

check_dt()

check_dx()

check_rosenberg_qn(*[, rosenberg_safety])

failed_check(msg)

get_dt([precision, dt_safety, units])

get_dx([precision, ldebye_safety, units])

get_n([precision, units])

get_v0([precision, units])

get_vtherm([precision, units])

get_vtherm_n([precision, units])

items()

keys()

setdefault([values])

str_from([src, missing_values_ok, comment])

timescales(*[, units])

update([values])

values_flat([values])

write([src, dst, exists_ok, ...])

Attributes

CHECKERS

GETTERS

checks_mode

get

check(var=None, *, mode=UNSET, **kw_checker)
check current values in self.ec for “reasonable-ness”.
var: None, str, or list of strings
tells which checkers to include. See self.CHECKERS.keys() for options.
None –> use all vars in self.CHECKERS.
str –> use this var.
list –> use these vars.
mode: UNSET, bool, ‘warn’, or ‘crash’
whether to check values for “reasonable-ness”, and how to behave if a check fails.
UNSET –> use self.checks_mode.
False –> don’t check.
True –> equivalent to ‘warn’
‘warn’ –> print warning message for any failed checks.
‘crash’ –> raise AssertionError for any failed checks.
additional kwargs are passed to every used checker.
returns dict {v: result from check_v} for each v in var.
check_dt()
checks that input_deck dt is smaller than or equal to the value from self.get_dt().
returns self.get_dt(units=’raw’), since it tells the suggested and old values for dt.
check_dx()
checks that input_deck dx is smaller than or equal to the value from self.get_dx().
returns self.get_dx(units=’raw’), since it tells the suggested and old values for dx.
check_rosenberg_qn(*, rosenberg_safety=UNSET)
check the rosenberg criterion for quasineutrality, for each fluid: (nusn / wplasma)^2 << 1.
rosenberg_safety: UNSET or number
the check passes iff (nusn / wplasma)^2 <= rosenberg_safety.
UNSET –> use DEFAULTS.EPPIC.ROSENBERG_SAFETY (default: 0.5)
return xarray of (mean(nusn / wplasma))^2 for each fluid
failed_check(msg)
what to do when a check fails. depends on self.checks_mode.
‘warn’ –> print warning message.
‘crash’ –> raise AssertionError.
True –> equivalent to ‘warn’
False –> do nothing.
property get
alias to __call__
get_dt(precision=1, *, dt_safety=UNSET, units='raw', **kw)
return dict of {‘dt’: EppicParam(value to use for dt, old=dt from input deck)}.
precision is for converting to str in exponential form.
dt_safety: UNSET or number
dt = dt_safety * minimum timescale.
UNSET –> use DEFAULTS.EPPIC.DT_SAFETY (default: 0.9)
units, kw:
passed to self.ec.using(…) while using this method.
get_dx(precision=1, *, ldebye_safety=UNSET, units='raw', **kw)
return dict of values to use for dx, dy, dz.
keys are dx, dy, dz. values are EppicParam objects, with old=dx, dy, dz from input deck.
precision is for converting to str in exponential form.
ldebye_safety: UNSET or number
dx, dy, dz = ldebye_safety * debye length of electrons.
UNSET –> use DEFAULTS.EPPIC.DSPACE_SAFETY (default: 1.1)
units, kw:
passed to self.ec.using(…) while using this method.
get_n(precision=3, *, units='raw', **kw)
return dict of values to use for n0d for all fluids in self.ec.fluid.
keys are n0d0, n0d1, etc. values are EppicParam objects, with old=n0d from input deck.
precision is for converting to str in exponential form.
units, kw:
passed to self.ec.using(…) while using this method.
get_v0(precision=3, *, units='raw', **kw)
return dict of values to use for vx0d, vy0d, vz0d for all fluids in self.ec.fluid,
for component in ec.component (e.g. use ec.component=(‘x’, ‘y’) to ignore ‘z’)
keys are vx0d0, vx0d1, etc. values are EppicParam objects, with old=vx0d from input deck.
precision is for converting to str in exponential form.
units, kw:
passed to self.ec.using(…) while using this method.
get_vtherm(precision=3, *, units='raw', **kw)
return dict of values to use for vxthd, vythd, vzthd for all fluids in self.ec.fluid,
for component in ec.component (e.g. use ec.component=(‘x’, ‘y’) to ignore ‘z’)
keys are vxthd0, vxthd1, etc. values are EppicParam objects, with old=vxthd from input deck.
precision is for converting to str in exponential form.
units, kw:
passed to self.ec.using(…) while using this method.
get_vtherm_n(precision=3, *, units='raw', **kw)
return dict of {‘vth_neutral’: EppicParam(value to use for vth_neutral, old=value from input deck)}.
units, kw:
passed to self.ec.using(…) while using this method.
setdefault(values={}, **values_as_kw)
setdefault for self.values. returns self.
Like self.update, but doesn’t overwrite existing values.
str_from(src='eppic.i', missing_values_ok=True, comment='previously={old}', **kw)
return str to use for the entire contents of the new, updated eppic.i file.
src: str
path to source file to use as template.
missing_values_ok: bool
whether it is okay for some of the varnames in values to not exist in eppic.i
comment: None or str
if not None, append comment as a comment to all updated lines.
Also, this comment will be hit by .format(old=old value)
additional kw passed to get_updated_eppic_i_str
timescales(*, units='raw', **kw_init)
returns an EppicTimescales object, to help with understanding the relevant timescales.
kwargs are pased to EppicTimescales(…)
update(values={}, **values_as_kw)
update self.values with values. returns self
static values_flat(values={}, **values_as_kw)
return these values as a ‘flat’ dict, suitable for using to update eppic.i file.
This is a dict of {key: value} pairs, appending dist number to key name where appropriate.
write(src='eppic.i', dst='eppic_updated.i', *, exists_ok=False, missing_values_ok=True, comment='previously={old}', **kw)
write updated eppic.i file to dst.
src: str
path to source file to use as template.
dst: str
path to destination file to write.
exists_ok: bool, default False
whether it is okay for dst to already exist.
missing_values_ok: bool
whether it is okay for some of the varnames in values to not exist in eppic.i
comment: None or str
if not None, append comment as a comment to all updated lines.
Also, this comment will be hit by .format(old=old value)
additional kw passed to update_eppic_i_file.
return abspath to dst.