Skip to content
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

Add initial guess to field_insensitive_point #63

Merged
merged 1 commit into from
Oct 31, 2023
Merged
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
10 changes: 3 additions & 7 deletions atomic_physics/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
import scipy.constants as consts
import atomic_physics as ap


_uB = consts.physical_constants["Bohr magneton"][0]
_uN = consts.physical_constants["nuclear magneton"][0]

Expand Down Expand Up @@ -65,17 +64,14 @@ def d2f_dB2(atom: ap.Atom, lower: int, upper: int, eps: float = 1e-4):
return (dfpr - df) / eps


def field_insensitive_point(
atom: ap.Atom, lower: int, upper: int, B_min: float = 1e-3, B_max: float = 1e-1
):
def field_insensitive_point(atom: ap.Atom, lower: int, upper: int, B0: float = 1e-8):
"""Returns the magnetic field at which the frequency of a transition
between two states in the same level becomes first-order field independent.

:param atom: the atom to work with
:param lower: index of the lower energy state
:param upper: index of the higher-energy state
:param B_min: minimum magnetic field used in numerical minimization (T)
:param B_max: maximum magnetic field used in numerical maximization (T)
:param B0: Initial guess for the magnetic field root (T)
:return: the field-independent point (T) or None if none found

To do: add special case where we can use the BR formula
Expand All @@ -89,7 +85,7 @@ def fun(B: float):
atom.setB(B)
return df_dB(atom, lower, upper)

res = opt.root(fun, x0=1e-8, options={"xtol": 1e-4, "eps": 1e-7})
res = opt.root(fun, x0=B0, options={"xtol": 1e-4, "eps": 1e-7})
return res.x[0] if res.success else None


Expand Down
Loading