PlasmaCalcs.addons.tfbi.tfbi_solver.TfbiSolver
- class PlasmaCalcs.addons.tfbi.tfbi_solver.TfbiSolver(cc, ions=None, *, kres='low', mod=UNSET, lmod=UNSET, ang=UNSET, tfbi_all=True, drel_cls=None)
Bases:
objecthigh-level interface for solving TFBI theory across many physical parameters.Call TfbiSolver to solve TFBI.Example:import PlasmaCalcs as pccc = pc.PlasmaCalculator(…) # <– your PlasmaCalculator of choicesolver = pc.TfbiSolver(cc)solution = solver() # alias: solver.solve()solution is an xarray.Dataset with all relevant quantities (see TfbiLoader.get_tfbi_all),and ‘omega’ telling roots with largest imaginary part.If you need more precise control over the solving process, use the pattern:import tfbi_theory as ttimport PlasmaCalcs as pccc = … # any PlasmaCalculator object from PlasmaCalcs.ds0 = cc.tfbi_ds()kp = tt.kPickerLowres(ds0)dsk = kp.get_ds() # copy of ds0, but with ds[‘k’] = k from kPicker.drel = tt.TfbiDisprelC.from_ds(dsk)dsR = drel.solve() # copy of dsk, but with ds[‘omega’] = solution to TFBI theory!TfbiSolver internally stores self.cc, ds0, kp, dsk, drel, and dsR,as defined by the pattern above.- cc: PlasmaCalculator
- PlasmaCalculator object used to load the data.Should be a TfbiLoader subclass. (PlasmaCalculator satisfies this by default,assuming successful import SymSolver and import tfbi_theory.)
- ions: None or specifier of multiple fluids (e.g. slice, or list of strs)
- None –> use cc.fluids.ions()print warning if this specifies more than DEFAULTS.ADDONS.TFBI_MAX_NUM_IONS ions(default: 5), because then solving will be slow and may be inaccurate.ions are determined when called, not during __init__.
- kres: ‘low’, ‘mid’, or ‘high’
- resolution in k-space. Tells which self.kPicker_cls to use.‘low’ –> tfbi_theory.kPickerLowres. Recommended if solving across many points.‘mid’ –> tfbi_theory.kPickerMidres. Recommended if solving across a few points.‘high’ –> tfbi_theory.kPickerHighres. Recommended if solving at only 1 point.
- mod, lmod, ang: UNSET or dict
- passed directly to kPicker if provided. Can specify k values other than the defaults.see help(self.kPicker_cls) for more details.
- tfbi_all: bool
- whether to compute all relevant tfbi vars, ds0 = cc(‘tfbi_all’).False –> compute only the necessary vars, ds0 = cc(‘tfbi_inputs’).
- drel_cls: None, str, or class
- tfbi_theory class to use for solving TFBI theory.None –> use self.drel_cls default: tt.TfbiDisprelCstr –> use getattr(tt, drel_cls) to get the class.
- __init__(cc, ions=None, *, kres='low', mod=UNSET, lmod=UNSET, ang=UNSET, tfbi_all=True, drel_cls=None)
Methods
__init__(cc[, ions, kres, mod, lmod, ang, ...])solve(*[, verbose])Attributes
drel_cls_namekPickerHighres_cls_namekPickerLowres_cls_namekPickerMidres_cls_name- property drel_cls
- class to use for solving TFBI theory. Default: tt.TfbiDisprelC.
- property ions_explicit
- list of ions from self.cc which would be used during self.cc.tfbi_ds()
- property kPicker_cls
- kPicker class to use for choosing wavevectors to consider. Depends on self.kres:‘low’ –> tfbi_theory.kPickerLowres‘mid’ –> tfbi_theory.kPickerMidres‘high’ –> tfbi_theory.kPickerHighres
- property solution
- result of self.solve(); alias to self.dsR.
- solve(*, verbose=True, **kw_growth_root)
- solve TFBI theory. Assigns self.ds0, kp, dsk, drel, and dsR.Does not do any caching at this level; if the code crashes you will need to restart it completely.For more precise control including possibility for caching, use the pattern directly:import tfbi_theory as ttimport PlasmaCalcs as pccc = … # any PlasmaCalculator object from PlasmaCalcs.ds0 = cc.tfbi_ds()kp = tt.kPickerLowres(ds0)dsk = kp.get_ds() # copy of ds0, but with ds[‘k’] = k from kPicker.drel = tt.TfbiDisprelC.from_ds(dsk)dsR = drel.solve() # copy of dsk, but with ds[‘omega’] = solution to TFBI theory!
- verbose: bool
- whether to print progress updates (highly recommended).
additional kwargs get passed directly to drel.solve().(options include: ncpu, ncoarse, careful)
- property solved
- tells whether self.solution exists