Skip to main content

No project description provided

Project description

Python versions on PyPI CeNTREX-TlF version on PyPI Code style: black

Extensions

CeNTREX-TlF-julia-extension version on PyPI CeNTREX-TlF version on PyPI

CeNTREX-TlF

Code for generating the CeNTREX TlF States, Hamiltonians, Transitions, Couplings and Lindblad equations.

Consists of six modules:

  • states
  • hamiltonian
  • transitions
  • couplings
  • lindblad
  • utils

states has code to generate states and the classes that describe the CoupledBasisState, UncoupledBasisState and State; where State holds multiple CoupledBasisStates or UncoupledBasisStates with different amplitudes, i.e. when superpositions arise.

Dependencies

  • numpy
  • scipy
  • sympy
  • pandas

Installation

python -m pip install .
where . is the path to the directory. To install directly from Github use:
python -m pip install git+https://github.com/ograsdijk/CeNTREX-TlF

states

states contains the functions and classes to represent the TlF states:
CoupledBasisState is a class representing a TlF state with coupled quantum numbers, i.e. F, mF, F1, J, I1, I2, Ω, P.
UncoupledBasisState is a class representing a TlF state with uncoupled quantum numbers, i.e. J, mJ, I1, m1, I2, m2, Ω, P.
Finally State is a class representing a collection of states, since in most cases the TlF molecules are in a superposition state.

from centrex_tlf import states
states.CoupledBasisState(F=1, mF=0, F1 = 1/2, J = 0, I1 = 1/2, I2 = 1/2, Omega = 0, P = 1)

or using some of the functions to generate all hyperfine substates in a given J level:

from centrex_tlf import states
QN = states.generate_uncoupled_states_ground(Js = [0,1])

which returns an array containing the UncoupledBasisStates

array([|X, J = 0, mJ = 0, I = 1/2, m = -1/2, I = 1/2, m = -1/2, P = +, Ω = 0>,
       |X, J = 0, mJ = 0, I = 1/2, m = -1/2, I = 1/2, m = 1/2, P = +, Ω = 0>,
       |X, J = 0, mJ = 0, I = 1/2, m = 1/2, I = 1/2, m = -1/2, P = +, Ω = 0>,
       |X, J = 0, mJ = 0, I = 1/2, m = 1/2, I = 1/2, m = 1/2, P = +, Ω = 0>,
       |X, J = 1, mJ = -1, I = 1/2, m = -1/2, I = 1/2, m = -1/2, P = -, Ω = 0>,
       |X, J = 1, mJ = -1, I = 1/2, m = -1/2, I = 1/2, m = 1/2, P = -, Ω = 0>,
       |X, J = 1, mJ = -1, I = 1/2, m = 1/2, I = 1/2, m = -1/2, P = -, Ω = 0>,
       |X, J = 1, mJ = -1, I = 1/2, m = 1/2, I = 1/2, m = 1/2, P = -, Ω = 0>,
       |X, J = 1, mJ = 0, I = 1/2, m = -1/2, I = 1/2, m = -1/2, P = -, Ω = 0>,
       |X, J = 1, mJ = 0, I = 1/2, m = -1/2, I = 1/2, m = 1/2, P = -, Ω = 0>,
       |X, J = 1, mJ = 0, I = 1/2, m = 1/2, I = 1/2, m = -1/2, P = -, Ω = 0>,
       |X, J = 1, mJ = 0, I = 1/2, m = 1/2, I = 1/2, m = 1/2, P = -, Ω = 0>,
       |X, J = 1, mJ = 1, I = 1/2, m = -1/2, I = 1/2, m = -1/2, P = -, Ω = 0>,
       |X, J = 1, mJ = 1, I = 1/2, m = -1/2, I = 1/2, m = 1/2, P = -, Ω = 0>,
       |X, J = 1, mJ = 1, I = 1/2, m = 1/2, I = 1/2, m = -1/2, P = -, Ω = 0>,
       |X, J = 1, mJ = 1, I = 1/2, m = 1/2, I = 1/2, m = 1/2, P = -, Ω = 0>],
      dtype=object)

State objects, which are superpositions of BasisStates are also generated easily:

superposition = 1*QN[0] + 0.1j*QN[1]

which returns

1.00 x |X, J = 0, mJ = 0, I = 1/2, m = -1/2, I = 1/2, m = -1/2, P = +, Ω = 0>
0.00+0.10j x |X, J = 0, mJ = 0, I = 1/2, m = -1/2, I = 1/2, m = 1/2, P = +, Ω = 0>

A subset of State, CoupledBasisStates can be selected with the QuantumSelector as follows:

QN = states.generate_coupled_states_ground(Js = [0,1])
qn_select = states.QuantumSelector(J = 1, mF = 0, electronic = states.ElectronicState.X)
qn_select.get_indices(QN)

which returns all the indices with J=1 and mJ=0:

array([ 4,  6,  9, 13], dtype=int64)

hamiltonian

hamiltonian contains the functions to generate TlF hamiltonians in the X and B state in either coupled or uncoupled form.
Generating a ground state X hamiltonian can be accomplished easily using some convenience functions:

from centrex_tlf import states, hamiltonian

# generate the hyperfine sublevels in J=0 and J=1
QN = states.generate_uncoupled_states_ground(Js = [0,1])

# generate a dictionary with X hamiltonian terms
H = hamiltonian.generate_uncoupled_hamiltonian_X(QN)

# create a function outputting the hamiltonian as a function of E and B
Hfunc = hamiltonian.generate_uncoupled_hamiltonian_X_function(H)

All functions generating hamiltonians only require a list or array of TlF states. Generating the hamiltonian only for certain hyperfine sublevels is hence also straightforward. The function calculate_uncoupled_hamiltonian_X calculates the hamiltonians from scratch, whereas generate_uncoupled_hamiltonian_X pulls the non-zero elements from an sqlite database.

To convert a hamiltonian from one basis to another transformation matrices can be generated or calculated (generate_transform_matrix pulls non-zero matrix elements from an sqlite database, calculate_transform_matrix does the full element wise calculation):

from centrex_tlf import states, hamiltonian

# generate the hyperfine sublevels in J=0 and J=1
QN = states.generate_uncoupled_states_ground(Js = [0,1])
# generate the coupled hyperfine sublevels in J=0 and J=1
QNc = states.generate_coupled_states_ground(Js = [0,1])

# generate a dictionary with X hamiltonian terms
H = hamiltonian.generate_uncoupled_hamiltonian_X(QN)
Hfunc = hamiltonian.generate_uncoupled_hamiltonian_X_function(H)
H0 = Hfunc(E = [0,0,0], B = [0,0,1e-3])

# generate the transformation matrix
transform = hamiltonian.generate_transform_matrix(QN, QNc)

# calculate the transformed matrix
H0c = transform.conj().T@H0@transform

This is mostly used for optical bloch simulations where the coupled states representation is more convenient.

Stark Shift Example

To calculate the energy levels as a function of the electric field the following code can be used, which calculates all energies up to J=6 but only plots the |J=2, mJ=0> hyperfine levels. These are the states focussed by the electrostatic quadrupole lens in the CeNTREX experiment. Quadrupole Lens States

import numpy as np
import matplotlib.pyplot as plt

from centrex_tlf import states, hamiltonian

# generate states up to J=6
QN = states.generate_uncoupled_states_ground(Js=np.arange(7))

# generate the X hamiltonian terms
H = hamiltonian.generate_uncoupled_hamiltonian_X(QN)

# create a function outputting the hamiltonian as a function of E and B
Hfunc = hamiltonian.generate_uncoupled_hamiltonian_X_function(H)

# V/cm
Ez = np.linspace(0, 50e3, 101)

# generate the Hamiltonian for (almost) zero field, add a small field to make states
# non-degenerate
Hi = Hfunc(E=[0, 0, 1e-3], B=[0, 0, 1e-3])
E, V = np.linalg.eigh(Hi)

# get the true superposition-states of the system
QN_states = hamiltonian.matrix_to_states(V, QN)

# original eigenvectors used in tracking states as energies change order
V_track = V.copy()

# indices of the J=2, mJ=0 states focused by the lens
indices_J2_mJ0 = [
    idx
    for idx, s in enumerate(QN_states)
    if s.largest.J == 2 and s.largest.mJ == 0
]

indices_J012 = [
    idx for idx, s in enumerate(QN_states) if s.largest.J in [0, 1, 2]
]

# empty array for storing energies
energy = np.empty([Ez.size, len(QN)], dtype=np.complex128)

# iterate over the electric field values
for idx, Ei in enumerate(Ez):
    Hi = Hfunc(E=[0, 0, Ei], B=[0, 0, 1e-3])
    E, V = np.linalg.eigh(Hi)

    # sort indices to keep the state order the same
    indices = np.argmax(np.abs(V_track.conj().T @ V), axis=1)
    energy[idx, :] = E[indices]
    V_track[:, :] = V[:, indices]

# plot the J=2, mJ=0 Stark curves
fig, ax = plt.subplots(figsize=(12, 8))
ax.plot(
    Ez,
    (energy.real[:, indices_J2_mJ0] - energy.real[:, indices_J2_mJ0][0, 0])
    / (2 * np.pi * 1e9),
)
ax.set_xlabel("E [V/cm]")
ax.set_ylabel("Energy [GHz]")
ax.set_title("|J=2, mJ=0> Stark Curve")
ax.grid(True)
plt.show()

couplings

Code for generating the CeNTREX TlF couplings. Includes code for generating branching ratios, electric dipole coupling elements and coupling fields

Generating branching ratios

The code below generates branching ratios from |J'=1, F1'=1/2, mF=0> to all states in the J=1 manifold.

from centrex_tlf import states, couplings

excited_state = states.CoupledBasisState(
    J=1, F1=1 / 2, F=1, mF=0, I1=1 / 2, I2=1 / 2, Omega=1, P=1
)
qn_select = states.QuantumSelector(J=1)
ground_states = [1*s for s in states.generate_coupled_states_X(qn_select)]
br = couplings.calculate_br(1 * excited_state, ground_states)

Generating couplings

The code below generates the coupling fields for the J=1 manifold to the J'=1, F1'=1/2, F'=1 manifold. The returned value is a dataclass CouplingFields containing the following fields:

  • ground_main
  • excited_main
  • main_coupling: the electric dipole coupling between ground_main and excited_main
  • ground_states: list of all ground states
  • excited_states: list of all excited states
  • fields: a list of CouplingField dataclasses with the following fields:
    • polarization: polarization vector
    • field: coupling field in the ground_states + excited_states basis
from centrex_tlf import states, couplings

qn_select = states.QuantumSelector(J=1)
ground_states = states.generate_coupled_states_X(qn_select)

qn_select = states.QuantumSelector(J=1, F1=1 / 2, F=1, P=1, Ω=1)
excited_states = states.generate_coupled_states_B(qn_select)

# the generate_coupling_field_* functions requires lists as inputs, not np.ndarrays
QN = list(1 * np.append(ground_states, excited_states))
ground_states = [1*s for s in  ground_states]
excited_states = [1*s for s in excited_states]

H_rot = np.eye(len(QN), dtype=complex) * np.arange(len(QN))
V_ref = np.eye(len(QN))
pol_vecs = [np.array([0.0, 0.0, 1.0]), np.array([1.0, 0.0, 0.0])]
normalize_pol = True

coupling = couplings.generate_coupling_field_automatic(
    ground_states_approx = ground_states, 
    excited_states_approx = excited_states, 
    QN_basis = QN,
    H_rot = H_rot, 
    QN = QN, 
    V_ref = V_ref, 
    pol_vecs = pol_vecs, 
    normalize_pol = normalize_pol
)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

centrex_tlf-0.1.8-cp313-cp313-win_amd64.whl (321.8 kB view details)

Uploaded CPython 3.13Windows x86-64

centrex_tlf-0.1.8-cp313-cp313-manylinux_2_28_x86_64.whl (476.1 kB view details)

Uploaded CPython 3.13manylinux: glibc 2.28+ x86-64

centrex_tlf-0.1.8-cp313-cp313-macosx_11_0_arm64.whl (428.7 kB view details)

Uploaded CPython 3.13macOS 11.0+ ARM64

centrex_tlf-0.1.8-cp312-cp312-win_amd64.whl (322.1 kB view details)

Uploaded CPython 3.12Windows x86-64

centrex_tlf-0.1.8-cp312-cp312-manylinux_2_28_x86_64.whl (476.3 kB view details)

Uploaded CPython 3.12manylinux: glibc 2.28+ x86-64

centrex_tlf-0.1.8-cp312-cp312-macosx_11_0_arm64.whl (428.4 kB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

centrex_tlf-0.1.8-cp311-cp311-win_amd64.whl (324.9 kB view details)

Uploaded CPython 3.11Windows x86-64

centrex_tlf-0.1.8-cp311-cp311-manylinux_2_28_x86_64.whl (480.1 kB view details)

Uploaded CPython 3.11manylinux: glibc 2.28+ x86-64

centrex_tlf-0.1.8-cp311-cp311-macosx_11_0_arm64.whl (435.4 kB view details)

Uploaded CPython 3.11macOS 11.0+ ARM64

centrex_tlf-0.1.8-cp310-cp310-win_amd64.whl (324.9 kB view details)

Uploaded CPython 3.10Windows x86-64

centrex_tlf-0.1.8-cp310-cp310-manylinux_2_28_x86_64.whl (480.0 kB view details)

Uploaded CPython 3.10manylinux: glibc 2.28+ x86-64

centrex_tlf-0.1.8-cp310-cp310-macosx_11_0_arm64.whl (435.3 kB view details)

Uploaded CPython 3.10macOS 11.0+ ARM64

File details

Details for the file centrex_tlf-0.1.8-cp313-cp313-win_amd64.whl.

File metadata

File hashes

Hashes for centrex_tlf-0.1.8-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 3006c7a2f9179d981586e8cf99b23ec3a50519b93402d5bcdfa7b602bf6d4732
MD5 676dff2350b82e09e23dcb6688aba77b
BLAKE2b-256 7e3cd2424b5e1c8cd73b1d75e1d1cc6b1e8061a02b93f13d7b27017d68cb2584

See more details on using hashes here.

File details

Details for the file centrex_tlf-0.1.8-cp313-cp313-manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for centrex_tlf-0.1.8-cp313-cp313-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 99a6795abd8c1beed31057190b7b0a15510e0bc15ab3b8f27bc1c8c395b8ac5a
MD5 650c9c3741c83c727447bf7b66fc6ca8
BLAKE2b-256 809c244aa9f92c75dceccfa5483b0e077256d5982193c17654e63a588a1c3b71

See more details on using hashes here.

File details

Details for the file centrex_tlf-0.1.8-cp313-cp313-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for centrex_tlf-0.1.8-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 87984d9454d528f2279c17774b89cd0a958199fe341f913073ac2bb3a764dc24
MD5 102c02f54261fcfdbfbbf8357eb72438
BLAKE2b-256 9df24e69560c6bd722425b8c6360c3d243c69dd80e3d84d3c03d3111b3d8b2de

See more details on using hashes here.

File details

Details for the file centrex_tlf-0.1.8-cp312-cp312-win_amd64.whl.

File metadata

File hashes

Hashes for centrex_tlf-0.1.8-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 aa1e7b8a4108590301dfea58bee258b8d7490e59950430d5f8bb9b9461ab812e
MD5 0e1abbc9a6c255e68ff19d7d26d0dadd
BLAKE2b-256 cd4c27ec723270ad8ef225f528a4f77cad46c28e3e6fbfbe9246be4b73ae7313

See more details on using hashes here.

File details

Details for the file centrex_tlf-0.1.8-cp312-cp312-manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for centrex_tlf-0.1.8-cp312-cp312-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 78029b0aeb7ba83cb6d9b4290062314415193c3f6026fe2157c6b7eb5dd946a5
MD5 c9d0ed8236fa883eca57da844783e076
BLAKE2b-256 bf7ef9f52898e1d00ecf2a9449ba823209257b14456b628b994aa20ae1672ae3

See more details on using hashes here.

File details

Details for the file centrex_tlf-0.1.8-cp312-cp312-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for centrex_tlf-0.1.8-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 2936b87a5f63d18b4a5f3c62334424fe281d6b76f9c5ac1faa9d6a543eee228a
MD5 c5b8fd9125fb680bac2f4124bae635c0
BLAKE2b-256 44bb0fa3a5a83b4cbc2aa6b4c5550784adde1e096daf4f68922e8784e687cf83

See more details on using hashes here.

File details

Details for the file centrex_tlf-0.1.8-cp311-cp311-win_amd64.whl.

File metadata

File hashes

Hashes for centrex_tlf-0.1.8-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 ece65121ee78d3df158b163d7d78e6e1d1040549decb6a402c911cec7080e916
MD5 49db293c8ba494e14d62a9698050f1f1
BLAKE2b-256 d3e22c3aa31f0ae768ec94da7b5adb1ad823843452040aad453ee5199cba3005

See more details on using hashes here.

File details

Details for the file centrex_tlf-0.1.8-cp311-cp311-manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for centrex_tlf-0.1.8-cp311-cp311-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 cd4b0c2b4e3c8191922783fa4f513e3543ab2b21bcef1151acec0535eecea86a
MD5 1045a8e0b9d77fdba0f168b4641209ce
BLAKE2b-256 328508c6e0c09fc7fb7df06c86927f936b3758036c30a65f5c1c86a33991dcc9

See more details on using hashes here.

File details

Details for the file centrex_tlf-0.1.8-cp311-cp311-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for centrex_tlf-0.1.8-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 682a0577179d704779f79b998bb3f444eb5c0929e994951058e8d355e1817c82
MD5 0eea0127537d5d5e388a2e7135c5a314
BLAKE2b-256 0feae12a98bd8b3414e1a20b75c8321c8d79d2e58a227a2f13818d02e8e4ae91

See more details on using hashes here.

File details

Details for the file centrex_tlf-0.1.8-cp310-cp310-win_amd64.whl.

File metadata

File hashes

Hashes for centrex_tlf-0.1.8-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 d0bfcd74749cbfc6adf22af1cf9ddfa3b3c6a924402b49d57bac74f48de2a581
MD5 ef46b04409aa7632f90eab161a9402ca
BLAKE2b-256 fb197e45d0b649e973e1a047616ce45f5bc89be252136073a7311bf28d375991

See more details on using hashes here.

File details

Details for the file centrex_tlf-0.1.8-cp310-cp310-manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for centrex_tlf-0.1.8-cp310-cp310-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 062bf746f8a24c37cb64fe8692244d37a2ab49702f71109decc31c9ccb3f154f
MD5 2c8d1cf7325cf2831b5ac8898f938c65
BLAKE2b-256 4d88938fa1fbdacbcdfb31a55b58e6aea0ec7e699b2283d2f9922ce308a144de

See more details on using hashes here.

File details

Details for the file centrex_tlf-0.1.8-cp310-cp310-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for centrex_tlf-0.1.8-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 56ce2a85d827d812e5bc1eff2de1ae7eaee64d445e16528d29a1a6fb189c28a8
MD5 425c25ca545c82b663315f47c9c3005f
BLAKE2b-256 5ec63653ce69f9e5e0f55faabfada566157e4e959648d87ffdac081a6cd4c188

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page