Skip to content
This repository was archived by the owner on Nov 10, 2025. It is now read-only.

Commit b962903

Browse files
put constants into unit
1 parent 5f7e853 commit b962903

6 files changed

Lines changed: 38 additions & 25 deletions

File tree

src/ryd_numerov/elements/base_element.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
import numpy as np
1111

12-
from ryd_numerov.units import ureg
12+
from ryd_numerov.units import rydberg_constant, ureg
1313

1414
if TYPE_CHECKING:
1515
from ryd_numerov.model.model import PotentialType
@@ -313,8 +313,7 @@ def reduced_mass_factor(self) -> float:
313313
314314
"""
315315
return ( # type: ignore [no-any-return] # pint typing .to(unit)
316-
self.get_corrected_rydberg_constant("hartree")
317-
/ ureg.Quantity(1, "rydberg_constant").to("hartree", "spectroscopy").magnitude
316+
self.get_corrected_rydberg_constant("hartree") / rydberg_constant.to("hartree").m
318317
)
319318

320319
@overload

src/ryd_numerov/elements/hydrogen.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
11
from typing import ClassVar
22

33
from ryd_numerov.elements.base_element import BaseElement
4-
from ryd_numerov.units import ureg
5-
6-
RydbergConstant = ureg.Quantity(1, "rydberg_constant").to("eV", "spectroscopy")
4+
from ryd_numerov.units import rydberg_constant
75

86

97
class Hydrogen(BaseElement):
@@ -29,7 +27,7 @@ class HydrogenTextBook(BaseElement):
2927
number_valence_electrons = 1
3028
ground_state_shell = (1, 0)
3129

32-
_ionization_energy = (RydbergConstant.magnitude, 0, str(RydbergConstant.units))
30+
_ionization_energy = (rydberg_constant.m, 0, str(rydberg_constant.u))
3331

3432
potential_type_default = "coulomb"
3533

src/ryd_numerov/elements/strontium.py

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,7 @@
22
from typing import ClassVar, Optional
33

44
from ryd_numerov.elements.base_element import BaseElement
5-
from ryd_numerov.units import ureg
6-
7-
RydbergConstant = ureg.Quantity(1, "rydberg_constant").to("cm^-1", "spectroscopy").magnitude
8-
electron_mass = ureg.Quantity(1, "electron_mass").to("u").magnitude
5+
from ryd_numerov.units import electron_mass, rydberg_constant
96

107

118
class _StrontiumAbstract(BaseElement):
@@ -41,7 +38,11 @@ class Strontium88(_StrontiumAbstract):
4138

4239
# https://physics.nist.gov/PhysRefData/Handbook/Tables/strontiumtable1.htm
4340
_isotope_mass = 87.905619 # u
44-
_corrected_rydberg_constant = (RydbergConstant / (1 + electron_mass / _isotope_mass), None, "1/cm")
41+
_corrected_rydberg_constant = (
42+
rydberg_constant.m / (1 + electron_mass.to("u").m / _isotope_mass),
43+
None,
44+
str(rydberg_constant.u),
45+
)
4546

4647
# -- [1] Phys. Rev. A 108, 022815 (2023)
4748
# -- [2] http://dx.doi.org/10.17169/refubium-34581
@@ -72,5 +73,9 @@ class Strontium87(_StrontiumAbstract):
7273
species = "Sr87"
7374

7475
# https://physics.nist.gov/PhysRefData/Handbook/Tables/strontiumtable1.htm
75-
_isotope_mass = 86.908884 # u
76-
_corrected_rydberg_constant = (RydbergConstant / (1 + electron_mass / _isotope_mass), None, "1/cm")
76+
_isotope_mass_u = 86.908884 # u
77+
_corrected_rydberg_constant = (
78+
rydberg_constant.m / (1 + electron_mass.to("u").m / _isotope_mass_u),
79+
None,
80+
str(rydberg_constant.u),
81+
)

src/ryd_numerov/elements/ytterbium.py

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,7 @@
22
from typing import ClassVar
33

44
from ryd_numerov.elements.base_element import BaseElement
5-
from ryd_numerov.units import ureg
6-
7-
RydbergConstant = ureg.Quantity(1, "rydberg_constant").to("cm^-1", "spectroscopy").magnitude
8-
electron_mass = ureg.Quantity(1, "electron_mass").to("u").magnitude
5+
from ryd_numerov.units import electron_mass, rydberg_constant
96

107

118
class _YtterbiumAbstract(BaseElement):
@@ -31,20 +28,32 @@ class Ytterbium171(_YtterbiumAbstract):
3128

3229
# https://physics.nist.gov/PhysRefData/Handbook/Tables/ytterbiumtable1.htm
3330
_isotope_mass = 170.936323 # u
34-
_corrected_rydberg_constant = (RydbergConstant / (1 + electron_mass / _isotope_mass), None, "1/cm")
31+
_corrected_rydberg_constant = (
32+
rydberg_constant.m / (1 + electron_mass.to("u").m / _isotope_mass),
33+
None,
34+
str(rydberg_constant.u),
35+
)
3536

3637

3738
class Ytterbium173(_YtterbiumAbstract):
3839
species = "Yb173"
3940

4041
# https://physics.nist.gov/PhysRefData/Handbook/Tables/ytterbiumtable1.htm
4142
_isotope_mass = 172.938208 # u
42-
_corrected_rydberg_constant = (RydbergConstant / (1 + electron_mass / _isotope_mass), None, "1/cm")
43+
_corrected_rydberg_constant = (
44+
rydberg_constant.m / (1 + electron_mass.to("u").m / _isotope_mass),
45+
None,
46+
str(rydberg_constant.u),
47+
)
4348

4449

4550
class Ytterbium174(_YtterbiumAbstract):
4651
species = "Yb174"
4752

4853
# https://physics.nist.gov/PhysRefData/Handbook/Tables/ytterbiumtable1.htm
4954
_isotope_mass = 173.938859 # u
50-
_corrected_rydberg_constant = (RydbergConstant / (1 + electron_mass / _isotope_mass), None, "1/cm")
55+
_corrected_rydberg_constant = (
56+
rydberg_constant.m / (1 + electron_mass.to("u").m / _isotope_mass),
57+
None,
58+
str(rydberg_constant.u),
59+
)

src/ryd_numerov/units.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,3 +76,7 @@
7676
"MAGNETIC_FIELD": "Gaussian",
7777
"ENERGY": "spectroscopy",
7878
}
79+
80+
81+
rydberg_constant = ureg.Quantity(1, "rydberg_constant").to("hartree", "spectroscopy")
82+
electron_mass = ureg.Quantity(1, "electron_mass").to("u")

tests/test_units.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,10 @@
11
import numpy as np
22

3-
from ryd_numerov.units import ureg
3+
from ryd_numerov.units import rydberg_constant, ureg
44

55

66
def test_constants() -> None:
7-
assert np.isclose(
8-
ureg.Quantity(1, "rydberg_constant").to("1/cm").magnitude, 109737.31568157, rtol=1e-10, atol=1e-10
9-
)
7+
assert np.isclose(rydberg_constant.to("1/cm", "spectroscopy").magnitude, 109737.31568157, rtol=1e-10, atol=1e-10)
108
assert np.isclose(
119
ureg.Quantity(1, "fine_structure_constant").to_base_units().magnitude,
1210
0.0072973525643394025,

0 commit comments

Comments
 (0)