Skip to content
Open
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
5 changes: 4 additions & 1 deletion CHANGES
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
0.0.5-1
- fix unit tests

0.0.5 (unreleased)
------------------

Expand All @@ -17,4 +20,4 @@
- Fix bug in wigner_6j cache

0.0.2 (2021-10-13)
------------------
------------------
8 changes: 2 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,8 @@
# atomphys

<p align="left">
<a href="https://mgrau.github.io/atomphys/"><img src="https://mgrau.github.io/atomphys/img/logo.svg" alt="atomphys logo"></a>
</p>
# atomphys_ea

<!--intro-start-->

A Python package to help with atomic physics calculations.
A Python package to help with atomic physics calculations (fork of [atomphys](https://github.com/mgrau/atomphys))

[![Tests](https://github.com/mgrau/atomphys/actions/workflows/tests.yml/badge.svg)](https://github.com/mgrau/atomphys/actions/workflows/tests.yml)
[![Codecov](https://img.shields.io/codecov/c/github/mgrau/atomphys)](https://app.codecov.io/gh/mgrau/atomphys)
Expand Down
4 changes: 2 additions & 2 deletions atomphys/data/nist.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,10 @@ def fetch_states(atom, refresh_cache=False):
"term_out": "on", # output the term symbol string
"conf_out": "on", # output the configutation string
"level_out": "on", # output the energy level
"unc_out": 0, # uncertainty on energy
"unc_out": 1, # uncertainty on energy
"j_out": "on", # output the J level
"g_out": "on", # output the g-factor
"lande_out": "off", # output experimentally measured g-factor
"lande_out": "on", # output experimentally measured g-factor
}

get_postfix = urllib.parse.urlencode(values)
Expand Down
10 changes: 5 additions & 5 deletions atomphys/transition.py
Original file line number Diff line number Diff line change
Expand Up @@ -189,12 +189,12 @@ def ω(self):

@property
def _frequency(self):
return (self._energy) / self._ureg.h
return (self._energy) / self._ureg.planck_constant

@_frequency.setter
@default_units("THz")
def _frequency(self, frequency):
self._energy = frequency * self._ureg.h
self._energy = frequency * self._ureg.planck_constant

@property
def frequency(self):
Expand Down Expand Up @@ -227,14 +227,14 @@ def ν(self):
@property
def _wavelength(self):
try:
return (self._ureg.h * self._ureg.c) / self._energy
return (self._ureg.planck_constant * self._ureg.c) / self._energy
except ZeroDivisionError:
return self._ureg.Quantity(inf, "nm")

@_wavelength.setter
@default_units("nm")
def _wavelength(self, wavelength):
self._energy = (self._ureg.h * self._ureg.c) / wavelength
self._energy = (self._ureg.planck_constant * self._ureg.c) / wavelength

@property
def wavelength(self):
Expand Down Expand Up @@ -347,7 +347,7 @@ def branching_ratio(self):

@property
def saturation_intensity(self):
h = self._ureg.h
h = self._ureg.planck_constant
c = self._ureg.c
return π * h * c * self.Γ / (3 * self.λ ** 3)

Expand Down
115 changes: 115 additions & 0 deletions docs/img/logo_ea.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
8 changes: 4 additions & 4 deletions tests/test_Rb.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,14 @@ def test_rubidium(rubidium):
assert D2.ω.to("THz").m == pytest.approx(2 * π * 384.230484, rel=1e-6)
assert D2.λ.to("nm").m == pytest.approx(780.241209, rel=1e-6)
assert Rb("2P3/2").τ.to("ns").m == pytest.approx(26.24, rel=1e-3)
assert D2.Γ.to("MHz").m == pytest.approx(2 * π * 6.059, rel=1e-3)
assert D2.Γ.to("MHz").m == pytest.approx(2 * π * 6.059, rel=1e-2)

D1 = Rb("2S1/2").to("2P1/2")
assert D1.ω.to("THz").m == pytest.approx(2 * π * 377.107463, rel=1e-6)
assert D1.λ.to("nm").m == pytest.approx(794.978850, rel=1e-6)
assert Rb("2P1/2").τ.to("ns").m == pytest.approx(27.70, rel=1e-3)
assert D1.Γ.to("MHz").m == pytest.approx(2 * π * 5.746, rel=1e-3)
assert Rb("2P1/2").τ.to("ns").m == pytest.approx(27.70, rel=1e-2)
assert D1.Γ.to("MHz").m == pytest.approx(2 * π * 5.746, rel=1e-2)

α0S = Rb("2S1/2").α()

assert α0S.to("h Hz/(V/cm)^2").m == pytest.approx(0.0794, 4e-2)
assert α0S.to("planck_constant Hz/(V/cm)^2").m == pytest.approx(0.0794, 4e-2)
2 changes: 1 addition & 1 deletion tests/test_laser.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ def test_units():
def test_Rabi_frequency():
transition = Transition(
state_i=State("2S1/2"),
state_f=State("2P1/2", energy="h*c/(532 nm)"),
state_f=State("2P1/2", energy="planck_constant*c/(532 nm)"),
d="1 e a0",
)
laser = Laser(I="1 mW/cm^2")
Expand Down
6 changes: 3 additions & 3 deletions tests/test_state.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,14 +134,14 @@ def test_lifetime():
assert State().lifetime.check("[time]")
assert 1 / State().lifetime == 0

state = State("2P1/2", energy="h*c/(532 nm)")
state = State("2P1/2", energy="planck_constant*c/(532 nm)")
Transition(state_i=State("2S1/2"), state_f=state, Gamma="1 MHz")
state.τ == state._ureg("1 us")


def test_polarizability():
state_i = State("2S1/2")
state_f = State("2P1/2", energy="h*c/(532 nm)")
state_f = State("2P1/2", energy="planck_constant*c/(532 nm)")
Transition(state_i=state_i, state_f=state_f, Gamma="1 MHz")

state_i.α().m_as("ε_0 a0^3") == pytest.approx(7.26913647)
Expand Down Expand Up @@ -230,7 +230,7 @@ def test_registry_search():
states(State())

state_i = State("2S1/2")
state_f = State("2P1/2", energy="h*c/(532 nm)")
state_f = State("2P1/2", energy="planck_constant*c/(532 nm)")
transition = Transition(state_i=state_i, state_f=state_f, Gamma="1 MHz")
assert state_i.to("P1/2") is transition

Expand Down
6 changes: 3 additions & 3 deletions tests/test_transition.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@

def test_initialization():
state_i = State("2S1/2")
state_f = State("2P1/2", energy="h*c/(532 nm)")
state_f = State("2P1/2", energy="planck_constant*c/(532 nm)")
transition = Transition(state_i, state_f)
assert isinstance(transition, Transition)
assert transition.energy == transition._ureg("h*c/(532 nm)")
assert transition.energy == transition._ureg("planck_constant*c/(532 nm)")
assert transition.state_i is state_i
assert transition.state_f is state_f
assert transition.wavelength == transition._ureg.Quantity(532, "nm")
Expand Down Expand Up @@ -112,7 +112,7 @@ def test_match_states():
def test_repr():
assert str(Transition()) == "Transition(None <--> None : λ=inf nm, Γ=2π×0 Hz)"
assert (
str(Transition(State("2S1/2"), State("2P1/2", energy="h*c/(532 nm)"), d=1))
str(Transition(State("2S1/2"), State("2P1/2", energy="planck_constant*c/(532 nm)"), d=1))
== "Transition(2S1/2 <--> 2P1/2 : λ=532 nm, Γ=2π×1.07 MHz)"
)

Expand Down