Moments of Maxwellians can be set from MHD equilibrium
Solves the following issue(s):
Closes #263 (closed)
Core changes:
- In the background parameters for Maxwellians, there is the new option
mhd
(instead of a constant value) for the moments:
maxw_params_mhd = {'n': 'mhd',
'u1': 'mhd',
'u2': 'mhd',
'u3': 'mhd',
'vth1': 'mhd',
'vth2': 'mhd',
'vth3': 'mhd'}
If mhd
is given, during the evaluation of the moments the mhd equilibrium is called and evaluated. Three evaluation methods are possible:
- flat (marker) evaluation
- phase space meshgrid
- real space meshgrid (3D)
The perturbation is added on top of the MHD equilibrium. The broadcasting has been taken care of in the Maxwellian base class. Unit test have been added for Maxwellian6D
and Maxwellian5D
.
- Particle classes are now instantiated as follows (in
StruphyModel._allocate_variables()
):
# background parameters
if 'background' in val['params']:
bckgr_params = val['params']['background']
else:
bckgr_params = None
# perturbation parameters
if 'perturbation' in val['params']:
pert_params = val['params']['perturbation']
else:
pert_params = None
kinetic_class = getattr(particles, val['space'])
val['obj'] = kinetic_class(
species,
**val['params']['markers'],
derham=self.derham,
domain=self.domain,
mhd_equil=self.mhd_equil,
bckgr_params=bckgr_params,
pert_params=pert_params
)
In particular, we pass mhd_equil
, bckgr_params
and pert_params
. In the Particles
base class, there is always a self.f_backgr
defined:
# set background function
bckgr_fun = bckgr_params['type']
if bckgr_fun in bckgr_params:
self._f_backgr = getattr(maxwellians, bckgr_fun)(
maxw_params=bckgr_params[bckgr_fun],
mhd_equil=mhd_equil
)
else:
self._f_backgr = getattr(maxwellians, bckgr_fun)()
print(f'\n{bckgr_fun} is not in bckgr_params; default background parameters are used.')
The signature of the Maxwellians has been changed a bit, in order to make it more clear:
def __init__(self, maxw_params=None, pert_params=None, mhd_equil=None)
- Other changes:
- Rename toy model
DriftKinetic
toGuidingCenter
- Check argument shape and ndim in call method of Maxwellian base class.
- Added
moment_factors
to Maxwellians - Add small offset to ScrewPinch equilibirum pressure to avoid zero values
Model-specific changes:
None
Documentation changes:
None