mhd
Input containing MHD eigenmodes.
This input is used in simulations studying particle response to MHD.
Using this data in a simulation requires that boozer data, containing mapping between real-space and Boozer coordinates, is present.
This module reads and writes both MHD_STAT and MHD_NONSTAT data. The only difference between these two is the time-dependency of the eigenfunctions, that is, does the mode amplitude (alpha or Phi) depend only on psi or psi and time. MHD_STAT assumes only psi dependency, making the interpolation much faster. So don’t use MHD_NONSTAT unless you really have to.
Stationary MHD eigenfunctions. |
|
Time-dependent MHD eigenfunctions. |
- class a5py.ascot5io.mhd.MHD_STAT(root, path, **kwargs)
Bases:
DataGroupStationary MHD eigenfunctions.
- static create_dummy()
Create dummy data that has correct format and is valid, but can be non-sensical.
This method is intended for testing purposes or to provide data whose presence is needed but which is not actually used in simulation.
This method creates two modes with constant eigenfunctions.
- Returns:
- data
dict Input data that can be passed to
write_hdf5method of a corresponding type.
- data
- plot_amplitude(amplitude='alpha', mode=None, ax=None)
Plot radial profile of all (or given mode) amplitudes.
For NONSTAT the profiles are shown at earliest time in dataset. TODO: Animate the NONSTAT to show profiles as a function of time.
- Args:
- amplitudestr <br>
Which amplitude is plotted: “alpha” (magnetic) or “phi” (electric)
- modetuple(int,int) <br>
Mode (n,m) to be plotted or None to plot all modes.
- axaxes <br>
Axes where plotting is done or None to create and show new fig.
- read()
Read data from HDF5 file.
- Returns:
- data
dict Data read from HDF5 stored in the same format as is passed to
write_hdf5().
- data
- static write_hdf5(fn, nmode, nmodes, mmodes, amplitude, omega, phase, alpha, phi, nrho, rhomin, rhomax, desc=None)
Write input data to the HDF5 file.
- Parameters:
- fn
str Full path to the HDF5 file.
- nmode
int Number of modes.
- nmodesarray_like (nmode,)
Mode n (toroidal) numbers.
- mmodesarray_like (nmode,)
Mode m (poloidal) numbers.
- amplitudearray_like (nmode,)
Mode amplitudies.
- omegaarray_like (nmode,)
Mode frequencies [rad/s].
- omegaarray_like (nmode,)
Mode phases [rad].
- alphaarray_like (
nrho,nmode) Magnetic perturbation eigenfunctions.
- phiarray_like (
nrho,nmode) Electric perturbation eigenfunctions.
- nrho
int Number of rho grid points.
- rhomin
float Minimum value in rho grid.
- rhomax
float Maximum value in rho grid.
- desc
str,optional Input’s description.
- fn
- Returns:
- name
str Name, i.e. “<type>_<qid>”, of the new input that was written.
- name
- Raises:
ValueErrorIf inputs were not consistent.
- class a5py.ascot5io.mhd.MHD_NONSTAT(root, path, **kwargs)
Bases:
DataGroupTime-dependent MHD eigenfunctions.
- static create_dummy()
Create dummy data that has correct format and is valid, but can be non-sensical.
This method is intended for testing purposes or to provide data whose presence is needed but which is not actually used in simulation.
This method creates two modes with constant eigenfunctions.
- Returns:
- data
dict Input data that can be passed to
write_hdf5method of a corresponding type.
- data
- plot_amplitude(amplitude='alpha', mode=None, ax=None)
Plot radial profile of all (or given mode) amplitudes.
For NONSTAT the profiles are shown at earliest time in dataset. TODO: Animate the NONSTAT to show profiles as a function of time.
- Args:
- amplitudestr <br>
Which amplitude is plotted: “alpha” (magnetic) or “phi” (electric)
- modetuple(int,int) <br>
Mode (n,m) to be plotted or None to plot all modes.
- axaxes <br>
Axes where plotting is done or None to create and show new fig.
- read()
Read data from HDF5 file.
- Returns:
- data
dict Data read from HDF5 stored in the same format as is passed to
write_hdf5().
- data
- static write_hdf5(fn, nmode, nmodes, mmodes, amplitude, omega, phase, alpha, phi, nrho, rhomin, rhomax, ntime, tmin, tmax, desc=None)
Write input data to the HDF5 file.
- Parameters:
- fn
str Full path to the HDF5 file.
- nmode
int Number of modes.
- nmodesarray_like (nmode,)
Mode n (toroidal) numbers.
- mmodesarray_like (nmode,)
Mode m (poloidal) numbers.
- amplitudearray_like (nmode,)
Mode amplitudies.
- omegaarray_like (nmode,)
Mode frequencies [rad/s].
- omegaarray_like (nmode,)
Mode phases [rad].
- alphaarray_like (
nrho,ntime,nmode) Magnetic perturbation eigenfunctions.
- phiarray_like (
nrho,ntime,nmode) Electric perturbation eigenfunctions.
- nrho
int Number of rho grid points.
- rhomin
float Minimum value in rho grid.
- rhomax
float Maximum value in rho grid.
- ntime
int,optional Number of time grid points.
- tmin
float Minimum value in time grid.
- tmax
float,optional Maximum value in time grid.
- desc
str,optional Input’s description.
- fn
- Returns:
- name
str Name, i.e. “<type>_<qid>”, of the new input that was written.
- name
- Raises:
ValueErrorIf inputs were not consistent.