Skip to content

Commit

Permalink
Merge branch 'development' into docs/atomic_repository_manipulation
Browse files Browse the repository at this point in the history
  • Loading branch information
vsnever authored Jul 31, 2024
2 parents 8934c8c + 2a77f38 commit db0f614
Show file tree
Hide file tree
Showing 8 changed files with 394 additions and 65 deletions.
78 changes: 60 additions & 18 deletions cherab/openadas/rates/atomic.pyx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

# Copyright 2016-2021 Euratom
# Copyright 2016-2021 United Kingdom Atomic Energy Authority
# Copyright 2016-2021 Centro de Investigaciones Energéticas, Medioambientales y Tecnológicas
# Copyright 2016-2024 Euratom
# Copyright 2016-2024 United Kingdom Atomic Energy Authority
# Copyright 2016-2024 Centro de Investigaciones Energéticas, Medioambientales y Tecnológicas
#
# Licensed under the EUPL, Version 1.1 or – as soon they will be approved by the
# European Commission - subsequent versions of the EUPL (the "Licence");
Expand All @@ -24,12 +24,26 @@ from raysect.core.math.function.float cimport Interpolator2DArray


cdef class IonisationRate(CoreIonisationRate):
"""
Ionisation rate.
Data is interpolated with cubic spline in log-log space.
Nearest neighbour extrapolation is used if extrapolate is True.
:param dict data: Ionisation rate dictionary containing the following entries:
| 'ne': 1D array of size (N) with electron density in m^-3,
| 'te': 1D array of size (M) with electron temperature in eV,
| 'rate': 2D array of size (N, M) with ionisation rate in m^3.s^-1.
:param bint extrapolate: Enable extrapolation (default=False).
:ivar tuple density_range: Electron density interpolation range.
:ivar tuple temperature_range: Electron temperature interpolation range.
:ivar dict raw_data: Dictionary containing the raw data.
"""

def __init__(self, dict data, extrapolate=False):
"""
:param data: Dictionary containing rate data.
:param extrapolate: Enable extrapolation (default=False).
"""

self.raw_data = data

Expand Down Expand Up @@ -62,7 +76,7 @@ cdef class IonisationRate(CoreIonisationRate):

cdef class NullIonisationRate(CoreIonisationRate):
"""
A PEC rate that always returns zero.
An ionisation rate that always returns zero.
Needed for use cases where the required atomic data is missing.
"""

Expand All @@ -71,12 +85,26 @@ cdef class NullIonisationRate(CoreIonisationRate):


cdef class RecombinationRate(CoreRecombinationRate):
"""
Recombination rate.
Data is interpolated with cubic spline in log-log space.
Nearest neighbour extrapolation is used if extrapolate is True.
:param dict data: Recombination rate dictionary containing the following entries:
| 'ne': 1D array of size (N) with electron density in m^-3,
| 'te': 1D array of size (M) with electron temperature in eV,
| 'rate': 2D array of size (N, M) with recombination rate in m^3.s^-1.
:param bint extrapolate: Enable extrapolation (default=False).
:ivar tuple density_range: Electron density interpolation range.
:ivar tuple temperature_range: Electron temperature interpolation range.
:ivar dict raw_data: Dictionary containing the raw data.
"""

def __init__(self, dict data, extrapolate=False):
"""
:param data: Dictionary containing rate data.
:param extrapolate: Enable extrapolation (default=False).
"""

self.raw_data = data

Expand Down Expand Up @@ -109,7 +137,7 @@ cdef class RecombinationRate(CoreRecombinationRate):

cdef class NullRecombinationRate(CoreRecombinationRate):
"""
A PEC rate that always returns zero.
A recombination rate that always returns zero.
Needed for use cases where the required atomic data is missing.
"""

Expand All @@ -118,12 +146,26 @@ cdef class NullRecombinationRate(CoreRecombinationRate):


cdef class ThermalCXRate(CoreThermalCXRate):
"""
Thermal charge exchange rate.
Data is interpolated with cubic spline in log-log space.
Linear extrapolation is used if extrapolate is True.
:param dict data: CX rate dictionary containing the following entries:
| 'ne': 1D array of size (N) with electron density in m^-3,
| 'te': 1D array of size (M) with electron temperature in eV,
| 'rate': 2D array of size (N, M) with thermal CX rate in m^3.s^-1.
:param bint extrapolate: Enable extrapolation (default=False).
:ivar tuple density_range: Electron density interpolation range.
:ivar tuple temperature_range: Electron temperature interpolation range.
:ivar dict raw_data: Dictionary containing the raw data.
"""

def __init__(self, dict data, extrapolate=False):
"""
:param data: Dictionary containing rate data.
:param extrapolate: Enable extrapolation (default=False).
"""

self.raw_data = data

Expand Down Expand Up @@ -155,7 +197,7 @@ cdef class ThermalCXRate(CoreThermalCXRate):

cdef class NullThermalCXRate(CoreThermalCXRate):
"""
A PEC rate that always returns zero.
A thermal CX rate that always returns zero.
Needed for use cases where the required atomic data is missing.
"""

Expand Down
81 changes: 67 additions & 14 deletions cherab/openadas/rates/beam.pyx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Copyright 2016-2021 Euratom
# Copyright 2016-2021 United Kingdom Atomic Energy Authority
# Copyright 2016-2021 Centro de Investigaciones Energéticas, Medioambientales y Tecnológicas
# Copyright 2016-2024 Euratom
# Copyright 2016-2024 United Kingdom Atomic Energy Authority
# Copyright 2016-2024 Centro de Investigaciones Energéticas, Medioambientales y Tecnológicas
#
# Licensed under the EUPL, Version 1.1 or – as soon they will be approved by the
# European Commission - subsequent versions of the EUPL (the "Licence");
Expand Down Expand Up @@ -31,8 +31,26 @@ cdef class BeamStoppingRate(CoreBeamStoppingRate):
"""
The beam stopping coefficient interpolation class.
:param data: A dictionary holding the beam coefficient data.
:param extrapolate: Set to True to enable extrapolation, False to disable (default).
Data is interpolated with cubic spline in log-log space.
Linear and quadratic extrapolations are used for "sen" and "st" respectively
if extrapolate is True.
:param dict data: A beam stopping rate dictionary containing the following entries:
| 'e': 1D array of size (N) with interaction energy in eV/amu,
| 'n': 1D array of size (M) with target electron density in m^-3,
| 't': 1D array of size (K) with target electron temperature in eV,
| 'sen': 2D array of size (N, M) with beam stopping rate energy component in m^3.s^-1.
| 'st': 1D array of size (K) with beam stopping rate temperature component in m^3.s^-1.
| 'sref': reference beam stopping rate in m^3.s^-1.
| The total beam stopping rate: s = sen * st / sref.
:param bint extrapolate: Set to True to enable extrapolation, False to disable (default).
:ivar tuple beam_energy_range: Interaction energy interpolation range.
:ivar tuple density_range: Target electron density interpolation range.
:ivar tuple temperature_range: Target electron temperature interpolation range.
:ivar dict raw_data: Dictionary containing the raw data.
"""

@cython.cdivision(True)
Expand Down Expand Up @@ -93,7 +111,7 @@ cdef class BeamStoppingRate(CoreBeamStoppingRate):

cdef class NullBeamStoppingRate(CoreBeamStoppingRate):
"""
A beam rate that always returns zero.
A beam stopping rate that always returns zero.
Needed for use cases where the required atomic data is missing.
"""

Expand All @@ -105,8 +123,26 @@ cdef class BeamPopulationRate(CoreBeamPopulationRate):
"""
The beam population coefficient interpolation class.
:param data: A dictionary holding the beam coefficient data.
:param extrapolate: Set to True to enable extrapolation, False to disable (default).
Data is interpolated with cubic spline in log-log space.
Linear and quadratic extrapolations are used for "sen" and "st" respectively
if extrapolate is True.
:param dict data: Beam population rate dictionary containing the following entries:
| 'e': 1D array of size (N) with interaction energy in eV/amu,
| 'n': 1D array of size (M) with target electron density in m^-3,
| 't': 1D array of size (K) with target electron temperature in eV,
| 'sen': 2D array of size (N, M) with dimensionless beam population rate energy component.
| 'st': 1D array of size (K) with dimensionless beam population rate temperature component.
| 'sref': reference dimensionless beam population rate.
| The total beam population rate: s = sen * st / sref.
:param bint extrapolate: Set to True to enable extrapolation, False to disable (default).
:ivar tuple beam_energy_range: Interaction energy interpolation range.
:ivar tuple density_range: Target electron density interpolation range.
:ivar tuple temperature_range: Target electron temperature interpolation range.
:ivar dict raw_data: Dictionary containing the raw data.
"""

@cython.cdivision(True)
Expand Down Expand Up @@ -167,7 +203,7 @@ cdef class BeamPopulationRate(CoreBeamPopulationRate):

cdef class NullBeamPopulationRate(CoreBeamPopulationRate):
"""
A beam rate that always returns zero.
A beam population rate that always returns zero.
Needed for use cases where the required atomic data is missing.
"""

Expand All @@ -179,9 +215,26 @@ cdef class BeamEmissionPEC(CoreBeamEmissionPEC):
"""
The beam emission coefficient interpolation class.
:param data: A dictionary holding the beam coefficient data.
:param wavelength: The natural wavelength of the emission line associated with the rate data in nm.
:param extrapolate: Set to True to enable extrapolation, False to disable (default).
Data is interpolated with cubic spline in log-log space.
Linear and quadratic extrapolations are used for "sen" and "st" respectively
if extrapolate is True.
:param dict data: Beam emission rate dictionary containing the following entries:
| 'e': 1D array of size (N) with interaction energy in eV/amu,
| 'n' 1D array of size (M) with target electron density in m^-3,
| 't' 1D array of size (K) with target electron temperature in eV,
| 'sen' 2D array of size (N, M) with beam emission rate energy component in photon.m^3.s^-1.
| 'st' 1D array of size (K) with beam emission rate temperature component in photon.m^3.s^-1.
| 'sref': reference beam emission rate in photon.m^3.s^-1.
:param double wavelength: The natural wavelength of the emission line associated with the rate data in nm.
:param bint extrapolate: Set to True to enable extrapolation, False to disable (default).
:ivar tuple beam_energy_range: Interaction energy interpolation range.
:ivar tuple density_range: Target electron density interpolation range.
:ivar tuple temperature_range: Target electron temperature interpolation range.
:ivar dict raw_data: Dictionary containing the raw data.
"""

@cython.cdivision(True)
Expand All @@ -194,7 +247,7 @@ cdef class BeamEmissionPEC(CoreBeamEmissionPEC):
e = data["e"] # eV/amu
n = data["n"] # m^-3
t = data["t"] # eV
sen = np.log10(PhotonToJ.to(data["sen"], wavelength)) # W.m^3/s
sen = np.log10(PhotonToJ.to(data["sen"], wavelength)) # W.m^3
st = np.log10(data["st"] / data["sref"]) # dimensionless

# store limits of data
Expand Down Expand Up @@ -243,7 +296,7 @@ cdef class BeamEmissionPEC(CoreBeamEmissionPEC):

cdef class NullBeamEmissionPEC(CoreBeamEmissionPEC):
"""
A beam rate that always returns zero.
A beam emission PEC that always returns zero.
Needed for use cases where the required atomic data is missing.
"""

Expand Down
50 changes: 40 additions & 10 deletions cherab/openadas/rates/cx.pyx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Copyright 2016-2021 Euratom
# Copyright 2016-2021 United Kingdom Atomic Energy Authority
# Copyright 2016-2021 Centro de Investigaciones Energéticas, Medioambientales y Tecnológicas
# Copyright 2016-2024 Euratom
# Copyright 2016-2024 United Kingdom Atomic Energy Authority
# Copyright 2016-2024 Centro de Investigaciones Energéticas, Medioambientales y Tecnológicas
#
# Licensed under the EUPL, Version 1.1 or – as soon they will be approved by the
# European Commission - subsequent versions of the EUPL (the "Licence");
Expand All @@ -26,12 +26,42 @@ from raysect.core.math.function.float cimport Interpolator1DArray, Constant1D

cdef class BeamCXPEC(CoreBeamCXPEC):
"""
The effective cx rate interpolation class.
:param donor_metastable: The metastable state of the donor species for which the rate data applies.
:param wavelength: The natural wavelength of the emission line associated with the rate data in nm.
:param data: A dictionary holding the rate data.
:param extrapolate: Set to True to enable extrapolation, False to disable (default).
Effective charge exchange photon emission coefficient.
The data for "qeb" is interpolated with a cubic spline in log-log space.
The data for "qti", "qni", "qz" and "qb" are interpolated with a cubic spline
in linear space.
Quadratic extrapolation is used for "qeb" and nearest neighbour extrapolation is used for
"qti", "qni", "qz" and "qb" if extrapolate is True.
:param int donor_metastable: The metastable state of the donor species for which the rate data applies.
:param double wavelength: The natural wavelength of the emission line associated with the rate data in nm.
:param data: Beam CX PEC dictionary containing the following entries:
| 'eb': 1D array of size (N) with beam energy in eV/amu,
| 'ti': 1D array of size (M) with receiver ion temperature in eV,
| 'ni': 1D array of size (K) with receiver ion density in m^-3,
| 'z': 1D array of size (L) with receiver Z-effective,
| 'b': 1D array of size (J) with magnetic field strength in Tesla,
| 'qeb': 1D array of size (N) with CX PEC energy component in photon.m^3.s-1,
| 'qti': 1D array of size (M) with CX PEC temperature component in photon.m^3.s-1,
| 'qni': 1D array of size (K) with CX PEC density component in photon.m^3.s-1,
| 'qz': 1D array of size (L) with CX PEC Zeff component in photon.m^3.s-1,
| 'qb': 1D array of size (J) with CX PEC B-field component in photon.m^3.s-1,
| 'qref': reference CX PEC in photon.m^3.s-1.
| The total beam CX PEC: q = qeb * qti * qni * qz * qb / qref^4.
:param bint extrapolate: Set to True to enable extrapolation, False to disable (default).
:ivar tuple beam_energy_range: Interaction energy interpolation range.
:ivar tuple density_range: Receiver ion density interpolation range.
:ivar tuple temperature_range: Receiver ion temperature interpolation range.
:ivar tuple zeff_range: Z-effective interpolation range.
:ivar tuple b_field_range: Magnetic field strength interpolation range.
:ivar int donor_metastable: The metastable state of the donor species.
:ivar double wavelength: The natural wavelength of the emission line in nm.
:ivar dict raw_data: Dictionary containing the raw data.
"""

@cython.cdivision(True)
Expand Down Expand Up @@ -79,7 +109,7 @@ cdef class BeamCXPEC(CoreBeamCXPEC):
:param energy: Interaction energy in eV/amu.
:param temperature: Receiver ion temperature in eV.
:param density: Receiver ion density in m^-3
:param density: Plasma total ion density in m^-3
:param z_effective: Plasma Z-effective.
:param b_field: Magnetic field magnitude in Tesla.
:return: The effective cx rate in W.m^3
Expand Down
Loading

0 comments on commit db0f614

Please sign in to comment.