idstools.compute.core_profiles

This module provides compute functions and classes for core_profiles ids data

refer data dictionary.

Module Contents

class idstools.compute.core_profiles.CoreProfilesCompute(ids, volume=None)[source]

This class provides compute functions for core profiles ids.

ids

The core profiles IDS (Integrated Data Structure) object containing plasma profile data including temperature, density, pressure, and rotation profiles.

Type:

object

volume

Optional volume data object for spatial integration and analysis.

Type:

object, optional

ids
volume = 'None'
combine_species_when_appear_twice(species, nspec_over_ntot, nspec_over_ne, nspec_over_nmaj, time_slice)[source]

This is helper function which checks if there are duplicate entries of species and combine the species. This is in place change of arrays

Parameters:
species

result from get_species()

nspec_over_ntot

result from get_nspec_over_ntot()

nspec_over_ne

result from get_nspec_over_ne()

nspec_over_nmaj

result from get_nspec_over_nmaj()

time_slice

time_slice on which function should operate on. Defaults to 0.

get_a(time_slice, element_index=0) list[source]

This function returns a list of atomic masses for a given slice and element index.

Parameters:
time_slice

The index of the slice in the ggd list that contains the ion information.Defaults to 0

element_index=0

Element index, It is used to access the ‘a’ attribute of the element object. Defaults to 0

Returns:

a list of atomic masses for each species in the given slice index and element index.

Example

import imas
connection = imas.DBEntry("imas:mdsplus?user=public;pulse=105033;run=1;database=ITER;version=3", "r")

idsObj = connection.get('core_profiles')
connection.close()
computeObj = CoreProfilesCompute(idsObj)
result = computeObj.get_a(time_slice=0)

[2.0, 3.0, 4.0, 9.0, 183.84, 40.0, 20.0]
get_electron_density_ne0()[source]

This function get_electron_density_ne0 returns a list of electron densities at the first position for each time step in a given object.

Returns:

The function get_ne0 returns a list of electron densities at the first spatial point (index 0) for all time steps in the simulation. The electron density is in units of 1e-19 m^-3.

Example

import imas
connection = imas.DBEntry("imas:mdsplus?user=public;pulse=105033;run=1;database=ITER;version=3", "r")
idsObj = connection.get('core_profiles')
connection.close()
computeObj = CoreProfilesCompute(idsObj)
result = computeObj.get_electron_density_ne0(time_slice=0)

[5.106128949975287]
get_electrons_pressure_properties(time_slice)[source]

The function get_electrons_pressure_properties calculates and returns various pressure properties of electrons, including maximum pressure and individual pressure components.

Returns:

The get_electrons_pressure_properties function returns a dictionary with the following key-value pairs: “maxima_electrons”: Maximum pressure of electrons “pressure_electron_total”: Total pressure of electrons “pressure_electron_thermal”: Thermal pressure of electrons “pressure_electron_fast_parallel”: Pressure of fast parallel electrons “pressure_electron_fast_perpendicular

get_ion_pressure_properties(time_slice)[source]

The get_ion_pressure_properties function calculates and returns the total thermal pressure, fast parallel pressure, and fast perpendicular pressure of ions in a given set of profiles.

Returns:

The function get_ion_pressure_properties is returning a dictionary containing the following

keys and values: maxima_ion, pressure_ion_thermal, pressure_ion_fast_parallel, pressure_ion_fast_perpendicular

get_labels(time_slice: int) list[source]

This function get_labels returns a list of labels for all species in a given time slice.

Parameters:
time_slice: int

an optional integer parameter that specifies the time slice on which the function should operate. The default value is 0

Returns:

a list of labels for all species in a given time slice.

Example

import imas
connection = imas.DBEntry("imas:mdsplus?user=public;pulse=104010;run=2;database=ITER;version=3", "r")
idsObj = connection.get('core_profiles')
computeObj = CoreProfilesCompute(idsObj)
result = computeObj.get_labels(time_slice=0)

['H', 'He', 'Ne']
get_ne(time_slice: int) float[source]

This function get_ne calculates the total number of electrons (ne) based on the volume and electron density of a given slice.

Parameters:
time_slice: int

time slice on which function should operate on. Defaults to 0.

Returns:

the total number of electrons (ne) in the given slice of the object, calculated by multiplying the volume of the slice with its electron density and summing the results.

Example


import imas connection = imas.DBEntry(“imas:mdsplus?user=public;pulse=104010;run=2;database=ITER;version=3”, “r”) idsObj = connection.get(‘core_profiles’) connection.close() computeObj = CoreProfilesCompute(idsObj) result = computeObj.get_ne(time_slice=0)

8.778296205101714e+23

get_nspec_over_ne(time_slice: int)[source]

This function calculates the ratio of species density to electron density.

Parameters:
time_slice: int

time slice on which function should operate on. Defaults to 0.

Returns:

the ratio of the species density list to the electron density (ne).

Example

import imas
connection = imas.DBEntry("imas:mdsplus?user=public;pulse=104010;run=2;database=ITER;version=3", "r")
idsObj = connection.get('core_profiles')
computeObj = CoreProfilesCompute(idsObj)
result = computeObj.get_nspec_over_ne(time_slice=0)

array([0.74048128, 0.0944273 , 0.00706596])
get_nspec_over_nmaj(time_slice: int) list[source]

This function returns a list of the ratio of each species density to the maximum species density.

Parameters:
time_slice: int

time slice on which function should operate on. Defaults to 0.

Returns:

a list of values obtained by dividing each element of the list species_density_list by the maximum value in that list. This list represents the ratio of the density of each species to the density of the most abundant species.

Example

import imas
connection = imas.DBEntry("imas:mdsplus?user=public;pulse=104010;run=2;database=ITER;version=3", "r")
idsObj = connection.get('core_profiles')
computeObj = CoreProfilesCompute(idsObj)
result = computeObj.get_nspec_over_nmaj(time_slice=0)

array([1.        , 0.12752153, 0.00954239])
get_nspec_over_ntot(time_slice: int)[source]

This function calculates the ratio of the number of species to the total number of particles in a plasma.

Parameters:
time_slice: int

time slice on which function should operate on. Defaults to 0.

Returns:

The function get_nspec_over_ntot is returning the ratio of the list of species densities to the total density (ntot).

Example

import imas
connection = imas.DBEntry("imas:mdsplus?user=public;pulse=104010;run=2;database=ITER;version=3", "r")
idsObj = connection.get('core_profiles')
computeObj = CoreProfilesCompute(idsObj)
result = computeObj.get_nspec_over_ntot(time_slice=0)

array([0.87945803, 0.11214983, 0.00839213])
static get_plasma_composition_with_species_concentration(ids, time_slice, volume=None) dict | int[source]

Function retrives composition and species concentration in below format

get_pressure(time_slice)[source]

The function get_pressure returns a dictionary containing the thermal pressure, parallel pressure, and perpendicular pressure.

Returns:

“maxima_total”: maximum value calculated based on pressure values “pressure_total”: total pressure value calculated as the sum of electron pressure and ion pressure “pressure_thermal”: thermal pressure values “pressure_parallel”: parallel pressure values “pressure_perpendicular”: perpendicular pressure values

Return type:

The get_pressure function returns a dictionary with the following key-value pairs

get_pressure_ion_total(time_slice) float | None[source]

The function get_pressure_ion_total returns the total ion pressure from a given set of profiles or None if the pressure values cannot be read.

Returns:

The function get_pressure_ion_total returns the total ion pressure from a given set of

profiles, or None if the pressure values cannot be read.

get_profiles(time_slice)[source]

The function get_profiles retrieves and organizes various profiles from a data source for further analysis.

Parameters:
time_slice

The time_slice parameter in the get_profiles method is used to specify which slice of profiles to retrieve.

Returns:

A dictionary named profiles is being returned, which contains the following keys and corresponding values

get_psi(time_slice: int) list | None[source]

This function get_psi returns the poloidal magnetic flux (psi) at a given time slice.

Parameters:
time_slice: int

time index

Returns:

the poloidal magnetic flux (psi) as a list of floats for a given time slice. If the length of the poloidal magnetic flux is greater than 0, then the function returns the negative of the poloidal magnetic flux. If the length of the poloidal magnetic flux is 0, then the function returns None.

Example

import imas
connection = imas.DBEntry("imas:mdsplus?user=public;pulse=104010;run=2;database=ITER;version=3", "r")
idsObj = connection.get('core_profiles')
computeObj = CoreProfilesCompute(idsObj)
result = computeObj.get_psi(time_slice=0)

array([-4.95660880e+01, -4.95537345e+01, -4.95275298e+01, -4.94833135e+01,
-4.94209348e+01, -4.93461904e+01, -4.92595767e+01, -4.91573223e+01,
get_rho_tor_norm(time_slice: int) numpy.ndarray | None[source]

This function get_rho_tor_norm returns a list of normalized toroidal rho values from a given time slice of a profiles_1d object.

Parameters:
time_slice: int

time index. Defaults to 0

Returns:

a list of normalized toroidal flux coordinates (rho_tor_norm) for a given time slice of the IDS object. If rho_tor_norm is not available, it tries to return a list of toroidal flux coordinates (rho_tor) instead. If neither is available, it returns None.

Example

import imas
connection = imas.DBEntry("imas:mdsplus?user=public;pulse=104010;run=2;database=ITER;version=3", "r")
idsObj = connection.get('core_profiles')
computeObj = CoreProfilesCompute(idsObj)
result = computeObj.get_rho_tor_norm(time_slice=0)

[0.005025125628140704,
0.015075376884422112,
0.035175879396984924,
0.045226130653266326,
0.05527638190954774]
get_species(time_slice: int) list[source]

This function get_species creates a Mendeleiev table and returns a list of species based on the values of a, z, and the table.

Parameters:
time_slice: int

time slice on which function should operate on. Defaults to 0.

Returns:

a list of species based on the values of a, z, and the Mendeleev table.

Example

import imas
connection = imas.DBEntry("imas:mdsplus?user=public;pulse=104010;run=2;database=ITER;version=3", "r")
idsObj = connection.get('core_profiles')
computeObj = CoreProfilesCompute(idsObj)
result = computeObj.get_species(time_slice=0)

['H', 'He4', 'Ne']
get_species_density(time_slice: int) tuple[source]

This function calculates the density of different species in a given slice and returns a tuple containing the species density list, the total density, and the index of the species with the maximum density.

Parameters:
time_slice: int

time slice on which function should operate on. Defaults to 0.

Returns:

a list of species density, the total density of all species, and the index of the species with the maximum density.

Return type:

a tuple containing three values

Example

import imas
connection = imas.DBEntry("imas:mdsplus?user=public;pulse=104010;run=2;database=ITER;version=3", "r")
idsObj = connection.get('core_profiles')
connection.close()
computeObj = CoreProfilesCompute(idsObj)
result = computeObj.get_species_density(time_slice=0)

([6.50016400579169e+23, 8.289108520803897e+22, 6.202712465391594e+21],7.391101982525995e+23, 0)
get_state_density(time_slice: int, species_index: int = 0, state_index: int = 0) numpy.ndarray | None[source]

This function get_state_density returns the density of a specified state of a specified species at a specified time slice, or the thermal density if the former is not available.

Parameters:
time_slice: int

an integer representing the index of the time slice for which the density is being requested. Defaults to 0

species_index: int = 0

The index of the ion species for which the density is being retrieved. Defaults to 0

state_index: int = 0

The index of the state for which the density is being retrieved. Defaults to 0

Returns:

a numpy array containing the density of a specified state of a specified species at a specified time slice. If the density is not available, it returns None.

Example

import imas
connection = imas.DBEntry("imas:mdsplus?user=public;pulse=104010;run=2;database=ITER;version=3", "r")
idsObj = connection.get('core_profiles')
connection.close()
computeObj = CoreProfilesCompute(idsObj)
result = computeObj.get_state_density(time_slice, speciesIndex=0, stateIndex=0)

array([4.16759116e+19, 4.17266130e+19, 4.17275806e+19, 4.17086410e+19,
4.16751781e+19, 4.16983762e+19, 4.17344996e+19, 4.17944658e+19,
get_states(time_slice: int) list[source]

This function get_states returns quantities related to the different states of the species (ionisation, energy, excitation, …) for each species

Parameters:
time_slice: int

time slice on which function should operate on. Defaults to 0.

Returns:

a list of states (ionisation, energy, excitation, etc.) in the input data of each species .

Example

import imas
connection = imas.DBEntry("imas:mdsplus?user=public;pulse=105033;run=1;database=ITER;version=3", "r")

idsObj = connection.get('core_profiles')
connection.close()
computeObj = CoreProfilesCompute(idsObj)
result = computeObj.get_states(time_slice=0)

print(result[0]) # state object from species
get_states_data(time_slice: int) dict[source]

This function get_states_data returns a dictionary containing data on the states and densities of different species in a plasma simulation.

Parameters:
time_slice: int

time slice on which function should operate on. Defaults to 0.

Returns:

a dictionary containing information about the states of different species in a plasma, including their labels, z-averages, densities, and relative densities.

Example

import imas
connection = imas.DBEntry("imas:mdsplus?user=public;pulse=104010;run=2;database=ITER;version=3", "r")
idsObj = connection.get('core_profiles')
connection.close()
computeObj = CoreProfilesCompute(idsObj)
result = computeObj.get_states_data(time_slice=0)


{'0': {'0': {'density_available': True,
'label': '',
'n_ni': 100.0,
'states_density': [6.50016400579169e+23],
'z_average': -9e+40}},
'1': {'0': {'density_available': True,
'label': '',
'n_ni': 0.023001604469815865,
'states_density': [1.906627956029117e+19, 8.287201892847867e+22],
'z_average': -9e+40},
get_volume(time_slice: int) numpy.ndarray[source]

This function get_volume returns the volume of a grid at a given time slice.

Parameters:
time_slice: int

time slice on which function should operate on. Defaults to 0.

Returns:

the volume of the grid for a given time slice. If the volume is empty, it returns None

Example

import imas
connection = imas.DBEntry("imas:mdsplus?user=public;pulse=104010;run=2;database=ITER;version=3", "r")
idsObj = connection.get('core_profiles')
connection.close()
computeObj = CoreProfilesCompute(idsObj)
result = computeObj.get_volume(time_slice=0)

array([4.39932160e-02, 2.19952424e-01, 5.71837023e-01, 1.09958863e+00,
1.80311391e+00, 2.68234060e+00, 3.73724537e+00, 4.96778828e+00,
get_z(time_slice: int, element_index: int = 0) list[source]

This function get_z returns a list of nuclear charges for each species in a given slice and element index.

Parameters:
time_slice: int

time slice on which functions should operate on. Defaults to 0.

element_index: int = 0

element of the atom or molecule on which functions should operate on. Defaults to 0.

Returns:

a list of nuclear charges for each species in the given time_slice and elementIndex.

Example

import imas
connection = imas.DBEntry("imas:mdsplus?user=public;pulse=105033;run=1;database=ITER;version=3", "r")
idsObj = connection.get('core_profiles')
connection.close()
computeObj = CoreProfilesCompute(idsObj)
result = computeObj.get_z(time_slice=0)

[1, 1, 2, 4, 74, 18, 10]
getnrho(time_slice)[source]

This function getnrho returns the number of elements in the rho_tor_norm or rho_tor grid based on the provided slice index.

Parameters:
time_slice

The time_slice parameter in the getnrho method is used to specify which slice of data to retrieve the number of rho values from.

Returns:

The getnrho method is returning the number of elements in the rho_tor_norm or rho_tor attribute of the grid object within the profiles_1d object at the specified time_slice. If either of these attributes has elements, the length of that attribute is returned as the number of nrho.

idstools.compute.core_profiles.logger