Skip to content

Split the openadas module into atomic repository and OpenADAS parser #377

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 28 commits into
base: development
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
9cc198a
Split atomic repository and OpenADAS parsing/installing methods.
vsnever Aug 22, 2022
b1d7adb
Fix backward compatibility.
vsnever Aug 22, 2022
ad58ca4
Fix incorrect units in some docstings and comments of atomic rate cla…
vsnever Aug 25, 2022
149e677
Improved docstrings in openadas and atomic repository functions. Upda…
vsnever Aug 25, 2022
659525a
Update changelog.
vsnever Aug 25, 2022
8741996
Merge branch 'development' into enhancement/atomic_data_repository
vsnever Feb 14, 2023
6c59bca
Merge branch 'development' into enhancement/atomic_data_repository
vsnever Jun 19, 2023
e80fa83
Update docstring for the atomic repository functions and interpolated…
vsnever Jul 10, 2023
e43aacf
Add repository functions for free-free Gaunt factor.
vsnever Jul 10, 2023
1347c94
Add repository functions for Zeeman structure.
vsnever Jul 10, 2023
5e2e27b
Update demo and changelog.
vsnever Jul 10, 2023
32edbd4
Update documentation for the atomic data.
vsnever Jul 10, 2023
1da0a66
Merge branch 'development' into enhancement/atomic_data_repository
vsnever Jul 10, 2023
3f62034
Fix docstrings for atomic data interpolators.
vsnever Jul 12, 2023
c2b0b5d
Add interpolators for total radiated power and fractional abundance.
vsnever Jul 12, 2023
11d535b
Fix multiple file rewrites in atomic data update functions.
vsnever Jul 12, 2023
6669c4d
Change path to Zeeman multiplet structure in the atomic repository to…
vsnever Jul 13, 2023
7d17b1e
Fix a KeyError in _notation_adf11_adas2cherab().
vsnever Aug 7, 2023
d6e0280
Fix a bug with undefined repository_path in add_total_power_rate.
vsnever Aug 8, 2023
54e3176
Fix the name of total_radiated_power() method in AtomicData.
vsnever Aug 8, 2023
77a360f
Fix a bug in TotalRadiatedPower.
vsnever Aug 8, 2023
feb05cf
Merge branch 'development' into enhancement/atomic_data_repository
vsnever Aug 9, 2023
7b4cf8b
Change path to Zeeman multiplet data in the atomic repository to matc…
vsnever Aug 9, 2023
5c95ad7
Add support for the CHERAB_ATOMIC_DATA environment variable defining …
vsnever Aug 9, 2023
dbe0bdc
Added description of CHERAB_ATOMIC_DATA environment variable to the d…
vsnever Aug 9, 2023
4b8e454
Update AtomicData docstring.
vsnever Aug 10, 2023
276f9bc
Merge branch 'development' into enhancement/atomic_data_repository
vsnever Dec 2, 2023
38482c8
Fix bremsstrahlung test.
vsnever Dec 2, 2023
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
12 changes: 12 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,31 @@ Project Changelog
Release 1.5.0 (TBD)
-------------------

API changes:
* Interpolated rates and local atomic repository functions are separated from OpenADAS parsers and installers and moved to cherab.atomic. (#364)
* Default interface to atomic data repository is changed to cherab.atomic.AtomicData, as it includes the data beyond the frame of Open-ADAS. (#364)
* The interface cherab.openadas.OpenADAS will continue to work as a wrapper for cherab.atomic.AtomicData for backward compatibility. (#364)
* Default path to atomic data repository changed to `~/.cherab/atomicdata/default_repository`. Call populate() from cherab.atomic.repository after updating to 1.5.0 (#364)
* InterpolatedFreeFreeGauntFactor and MaxwellianFreeFreeGauntFactor are replaced with a general interpolator FreeFreeGauntFactor from cherab.atomic.gaunt. (#364)
* ZeemanStructure class is splitted to base (abstract) and interpolator classes. The latter is moved to cherab.atomic.zeeman and its initialiser interface is chaged to match the other atomic data interpolators. (#364)

New:
* Support Raysect 0.8
* Add custom line shape support to BeamCXLine model. (#394)
* Add functions to read/write free-free Gaunt factor in the atomic repository. (#364)
* Add functions to read/write Zeeman structure in the atomic repository. (#364)
* Add PeriodicTransformXD and VectorPeriodicTransformXD functions to support the data simulated with periodic boundary conditions. (#387)
* Add CylindricalTransform and VectorCylindricalTransform to transform functions from cylindrical to Cartesian coordinates. (#387)
* Add numerical integration of Bremsstrahlung spectrum over a spectral bin. (#395)
* Replace the coarse numerical constant in the Bremsstrahlung model with an exact expression. (#409)
* Add the kind attribute to RayTransferPipelineXD that determines whether the ray transfer matrix is multiplied by sensitivity ('power') or not ('radiance'). (#412)
* Improved parsing of metadata from the ADAS ADF15 'bnd' files for H-like ions. Raises a runtime error if the metadata cannot be parsed. (#424)
* Get the path to the default atomic data repository from the CHERAB_ATOMIC_DATA environment variable. (#416)

Bug fixes:
* Fix deprecated transforms being cached in LaserMaterial after laser.transform update (#420)


Release 1.4.0 (3 Feb 2023)
-------------------

Expand Down
20 changes: 20 additions & 0 deletions cherab/atomic/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Copyright 2016-2022 Euratom
# Copyright 2016-2022 United Kingdom Atomic Energy Authority
# Copyright 2016-2022 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");
# You may not use this work except in compliance with the Licence.
# You may obtain a copy of the Licence at:
#
# https://joinup.ec.europa.eu/software/page/eupl5
#
# Unless required by applicable law or agreed to in writing, software distributed
# under the Licence is distributed on an "AS IS" basis, WITHOUT WARRANTIES OR
# CONDITIONS OF ANY KIND, either express or implied.
#
# See the Licence for the specific language governing permissions and limitations
# under the Licence.

from . import repository
from .atomicdata import AtomicData
753 changes: 753 additions & 0 deletions cherab/atomic/atomicdata.py

Large diffs are not rendered by default.

19 changes: 19 additions & 0 deletions cherab/atomic/gaunt/__init__.pxd
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Copyright 2016-2023 Euratom
# Copyright 2016-2023 United Kingdom Atomic Energy Authority
# Copyright 2016-2023 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");
# You may not use this work except in compliance with the Licence.
# You may obtain a copy of the Licence at:
#
# https://joinup.ec.europa.eu/software/page/eupl5
#
# Unless required by applicable law or agreed to in writing, software distributed
# under the Licence is distributed on an "AS IS" basis, WITHOUT WARRANTIES OR
# CONDITIONS OF ANY KIND, either express or implied.
#
# See the Licence for the specific language governing permissions and limitations
# under the Licence.

from cherab.atomic.gaunt.gaunt cimport *
19 changes: 19 additions & 0 deletions cherab/atomic/gaunt/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Copyright 2016-2023 Euratom
# Copyright 2016-2023 United Kingdom Atomic Energy Authority
# Copyright 2016-2023 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");
# You may not use this work except in compliance with the Licence.
# You may obtain a copy of the Licence at:
#
# https://joinup.ec.europa.eu/software/page/eupl5
#
# Unless required by applicable law or agreed to in writing, software distributed
# under the Licence is distributed on an "AS IS" basis, WITHOUT WARRANTIES OR
# CONDITIONS OF ANY KIND, either express or implied.
#
# See the Licence for the specific language governing permissions and limitations
# under the Licence.

from .gaunt import FreeFreeGauntFactor
29 changes: 29 additions & 0 deletions cherab/atomic/gaunt/gaunt.pxd
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# Copyright 2016-2023 Euratom
# Copyright 2016-2023 United Kingdom Atomic Energy Authority
# Copyright 2016-2023 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");
# You may not use this work except in compliance with the Licence.
# You may obtain a copy of the Licence at:
#
# https://joinup.ec.europa.eu/software/page/eupl5
#
# Unless required by applicable law or agreed to in writing, software distributed
# under the Licence is distributed on an "AS IS" basis, WITHOUT WARRANTIES OR
# CONDITIONS OF ANY KIND, either express or implied.
#
# See the Licence for the specific language governing permissions and limitations
# under the Licence.

from cherab.core.math cimport Function2D
from cherab.core.atomic cimport FreeFreeGauntFactor as CoreFreeFreeGauntFactor


cdef class FreeFreeGauntFactor(CoreFreeFreeGauntFactor):

cdef:
readonly tuple u_range, gamma2_range
readonly dict raw_data
double _u_min, _u_max, _gamma2_min, _gamma2_max
Function2D _gaunt_factor
104 changes: 104 additions & 0 deletions cherab/atomic/gaunt/gaunt.pyx
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
# Copyright 2016-2023 Euratom
# Copyright 2016-2023 United Kingdom Atomic Energy Authority
# Copyright 2016-2023 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");
# You may not use this work except in compliance with the Licence.
# You may obtain a copy of the Licence at:
#
# https://joinup.ec.europa.eu/software/page/eupl5
#
# Unless required by applicable law or agreed to in writing, software distributed
# under the Licence is distributed on an "AS IS" basis, WITHOUT WARRANTIES OR
# CONDITIONS OF ANY KIND, either express or implied.
#
# See the Licence for the specific language governing permissions and limitations
# under the Licence.

import numpy as np
from libc.math cimport log10, log, M_PI, sqrt
from raysect.core.math.function.float cimport Interpolator2DArray
from cherab.core.utility.constants cimport RYDBERG_CONSTANT_EV, SPEED_OF_LIGHT, ELEMENTARY_CHARGE, PLANCK_CONSTANT

cimport cython


DEF EULER_GAMMA = 0.5772156649015329

cdef double PH_TO_EV_FACTOR = PLANCK_CONSTANT * SPEED_OF_LIGHT * 1e9 / ELEMENTARY_CHARGE


cdef class FreeFreeGauntFactor(CoreFreeFreeGauntFactor):
r"""
The temperature-averaged free-free Gaunt factors interpolated in the space of parameters:
:math:`u = h{\nu}/kT` and :math:`{\gamma}^{2} = Z^{2}Ry/kT`.
See T.R. Carson, 1988, Astron. & Astrophys., 189,
`319 <https://ui.adsabs.harvard.edu/#abs/1988A&A...189..319C/abstract>`_ for details.

The cubic interpolation in a semi-log space is used.

The Born approximation and classical limits are used outside the interpolation range.

:param dict data: Dictionary containing the Gaunt factor data with the following keys:

| 'u': A 1D array of real values.
| 'gamma2': A 1D array of real values.
| 'gaunt_factor': 2D array of real values storing the Gaunt factor values at u, gamma2.

:ivar tuple u_range: The interpolation range of `u` parameter.
:ivar tuple gamma2_range: The interpolation range of :math:`\\gamma^2` parameter.
:ivar dict raw_data: Dictionary containing the raw data.
"""

def __init__(self, dict data):

self.raw_data = data

u = data['u']
gamma2 = data['gamma2']
gaunt_factor = data['gaunt_factor']

self._u_min = u.min()
self._u_max = u.max()
self._gamma2_min = gamma2.min()
self._gamma2_max = gamma2.max()

self.u_range = (self._u_min, self._u_max)
self.gamma2_range = (self._gamma2_min, self._gamma2_max)

self._gaunt_factor = Interpolator2DArray(np.log10(u), np.log10(gamma2), gaunt_factor, 'cubic', 'none', 0, 0)

@cython.cdivision(True)
cpdef double evaluate(self, double z, double temperature, double wavelength) except? -1e999:
"""
Returns the temperature-averaged free-free Gaunt factor for the supplied parameters.

:param double z: Species charge or effective plasma charge.
:param double temperature: Electron temperature in eV.
:param double wavelength: Spectral wavelength.

:return: free-free Gaunt factor
"""

cdef:
double u, gamma2

if z == 0:

return 0

gamma2 = z * z * RYDBERG_CONSTANT_EV / temperature
u = PH_TO_EV_FACTOR / (temperature * wavelength)

# classical limit
if u >= self._u_max or gamma2 >= self._gamma2_max:

return 1

# Born approximation limit
if u < self._u_min or gamma2 < self._gamma2_min:

return sqrt(3) / M_PI * (log(4 / u) - EULER_GAMMA)

return self._gaunt_factor.evaluate(log10(u), log10(gamma2))
24 changes: 24 additions & 0 deletions cherab/atomic/rates/__init__.pxd
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Copyright 2016-2022 Euratom
# Copyright 2016-2022 United Kingdom Atomic Energy Authority
# Copyright 2016-2022 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");
# You may not use this work except in compliance with the Licence.
# You may obtain a copy of the Licence at:
#
# https://joinup.ec.europa.eu/software/page/eupl5
#
# Unless required by applicable law or agreed to in writing, software distributed
# under the Licence is distributed on an "AS IS" basis, WITHOUT WARRANTIES OR
# CONDITIONS OF ANY KIND, either express or implied.
#
# See the Licence for the specific language governing permissions and limitations
# under the Licence.

from cherab.atomic.rates.beam cimport *
from cherab.atomic.rates.cx cimport *
from cherab.atomic.rates.pec cimport *
from cherab.atomic.rates.atomic cimport *
from cherab.atomic.rates.radiated_power cimport *
from cherab.atomic.rates.fractional_abundance cimport *
24 changes: 24 additions & 0 deletions cherab/atomic/rates/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Copyright 2016-2018 Euratom
# Copyright 2016-2018 United Kingdom Atomic Energy Authority
# Copyright 2016-2018 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");
# You may not use this work except in compliance with the Licence.
# You may obtain a copy of the Licence at:
#
# https://joinup.ec.europa.eu/software/page/eupl5
#
# Unless required by applicable law or agreed to in writing, software distributed
# under the Licence is distributed on an "AS IS" basis, WITHOUT WARRANTIES OR
# CONDITIONS OF ANY KIND, either express or implied.
#
# See the Licence for the specific language governing permissions and limitations
# under the Licence.

from .beam import *
from .cx import *
from .pec import *
from .atomic import *
from .radiated_power import *
from .fractional_abundance import *
File renamed without changes.
Loading