1010
1111import numpy as np
1212
13- from ryd_numerov .species .utils import calc_energy_from_nu , convert_electron_configuration
13+ from ryd_numerov .species .utils import calc_nu_from_energy , convert_electron_configuration
1414from ryd_numerov .units import rydberg_constant , ureg
1515
1616if TYPE_CHECKING :
@@ -48,7 +48,7 @@ class SpeciesObject(ABC):
4848 _ionization_energy : tuple [float , float | None , str ]
4949 """Ionization energy with uncertainty and unit: (value, uncertainty, unit)."""
5050
51- # Parameters for the extended Rydberg Ritz formula, see calc_energy
51+ # Parameters for the extended Rydberg Ritz formula, see calc_nu
5252 _quantum_defects : ClassVar [dict [tuple [int , float , float ], tuple [float , float , float , float , float ]] | None ] = None
5353 """Dictionary containing the quantum defects for each (l, j_tot, s_tot) combination, i.e.
5454 _quantum_defects[(l,j_tot,s_tot)] = (d0, d2, d4, d6, d8)
@@ -321,33 +321,7 @@ def reduced_mass_factor(self) -> float:
321321 """
322322 return self .get_corrected_rydberg_constant ("hartree" ) / rydberg_constant .to ("hartree" ).m
323323
324- @overload
325- def calc_energy (
326- self ,
327- n : int ,
328- l : int ,
329- j_tot : float ,
330- s_tot : float | None = None ,
331- * ,
332- use_nist_data : bool = True ,
333- nist_n_max : int = 15 ,
334- unit : None = None ,
335- ) -> PintFloat : ...
336-
337- @overload
338- def calc_energy (
339- self ,
340- n : int ,
341- l : int ,
342- j_tot : float ,
343- s_tot : float | None = None ,
344- * ,
345- use_nist_data : bool = True ,
346- nist_n_max : int = 15 ,
347- unit : str ,
348- ) -> float : ...
349-
350- def calc_energy ( # noqa: C901
324+ def calc_nu (
351325 self ,
352326 n : int ,
353327 l : int ,
@@ -356,15 +330,15 @@ def calc_energy( # noqa: C901
356330 * ,
357331 use_nist_data : bool = True ,
358332 nist_n_max : int = 15 ,
359- unit : str | None = "hartree" ,
360- ) -> PintFloat | float :
361- r"""Calculate the energy of a Rydberg state with for the given n, l, j_tot and s_tot.
333+ ) -> float :
334+ r"""Calculate the effective principal quantum number nu of a Rydberg state with the given n, l, j_tot and s_tot.
362335
363- I.e. either look up the energy for low lying states in the nist data,
364- or calculate it via the quantum defect theory.
336+ I.e. either look up the energy for low lying states in the nist data (if use_nist_data is True),
337+ and calculate nu from the energy.
338+ Or calculate nu via the quantum defect theory.
365339
366- The effective principal quantum number in quantum defect theory
367- is defined as series expansion :math:`n^* = n - \delta_{lj}(n)`
340+ The effective principal quantum number nu in quantum defect theory
341+ is defined as series expansion :math:`\nu = n^* = n - \delta_{lj}(n)`
368342 where
369343
370344 .. math::
@@ -403,28 +377,18 @@ def calc_energy( # noqa: C901
403377 if j_tot % 1 != (l + s_tot ) % 1 :
404378 raise ValueError (f"Invalid quantum numbers: ({ l = } , { j_tot = } , { s_tot = } )" )
405379
406- energy_au : float | None = None
407- if n <= nist_n_max and use_nist_data :
380+ if n <= nist_n_max and use_nist_data : # try to use NIST data
408381 if (n , l , j_tot , s_tot ) in self ._nist_energy_levels :
409382 energy_au = self ._nist_energy_levels [(n , l , j_tot , s_tot )]
410383 energy_au -= self .get_ionization_energy ("hartree" )
411- else :
412- logger .debug (
413- "NIST energy levels for (n=%d, l=%d, j_tot=%s, s_tot=%s) not found, using quantum defect theory." ,
414- * (n , l , j_tot , s_tot ),
415- )
416-
417- if energy_au is None :
418- if self ._quantum_defects is None :
419- raise ValueError (f"No quantum defect data available for species { self .name } ." )
420- d0 , d2 , d4 , d6 , d8 = self ._quantum_defects .get ((l , j_tot , s_tot ), (0 , 0 , 0 , 0 , 0 ))
421- delta_nlj = d0 + d2 / (n - d0 ) ** 2 + d4 / (n - d0 ) ** 4 + d6 / (n - d0 ) ** 6 + d8 / (n - d0 ) ** 8
422- n_star = n - delta_nlj
423- energy_au = calc_energy_from_nu (self .reduced_mass_factor , n_star )
424-
425- energy : PintFloat = ureg .Quantity (energy_au , "hartree" )
426- if unit is None :
427- return energy
428- if unit == "a.u." :
429- return energy .magnitude
430- return energy .to (unit , "spectroscopy" ).magnitude
384+ return calc_nu_from_energy (self .reduced_mass_factor , energy_au )
385+ logger .debug (
386+ "NIST energy levels for (n=%d, l=%d, j_tot=%s, s_tot=%s) not found, using quantum defect theory." ,
387+ * (n , l , j_tot , s_tot ),
388+ )
389+
390+ if self ._quantum_defects is None :
391+ raise ValueError (f"No quantum defect data available for species { self .name } ." )
392+ d0 , d2 , d4 , d6 , d8 = self ._quantum_defects .get ((l , j_tot , s_tot ), (0 , 0 , 0 , 0 , 0 ))
393+ delta_nlj = d0 + d2 / (n - d0 ) ** 2 + d4 / (n - d0 ) ** 4 + d6 / (n - d0 ) ** 6 + d8 / (n - d0 ) ** 8
394+ return n - delta_nlj
0 commit comments