Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
61 changes: 35 additions & 26 deletions cherab/openadas/install.py
Original file line number Diff line number Diff line change
Expand Up @@ -269,14 +269,17 @@ def install_adf15(element, ionisation, file_path, download=False, repository_pat


def install_adf21(beam_species, target_ion, target_charge, file_path, download=False, repository_path=None, adas_path=None):
# """
# Adds the rate defined in an ADF21 file to the repository.
#
# :param file_path: Path relative to ADAS root.
# :param download: Attempt to download file if not present (Default=True).
# :param repository_path: Path to the repository in which to install the rates (optional).
# :param adas_path: Path to ADAS files repository (optional).
# """
"""
Adds the beam stopping rate defined in an ADF21 file to the repository.

:param beam_species: Beam neutral atom (Element/Isotope).
:param target_ion: Target species (Element/Isotope).
:param target_charge: Charge of the target species.
:param file_path: Path relative to ADAS root.
:param download: Attempt to download file if not present (Default=True).
:param repository_path: Path to the repository in which to install the rates (optional).
:param adas_path: Path to ADAS files repository (optional).
"""

print('Installing {}...'.format(file_path))
path = _locate_adas_file(file_path, download, adas_path, repository_path)
Expand All @@ -289,15 +292,18 @@ def install_adf21(beam_species, target_ion, target_charge, file_path, download=F


def install_adf22bmp(beam_species, beam_metastable, target_ion, target_charge, file_path, download=False, repository_path=None, adas_path=None):
pass
# """
# Adds the rate defined in an ADF21 file to the repository.
#
# :param file_path: Path relative to ADAS root.
# :param download: Attempt to download file if not present (Default=True).
# :param repository_path: Path to the repository in which to install the rates (optional).
# :param adas_path: Path to ADAS files repository (optional).
# """
"""
Adds the beam population rate defined in an ADF22 BMP file to the repository.

:param beam_species: Beam neutral atom (Element/Isotope).
:param beam_metastable: Metastable/excitation level of beam neutral atom.
:param target_ion: Target species (Element/Isotope).
:param target_charge: Charge of the target species.
:param file_path: Path relative to ADAS root.
:param download: Attempt to download file if not present (Default=True).
:param repository_path: Path to the repository in which to install the rates (optional).
:param adas_path: Path to ADAS files repository (optional).
"""

print('Installing {}...'.format(file_path))
path = _locate_adas_file(file_path, download, adas_path, repository_path)
Expand All @@ -310,15 +316,18 @@ def install_adf22bmp(beam_species, beam_metastable, target_ion, target_charge, f


def install_adf22bme(beam_species, target_ion, target_charge, transition, file_path, download=False, repository_path=None, adas_path=None):
pass
# """
# Adds the rate defined in an ADF21 file to the repository.
#
# :param file_path: Path relative to ADAS root.
# :param download: Attempt to download file if not present (Default=True).
# :param repository_path: Path to the repository in which to install the rates (optional).
# :param adas_path: Path to ADAS files repository (optional).
# """
"""
Adds the beam emission rate defined in an ADF22 BME file to the repository.

:param beam_species: Beam neutral atom (Element/Isotope).
:param target_ion: Target species (Element/Isotope).
:param target_charge: Charge of the target species.
:param transition: Tuple containing (initial level, final level).
:param file_path: Path relative to ADAS root.
:param download: Attempt to download file if not present (Default=True).
:param repository_path: Path to the repository in which to install the rates (optional).
:param adas_path: Path to ADAS files repository (optional).
"""

print('Installing {}...'.format(file_path))
path = _locate_adas_file(file_path, download, adas_path, repository_path)
Expand Down
143 changes: 121 additions & 22 deletions cherab/openadas/repository/atomic.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Copyright 2016-2018 Euratom
# Copyright 2016-2018 United Kingdom Atomic Energy Authority
# Copyright 2016-2018 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 @@ -34,8 +34,15 @@ def add_ionisation_rate(species, charge, rate, repository_path=None):
function instead. The update function avoids repeatedly opening and closing
the rate files.

:param repository_path:
:return:
:param species: Plasma species (Element/Isotope).
:param charge: Charge of the plasma species.
:param rate: Ionisation rate dictionary containing the following entries:

| 'ne': array-like of size (N) with electron density in m^-3,
| 'te': array-like of size (M) with electron temperature in eV,
| 'rate': array-like of size (N, M) with ionisation rate in m^3.s^-1.

:param repository_path: Path to the atomic data repository.
"""

update_ionisation_rates({
Expand All @@ -47,11 +54,21 @@ def add_ionisation_rate(species, charge, rate, repository_path=None):

def update_ionisation_rates(rates, repository_path=None):
"""
Ionisation rate file structure

/ionisation/<species>.json
Updates the ionisation rate files `/ionisation/<species>.json`
in atomic data repository.

File contains multiple rates, indexed by the ion charge state.

:param rates: Dictionary in the form {<species>: {<charge>: <rate>}}, where

| <species> is the plasma species (Element/Isotope),
| <charge> is the charge of the plasma species,
| <rate> is the ionisation rate dictionary containing the following entries:
| 'ne': array-like of size (N) with electron density in m^-3,
| 'te': array-like of size (M) with electron temperature in eV,
| 'rate': array-like of size (N, M) with ionisation rate in m^3.s^-1.

:param repository_path: Path to the atomic data repository.
"""

repository_path = repository_path or DEFAULT_REPOSITORY_PATH
Expand All @@ -75,8 +92,15 @@ def add_recombination_rate(species, charge, rate, repository_path=None):
function instead. The update function avoids repeatedly opening and closing
the rate files.

:param repository_path:
:return:
:param species: Plasma species (Element/Isotope).
:param charge: Charge of the plasma species.
:param rate: Recombination rate dictionary containing the following entries:

| 'ne': array-like of size (N) with electron density in m^-3,
| 'te': array-like of size (M) with electron temperature in eV,
| 'rate': array-like of size (N, M) with recombination rate in m^3.s^-1.

:param repository_path: Path to the atomic data repository.
"""

update_recombination_rates({
Expand All @@ -88,11 +112,21 @@ def add_recombination_rate(species, charge, rate, repository_path=None):

def update_recombination_rates(rates, repository_path=None):
"""
Ionisation rate file structure

/recombination/<species>.json
Updates the recombination rate files `/recombination/<species>.json`
in the atomic data repository.

File contains multiple rates, indexed by the ion charge state.

:param rates: Dictionary in the form {<species>: {<charge>: <rate>}}, where

| <species> is the plasma species (Element/Isotope),
| <charge> is the charge of the plasma species,
| <rate> is the recombination rate dictionary containing the following entries:
| 'ne': array-like of size (N) with electron density in m^-3,
| 'te': array-like of size (M) with electron temperature in eV,
| 'rate': array-like of size (N, M) with recombination rate in m^3.s^-1.

:param repository_path: Path to the atomic data repository.
"""

repository_path = repository_path or DEFAULT_REPOSITORY_PATH
Expand All @@ -109,7 +143,6 @@ def update_recombination_rates(rates, repository_path=None):


def add_thermal_cx_rate(donor_element, donor_charge, receiver_element, rate, repository_path=None):

"""
Adds a single thermal charge exchange rate to the repository.

Expand All @@ -118,11 +151,16 @@ def add_thermal_cx_rate(donor_element, donor_charge, receiver_element, rate, rep
the rate files.

:param donor_element: Element donating the electron.
:param donor_charge: Charge of the donating atom/ion
:param receiver_element: Element receiving the electron
:param rate: rates
:param repository_path:
:return:
:param donor_charge: Charge of the donating atom/ion.
:param receiver_element: Element receiving the electron.
:param receiver_charge: Charge of the receiving atom/ion.
:param rate: Thermal CX rate dictionary containing the following entries:

| 'ne': array-like of size (N) with electron density in m^-3,
| 'te': array-like of size (M) with electron temperature in eV,
| 'rate': array-like of size (N, M) with thermal CX rate in m^3.s^-1.

:param repository_path: Path to the atomic data repository.
"""

rates2update = RecursiveDict()
Expand All @@ -133,11 +171,25 @@ def add_thermal_cx_rate(donor_element, donor_charge, receiver_element, rate, rep

def update_thermal_cx_rates(rates, repository_path=None):
"""
Thermal charge exchange rate file structure

/thermal_cx/<donor_element>/<donor_charge>/<receiver_element>.json
Updates the thermal charge exchange rate files
`/thermal_cx/<donor_element>/<donor_charge>/<receiver_element>.json`
in the atomic data repository.

File contains multiple rates, indexed by the ion charge state.

:param rates: Dictionary in the form:

| { <donor_element>: { <donor_charge>: { <receiver_element>: { <donor_charge>: <rate> } } } }, where
| <donor_element> is the element donating the electron.
| <donor_charge> is the charge of the donating atom/ion.
| <receiver_element> is the element receiving the electron.
| <receiver_charge> is the charge of the receiving atom/ion.
| <rate> is the thermal CX rate dictionary containing the following entries:
| 'ne': array-like of size (N) with electron density in m^-3,
| 'te': array-like of size (M) with electron temperature in eV,
| 'rate': array-like of size (N, M) with thermal CX rate in m^3.s^-1.

:param repository_path: Path to the atomic data repository.
"""

repository_path = repository_path or DEFAULT_REPOSITORY_PATH
Expand Down Expand Up @@ -203,6 +255,21 @@ def _update_and_write_adf11(species, rate_data, path):


def get_ionisation_rate(element, charge, repository_path=None):
"""
Reads the ionisation rate for the given species and charge
from the atomic data repository.

:param element: Plasma species (Element/Isotope).
:param charge: Charge of the plasma species.
:param repository_path: Path to the atomic data repository.

:return rate: 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.

"""

repository_path = repository_path or DEFAULT_REPOSITORY_PATH

Expand All @@ -224,6 +291,21 @@ def get_ionisation_rate(element, charge, repository_path=None):


def get_recombination_rate(element, charge, repository_path=None):
"""
Reads the recombination rate for the given species and charge
from the atomic data repository.

:param element: Plasma species (Element/Isotope).
:param charge: Charge of the plasma species.
:param repository_path: Path to the atomic data repository.

:return rate: 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.

"""

repository_path = repository_path or DEFAULT_REPOSITORY_PATH

Expand All @@ -245,6 +327,23 @@ def get_recombination_rate(element, charge, repository_path=None):


def get_thermal_cx_rate(donor_element, donor_charge, receiver_element, receiver_charge, repository_path=None):
"""
Reads the thermal charge exchange rate for the given species and charge
from the atomic data repository.

:param donor_element: Element donating the electron.
:param donor_charge: Charge of the donating atom/ion.
:param receiver_element: Element receiving the electron.
:param receiver_charge: Charge of the receiving atom/ion.
:param repository_path: Path to the atomic data repository.

:return rate: Thermal 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.

"""

repository_path = repository_path or DEFAULT_REPOSITORY_PATH

Expand Down
Loading