idstools.compute.equilibrium

This module provides compute functions and classes for equilibrium ids data

refer data dictionary.

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.

Type:

object

Initialization EquilibriumCompute object.

Parameters:
ids: object

equilibrium ids 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_2d to 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_2d of the specified grid type

Parameters:
time_slice: int

time slice index

grid_type: int = 1

grid type. Defaults to 1.

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:

list

Raises:

AttributeError – The Raises section 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) section

See 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:
time_slice: int

time_slice is an integer parameter representing the index of the time slice for which the magnetic field is being calculated from profiles 2D.

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_2d has information about following fields b_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_constraints_info(label, constraints, constraintsE, time, time_index1, timeE)[source]
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’

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.

Parameters:
time_slice: int

The time slice parameter represents the time step at which the flux surfaces are to be calculated.

Returns:

a dictionary containing information about flux surfaces at a specific time slice. The dictionary includes a 2D Cartesian grid, a 2D profile index, and a 2D array of rho values. If no profiles are found, the function returns None.

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

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

Time slice is a parameter

attributes=None

The attributes parameter in the get_profiles_1d_quantities function is a list

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_2d to 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:
time_slice: int

time_slice is an index of time_slice. If not specified, it defaults to 0. Defaults to 0

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.

Parameters:
r

The r parameter in the getgm3 function represents the radial coordinate at which you want to calculate the value of gm3. This function interpolates the value of gm3 at the specified radial coordinate r based on the provided data.

time_slice: int

The time_slice parameter

Returns:

The function getgm3 returns the value of gm3, which is calculated based on the input parameters r and time_slice. The calculation involves interpolation of time_slice[time_slice].profiles_1d.gm3 based on r and normalization by rho_tor_sep squared.

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.

Parameters:
r

The r parameter in the getgm7 method is used as the input radial coordinate for which you want to calculate the value of gm7.

time_slice: int

The time_slice parameter

Returns:

The function getgm7 returns the value of gm7, which is calculated based on the input parameters r and time_slice.

getmrho(time_slice: int)[source]

This function calculates the number of elements in a list that are less than zero.

Parameters:
time_slice: int

The time_slice parameter

Returns:

The function getmrho is returning the number of elements in the rho_tor_norm list that are less than 0.

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