idstools.compute.equilibrium¶
This module provides compute functions and classes for equilibrium ids data
Module Contents¶
- class idstools.compute.equilibrium.EquilibriumCompute(ids: object)[source]¶
This class provides compute functions for equilibrium ids.
- ids¶
The equilibrium IDS (Integrated Data Structure) object containing time-resolved equilibrium data including profiles, magnetic field information, constraints, and boundary information.
Initialization EquilibriumCompute object.
- ids¶
-
get2d_cartesian_grid(time_slice: int, profiles2d_index: int =
0) dict | None[source]¶ This function returns a dictionary containing 2D Cartesian grid coordinates and psi values from an equilibrium IDS object.
- Parameters:¶
- time_slice: int¶
The time slice index of the equilibrium data to be used for generating the 2D Cartesian grid. Defaults to 0
- profiles2d_index: int =
0¶ profiles2d_index is an integer parameter that represents the index of the
profile_2dto be used in the calculation. It is used to access the specific 2D profile from the list of profiles in the time_slice object. Defaults to 0
- Returns:¶
A dictionary containing the 2D Cartesian grid coordinates (r2d and z2d) and the corresponding psi values (psi2d).
Example
import imas connection = imas.DBEntry("imas:mdsplus?user=public;pulse=134173;run=106;database=ITER;version=3","r") idsObj = connection.get('equilibrium') computeObj = EquilibriumCompute(idsObj) result = computeObj.get2d_cartesian_grid(time_slice=0) {'psi2d': array([[]]), 'r2d': array([[]]), 'z2d': array([[]])}
-
get2d_profiles_indices(time_slice: int, grid_type: int =
1) list[source]¶ Return the indices of
profiles_2dof the specified grid type- Parameters:¶
- Returns:¶
list of indices of the 2D profiles at a given time slice. If no such 2D profiles are found, it returns None
- Return type:¶
- Raises:¶
AttributeError – The
Raisessection is a list of all exceptions that are relevant to the interface.
Notes
Multiple 2D representations of the equilibrium are stored in
profiles_2d. Various grid types are available like rectangular, inverse etc. read more on profiles_2d(i1) sectionSee also
getFluxSurfaces()getBTotal()Examples
import imas connection = imas.DBEntry("imas:mdsplus?user=public;pulse=134173;run=106;database=ITER;version=3","r") idsObj = connection.get('equilibrium') computeObj = EquilibriumCompute(idsObj) indices = idsobj.get2d_profiles_indices(time_slice=0, gridType=1) [0]
- get_b_total(time_slice: int) tuple[source]¶
This function calculates the total magnetic field strength at a given time slice based on the radial, vertical, and toroidal components of the magnetic field.
- Parameters:¶
- Returns:¶
Index in profiles_2d Array of total magnetic field strength (bTotal) at a given time slice, calculated using the square root of the sum of the squares of the radial, vertical, and toroidal components of the magnetic field. If there are no profiles available for the given time slice, the function returns None.
Examples
import imas connection = imas.DBEntry(“imas:mdsplus?user=public;pulse=134173;run=106;database=ITER;version=3”, “r”) idsObj = connection.get(‘equilibrium’) computeObj = EquilibriumCompute(idsObj) indices = idsobj.get_b_total(time_slice=0) (0, array([[10.99503929
Notes
\[bTotal = \sqrt{b\_field\_r^2 + b\_field\_z^2 + b\_field\_tor^2}\]profiles_2dhas information about following fieldsb_field_r(R component of the poloidal magnetic field)b_field_z(Z component of the poloidal magnetic field)b_field_tor(Toroidal component of the magnetic field)
-
get_contour(psi_axis, psi_boundary, time, time_index1, psi_axis2=
None, psi_boundary2=None, time2=None, psi2D1=None, psi2D2=None)[source]¶
-
get_equilibria(selection=
None)[source]¶ The function get_equilibria retrieves equilibrium data from a given object and organizes it into a dictionary for further analysis.
- Parameters:¶
- selection=
None¶ List of data types to calculate and return. If None, returns all data. Possible values include: ‘time’, ‘nt’, ‘ip’, ‘q0’, ‘beta’, ‘rmag’, ‘zmag’, ‘psi_axis’, ‘psi_boundary’, ‘psi1D’, ‘qpsi1D’, ‘press1D’, ‘psi2D’, ‘jtor2D’, ‘r2D’, ‘z2D’, ‘rb’, ‘zb’, ‘r’, ‘z’, ‘j_tor1D’, ‘rin1D’, ‘rout1D’, ‘output_flag’, ‘name’, ‘num_iterations’, ‘iteration_error’, ‘constraints’, ‘ip_constraints’, ‘pf_constraints’, ‘passive_constraints’, ‘bpol_constraints’, ‘fluxloop_constraints’, ‘profiles_1d’, ‘profiles_2d’, ‘boundaries’, ‘global_quantities’, ‘all_constraints’
- selection=
- Returns:¶
The get_equilibria method returns a dictionary named data containing the requested equilibrium data such as time, magnetic field parameters, profiles in 1D and 2D, boundary information, constraints information, and other relevant details.
- get_flux_surfaces(time_slice: int) dict[source]¶
This function returns a dictionary containing 2D profiles and rho values for a given time slice.
-
get_global_quantities(time_slice=
None, attributes=None)[source]¶ This Python function retrieves global quantities from a time slice object based on specified attributes.
- Parameters:¶
- time_slice=
None¶ The time_slice parameter in the get_global_quantities function is used to specify a particular time slice for which you want to retrieve global quantities. If time_slice is not provided (i.e., it is None), the function will retrieve global quantities for all time slices
- attributes=
None¶ The attributes parameter in the get_global_quantities function is used to specify a list of quantities that you want to retrieve from the global quantities of a time slice. The default list of attributes includes “q_min”, “q_95”, “li_3”, “beta_tor
- time_slice=
- Returns:¶
The get_global_quantities function returns a dictionary quantities containing global
quantities based on the provided time_slice and attributes. If time_slice is not specified, it calculates the global quantities for all time slices and stores them in arrays within the dictionary. If time_slice is specified, it retrieves the global quantities for that specific time slice and returns them in the dictionary format
- get_ip() list[source]¶
This function returns a list of Plasma current (toroidal component) values for each time slice.
- Returns:¶
a list of plasma currents for each time slice in self.ids.time_slice. The plasma current is calculated by multiplying the global quantity ip by -1.0e-6.
Examples
import imas connection = imas.DBEntry("imas:mdsplus?user=public;pulse=134173;run=106;database=ITER;version=3","r") idsObj = connection.get('equilibrium') computeObj = EquilibriumCompute(idsObj) result = computeObj.getIP() array([[]])
-
get_profiles_1d_quantities(time_slice, attributes=
None)[source]¶ The function get_profiles_1d_quantities retrieves specified attributes from a 1D profile at a given time slice.
- Parameters:¶
of strings that represent the quantities or attributes you want to retrieve from the profiles_1d object for a specific time slice. defaults it retrives pressure, q, beta_pol
- Returns:¶
A dictionary containing the values of the specified attributes (“pressure”, “q”, “beta_pol”)
for the given time slice from the profiles_1d data.
-
get_rho2d(time_slice: int, profiles2d_index: int =
0) numpy.ndarray | None[source]¶ This function calculates rho(R,Z) using toroidal flux and returns a dictionary containing the result.
- Parameters:¶
- time_slice: int¶
The time slice is an integer value that represents the index of the time slice in the equilibrium ids. It is used to select a specific time slice for the calculation of rho(R,Z). Defaults to 0
- profiles2d_index: int =
0¶ profiles2d_index is an integer parameter that represents the index of the
profiles_2dto be used for the calculation of rho(R,Z). It is used to access the profiles_2d list in the time_slice object. Defaults to 0
- Returns:¶
a value containing the square root of the toroidal flux values divided by the maximum toroidal flux value, if the length of toroidal flux is greater than 0. If the length of toroidal flux is less than 1, it returns None.
Examples
import imas connection = imas.DBEntry("imas:mdsplus?user=public;pulse=134173;run=106;database=ITER;version=3", "r") idsObj = connection.get('equilibrium') computeObj = EquilibriumCompute(idsObj) result = computeObj.get_rho2d(time_slice=0)
- get_top_view(time_slice: int) dict[source]¶
The function returns data for plotting the top view of a 2D shape.
- Parameters:¶
- Returns:¶
The function get_top_view returns a dictionary topViewDict containing the following keys
”r0”: the geometric axis r of the boundary at the given time_slice
”amin”: the minor radius of the boundary at the given time_slice
”phit”: an array of 100 evenly spaced values between 0 and 2 * pi
”xpla”: left x-coordinate of a point in polar coordinates
”ypla”: left y-coordinate of a point in polar coordinates
”xplap”: right x-coordinate of a point in polar coordinates
”yplap”: right y-coordinate of a point in polar coordinates
- getgm3(r, time_slice: int)[source]¶
The function getgm3 calculates and returns a value based on interpolation and division operations.
- getgm7(r, time_slice: int)[source]¶
The function getgm7 calculates and returns the normalized value of gm7 at a given radial position r for a specific time slice.
- getmrho(time_slice: int)[source]¶
This function calculates the number of elements in a list that are less than zero.
-
rescale(rescale_factor, dd_update=
False)[source]¶ The function rescales various magnetic field properties in an equilibrium by a specified factor.
- Parameters:¶
- rescale_factor¶
The rescale method you provided rescales various magnetic field components in an equilibrium object by a specified rescale factor. The rescale factor is a float value that you pass to the method to determine the extent of rescaling for the magnetic field components.
- Returns:¶
The rescale method returns the rescaled equilibrium equout after applying the rescaling factor to various magnetic field components and properties within the equilibrium data structure. The method also updates the comment in the ids_properties of the equilibrium to indicate that the magnetic field has been rescaled by a certain factor.
-
z_shift(shift, dd_update=
False)[source]¶ The function z_shift rigidly shifts the vertical position of various components within an equilibrium by a specified amount.
- Parameters:¶
- shift¶
The shift parameter in the z_shift method represents the vertical shift in meters that will be applied to the equilibrium data. This shift will be added to the z-coordinates of various points and boundaries within the equilibrium data structure.
- Returns:¶
The z_shift method returns a vertically shifted equilibrium object (equilibrium IDS) after applying the specified vertical shift in meters to various components of the equilibrium data structure. The method modifies the z-coordinates of different components within the equilibrium object based on the provided shift value. Additionally, it updates the comment of the equilibrium object to indicate that it has been shifted vertically by a certain amount.
- idstools.compute.equilibrium.logger¶