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.

a5py.ascot5io.mhd.MHD_STAT

Stationary MHD eigenfunctions.

a5py.ascot5io.mhd.MHD_NONSTAT

Time-dependent MHD eigenfunctions.

class a5py.ascot5io.mhd.MHD_STAT(root, path, **kwargs)

Bases: DataGroup

Stationary 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:
datadict

Input data that can be passed to write_hdf5 method of a corresponding type.

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:
datadict

Data read from HDF5 stored in the same format as is passed to write_hdf5().

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:
fnstr

Full path to the HDF5 file.

nmodeint

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.

nrhoint

Number of rho grid points.

rhominfloat

Minimum value in rho grid.

rhomaxfloat

Maximum value in rho grid.

descstr, optional

Input’s description.

Returns:
namestr

Name, i.e. “<type>_<qid>”, of the new input that was written.

Raises:
ValueError

If inputs were not consistent.

class a5py.ascot5io.mhd.MHD_NONSTAT(root, path, **kwargs)

Bases: DataGroup

Time-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:
datadict

Input data that can be passed to write_hdf5 method of a corresponding type.

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:
datadict

Data read from HDF5 stored in the same format as is passed to write_hdf5().

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:
fnstr

Full path to the HDF5 file.

nmodeint

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.

nrhoint

Number of rho grid points.

rhominfloat

Minimum value in rho grid.

rhomaxfloat

Maximum value in rho grid.

ntimeint, optional

Number of time grid points.

tminfloat

Minimum value in time grid.

tmaxfloat, optional

Maximum value in time grid.

descstr, optional

Input’s description.

Returns:
namestr

Name, i.e. “<type>_<qid>”, of the new input that was written.

Raises:
ValueError

If inputs were not consistent.