![]() |
The Open FUSION Toolkit 1.0.0-6f445ef
An open-source framework for fusion and plasma science and engineering
|
Interface that sets up normal magnetic field probes at a desired surface, Fourier analyze the signals, and output them for GPEC.
Public Member Functions | |
| __init__ (self, radial_positions, axial_positions, major_radius, helicity) | |
| Initialize the interface with surface. | |
| convert_to_polar (self) | |
| Converts (R,Z) to (theta,r) with respect to a major radius. | |
| fft2 (self, B, hamada_dphi=None) | |
| Performs a 2D Fast Fourier Transform in PEST/Hamada coordinates on the magnetic field matrix probed by sensors with proper Nyquist handling. | |
| field_fourier_amplitude_contour (self, t, m_min, m_max, n_min, n_max, fig, ax, hamada_dphi=None, part='r') | |
| Plot the real fourier amplitude of the magnetic field in the fourier space. | |
| get_B_mesh (self, t) | |
| Extract the mesh of magnetic sensor values at a t time step. | |
| ifft2 (self, B_n, hamada_dphi=None) | |
| Performs an inverse 2D Fast Fourier Transform in PEST/Hamada coordinates on the transformed magnetic field matrix with proper Nyquist handling. | |
| load_histfile (self, hist_file_path='floops.hist', norm=None) | |
| Loading histfile containing magnetic values at the surface collected by sensors. | |
| place_normal_sensors (self, nphi=15, filename='floops.loc', ax=None) | |
| Place normal sensors on the ThinCurr object. | |
| plot_1D_fourier_amplitude (self, t, harmonics, ax, toroidal_harmonics=True, hamada_dphi=None, part='r') | |
Plot real fourier amplitude of 1D Fast Fourier Transform of the magnetic mesh in axis at time step t | |
| plot_2D_fourier_amplitude (self, t, harmonics, ax, toroidal_harmonics=True, hamada_dphi=None, x_type='modes', x_mode_min=None, x_mode_max=None) | |
| Plot the 2D Fast Fourier Transformed amplitude of the mesh of magnetic values against poloidal/toroidal harmonics/angles. | |
| plot_inverse_2D_fourier_transform (self, t, fig, ax) | |
Use ifft2 to reconstruct the sensor signal at time step t | |
| plot_m_over_n_amplitude (self, m_list, n_list, t_max, dt, ax, t_min=0, hamada_dphi=None) | |
Plot the 2D Fast Fourier Transformed amplitude of the magnetic field for m/n (poloidal harmonic / toroidal harmonic) mode with respect to time. | |
| plot_sensor_output (self, t, fig, ax) | |
Plot the magnetic field contour of the sensors on the surface at time step t | |
| plot_sensor_output_on_surface (self, t, figs, axes) | |
Plot the normal magnetic field on the surface at time step t | |
| plot_sensor_signal_against_angle (self, t, ax, theta=True) | |
| Plot the value of normal magnetic fields over theta/phi at at phi/theta = 0. | |
| save_surfmn (self, t, filename, eliminate_negative_n=True, scale=1e-4, hamada_dphi=None) | |
Sort the Fast Fourier Transformed B mesh in PEST or Hamada coordinate at time step t and write it to a SURFMN-formatted file. | |
| sort_fft_indices_and_mesh (self, B_n_fft, n_modes, m_modes) | |
| Sort the Fourier Transformed B mesh and the poloidal and toroidal mode numbers generated by the FFT functions in this class while considering helicity. | |
Public Attributes | |
| axial_positions | |
| helicity | |
| hist_file | |
| major_radius | |
| nphi | |
| ntheta | |
| radial_positions | |
| theta_list | |
| __init__ | ( | self, | |
| radial_positions, | |||
| axial_positions, | |||
| major_radius, | |||
| helicity | |||
| ) |
Initialize the interface with surface.
| radial_positions | The R coordinates that defines the surface [ntheta] |
| axial_positions | The Z coordinates that defines the surface [ntheta] |
| major_radius | The major radius of the device |
| helicity | Sign of the plasma helicity |
| convert_to_polar | ( | self | ) |
Converts (R,Z) to (theta,r) with respect to a major radius.
| fft2 | ( | self, | |
| B, | |||
hamada_dphi = None |
|||
| ) |
Performs a 2D Fast Fourier Transform in PEST/Hamada coordinates on the magnetic field matrix probed by sensors with proper Nyquist handling.
| B | Input matrix of shape [ntheta,nphi] |
| hamada_dphi | Hamada phase shifts [ntheta] |
B_n The Fast Fourier Transformed matrix [ntheta,nphi], n_modes The toroidal mode numbers [nphi], m_modes The poloidal mode numbers [ntheta] | field_fourier_amplitude_contour | ( | self, | |
| t, | |||
| m_min, | |||
| m_max, | |||
| n_min, | |||
| n_max, | |||
| fig, | |||
| ax, | |||
hamada_dphi = None, |
|||
part = 'r' |
|||
| ) |
Plot the real fourier amplitude of the magnetic field in the fourier space.
| t | The time step during the time evolution |
| m_min | The lower limit of the poloidal harmonics to be included in the contour |
| m_max | The upper limit of the poloidal harmonics to be included in the contour |
| n_min | The lower limit of the toroidal harmonics to be included in the contour |
| n_max | The upper limit of the toroidal harmonics to be included in the contour |
| fig | Matplotlib figure for plotting |
| ax | Matplotlib axis for plotting |
| hamada_dphi | Hamada phase shifts [ntheta] |
| part | The part of the fourier amplitude to be plotted ('r' for real, 'i' for imaginary, 'a' for absolute) |
| get_B_mesh | ( | self, | |
| t | |||
| ) |
Extract the mesh of magnetic sensor values at a t time step.
| t | The time step at which the sensor values are extracted from sensor_file |
sensor_mesh Sensor values on a (theta,phi) mesh [ntheta,nphi] | ifft2 | ( | self, | |
| B_n, | |||
hamada_dphi = None |
|||
| ) |
Performs an inverse 2D Fast Fourier Transform in PEST/Hamada coordinates on the transformed magnetic field matrix with proper Nyquist handling.
| B_n | Input FFT'ed matrix of shape [ntheta,nphi] |
| hamada_dphi | Hamada phase shifts [ntheta] |
B_ifft The reconstructed matrix [ntheta,nphi] | load_histfile | ( | self, | |
hist_file_path = 'floops.hist', |
|||
norm = None |
|||
| ) |
Loading histfile containing magnetic values at the surface collected by sensors.
| hist_file_path | Path to the histfile containing sensor values |
| norm | Normalization factor to be applied to the sensor values |
| place_normal_sensors | ( | self, | |
nphi = 15, |
|||
filename = 'floops.loc', |
|||
ax = None |
|||
| ) |
Place normal sensors on the ThinCurr object.
| nphi | The number of poloidal planes to be probed by sensors in the toroidal direction |
| filename | The name of the file storing ThinCurr sensors |
| ax | Matplotlib axis for plotting |
ax if it is provided | plot_1D_fourier_amplitude | ( | self, | |
| t, | |||
| harmonics, | |||
| ax, | |||
toroidal_harmonics = True, |
|||
hamada_dphi = None, |
|||
part = 'r' |
|||
| ) |
Plot real fourier amplitude of 1D Fast Fourier Transform of the magnetic mesh in axis at time step t
| t | The time step during the time evolution |
| harmonics | Array of mode number in the axis dimension, whose real amplitudes are to be plotted against the other dimension [:] |
| ax | Matplotlib axis for plotting |
| toroidal_harmonics | Whether the input harmonics is toroidal or poloidal harmonics |
| hamada_dphi | Hamada phase shifts [ntheta] |
| part | The part of the fourier amplitude to be plotted ('r' for real, 'i' for imaginary, 'a' for absolute) |
harmonics | plot_2D_fourier_amplitude | ( | self, | |
| t, | |||
| harmonics, | |||
| ax, | |||
toroidal_harmonics = True, |
|||
hamada_dphi = None, |
|||
x_type = 'modes', |
|||
x_mode_min = None, |
|||
x_mode_max = None |
|||
| ) |
Plot the 2D Fast Fourier Transformed amplitude of the mesh of magnetic values against poloidal/toroidal harmonics/angles.
| t | The time step during the time evolution |
| harmonics | List of (poloidal/toroidal) modes whose amplitudes are to be visualized in y axis [:] |
| ax | Matplotlib axis for plotting |
| toroidal_harmonics | Whether the input harmonics is toroidal or poloidal harmonics |
| hamada_dphi | Hamada phase shifts [ntheta] |
| x_type | The variable on x axis ('modes' or 'angles') |
| x_mode_min | The min of the (toroidal/poloidal) mode number to be visualized on x axis |
| x_mode_max | The max of the (toroidal/poloidal) mode number to be visualized on x axis |
harmonics harmonics | plot_inverse_2D_fourier_transform | ( | self, | |
| t, | |||
| fig, | |||
| ax | |||
| ) |
Use ifft2 to reconstruct the sensor signal at time step t
| t | The time step of the sensor signals at which fft and ifft is to be performed |
| fig | Matplotlib figure for plotting |
| ax | Matplotlib axis for plotting |
t | plot_m_over_n_amplitude | ( | self, | |
| m_list, | |||
| n_list, | |||
| t_max, | |||
| dt, | |||
| ax, | |||
t_min = 0, |
|||
hamada_dphi = None |
|||
| ) |
Plot the 2D Fast Fourier Transformed amplitude of the magnetic field for m/n (poloidal harmonic / toroidal harmonic) mode with respect to time.
| m_list | The list of m of the m/n modes to be visualized [:] |
| n_list | The (list of) n of the m/n modes to be visualized [:] |
| t_max | The ending time step of the plot |
| dt | The duration of each time step in unit of seconds |
| ax | Matplotlib axis for plotting |
| t_min | The starting time step of the plot |
| hamada_dphi | Hamada phase shifts [ntheta] |
m_list and n_list | plot_sensor_output | ( | self, | |
| t, | |||
| fig, | |||
| ax | |||
| ) |
Plot the magnetic field contour of the sensors on the surface at time step t
| t | The time step during the time evolution |
| fig | Matplotlib figure for plotting |
| ax | Matplotlib axis for plotting |
t | plot_sensor_output_on_surface | ( | self, | |
| t, | |||
| figs, | |||
| axes | |||
| ) |
Plot the normal magnetic field on the surface at time step t
| t | The time step during the time evolution |
| figa | Maximumly two Matplotlib figures for plotting |
| axes | Two Matplotlib axes for plotting |
| plot_sensor_signal_against_angle | ( | self, | |
| t, | |||
| ax, | |||
theta = True |
|||
| ) |
Plot the value of normal magnetic fields over theta/phi at at phi/theta = 0.
| t | The time step during the time evolution |
| ax | Matplotlib axis for plotting |
| theta | Plot against theta (True) or phi (False) |
| save_surfmn | ( | self, | |
| t, | |||
| filename, | |||
eliminate_negative_n = True, |
|||
scale = 1e-4, |
|||
hamada_dphi = None |
|||
| ) |
Sort the Fast Fourier Transformed B mesh in PEST or Hamada coordinate at time step t and write it to a SURFMN-formatted file.
| t | The time step at which the magnetic values are desired |
| filename | Filename of the file |
| eliminate_negative_n | Whether values of negative n modes should be written to the file |
| scale | The scaling of the values in the file |
| hamada_dphi | Hamada phase shifts [ntheta] |
| sort_fft_indices_and_mesh | ( | self, | |
| B_n_fft, | |||
| n_modes, | |||
| m_modes | |||
| ) |
Sort the Fourier Transformed B mesh and the poloidal and toroidal mode numbers generated by the FFT functions in this class while considering helicity.
| B_n_fft | The Fast Fourier Transformed B mesh, the first output of self.fft(B) [ntheta,nphi] |
| n_modes | The toroidal mode numbers, the second output of self.fft(B) [ntheta] |
| m_modes | The poloidal mode numbers, the third output of self.fft(B) [nphi] |
B_n_sorted The sorted FFT'ed B mesh [ntheta,nphi], n_modes_sorted The sorted toroidal mode numbers [ntheta], m_modes_sorted The sorted poloidal mode numbers [nphi] | axial_positions |
| helicity |
| hist_file |
| major_radius |
| nphi |
| ntheta |
| radial_positions |
| theta_list |