Skip to main content

Python versions on PyPI CeNTREX-TlF version on PyPI

See the changelog for release notes and migration guidance.

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.

Lindblad Solver Performance Options

Rust-backed Lindblad solves default to execution_mode="expanded_sparse". This mode uses a packed Hermitian density matrix and, by default, groups diagonal-real and complex input terms in the RHS kernel. The grouping can be controlled with use_split_input_rhs on solve_lindblad, solve_lindblad_batch, parameter_scan, initial_condition_scan, and grid_scan.

result = solve_lindblad(
    prepared,
    rho0,
    (0.0, t_end),
    execution_mode="expanded_sparse",
    use_split_input_rhs=True,  # default
)

Set use_split_input_rhs=False to keep the same expanded-sparse coefficient representation while disabling input-term grouping. This is mainly useful for benchmarking or checking full-system performance regressions; compact systems usually benefit from the default grouped path.

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
)

Metadata

Release files for centrex-tlf 0.2.7

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Built distributions (wheels)

Table of built distributions (wheels) for centrex-tlf 0.2.7
File
centrex_tlf-0.2.7-cp313-cp313-win_amd64.whl CPython 3.13 CPython 3.13 Windows x86-64 Details
centrex_tlf-0.2.7-cp313-cp313-manylinux_2_28_x86_64.whl CPython 3.13 CPython 3.13 Linux glibc 2.28+ x86-64 Details
centrex_tlf-0.2.7-cp313-cp313-macosx_11_0_arm64.whl CPython 3.13 CPython 3.13 macOS 11.0+ ARM64 Details
centrex_tlf-0.2.7-cp312-cp312-win_amd64.whl CPython 3.12 CPython 3.12 Windows x86-64 Details
centrex_tlf-0.2.7-cp312-cp312-manylinux_2_28_x86_64.whl CPython 3.12 CPython 3.12 Linux glibc 2.28+ x86-64 Details
centrex_tlf-0.2.7-cp312-cp312-macosx_11_0_arm64.whl CPython 3.12 CPython 3.12 macOS 11.0+ ARM64 Details
centrex_tlf-0.2.7-cp311-cp311-win_amd64.whl CPython 3.11 CPython 3.11 Windows x86-64 Details
centrex_tlf-0.2.7-cp311-cp311-manylinux_2_28_x86_64.whl CPython 3.11 CPython 3.11 Linux glibc 2.28+ x86-64 Details
centrex_tlf-0.2.7-cp311-cp311-macosx_11_0_arm64.whl CPython 3.11 CPython 3.11 macOS 11.0+ ARM64 Details
centrex_tlf-0.2.7-cp310-cp310-win_amd64.whl CPython 3.10 CPython 3.10 Windows x86-64 Details
centrex_tlf-0.2.7-cp310-cp310-manylinux_2_28_x86_64.whl CPython 3.10 CPython 3.10 Linux glibc 2.28+ x86-64 Details
centrex_tlf-0.2.7-cp310-cp310-macosx_11_0_arm64.whl CPython 3.10 CPython 3.10 macOS 11.0+ ARM64 Details

Total release size: 11.1 MB

Release files / centrex_tlf-0.2.7-cp313-cp313-win_amd64.whl

Download URL centrex_tlf-0.2.7-cp313-cp313-win_amd64.whl
Size 894.1 kB
Tags CPython 3.13 Windows x86-64
SHA-256 checksum
How to use checksums
d7ea5c587f59a54937e7d77dde15ce57c42b5cb4f65ae710dbe8f3347c703c5e
BLAKE2b-256 checksum
How to use checksums
946f98887ed597c3ef5c5d1d1778f44a0af1c96cf8061ca36e02ce93ed79424b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.14

Release files / centrex_tlf-0.2.7-cp313-cp313-manylinux_2_28_x86_64.whl

Download URL centrex_tlf-0.2.7-cp313-cp313-manylinux_2_28_x86_64.whl
Size 984.0 kB
Tags CPython 3.13 Linux glibc 2.28+ x86-64
SHA-256 checksum
How to use checksums
8108771fa00c944eb25582aaf5df3ae684911440b2a7c33636eaa0584456ca7d
BLAKE2b-256 checksum
How to use checksums
a85e097fb2ca647be3386c7ab951d440e4b6c5d4903245c153983bb604dc7208
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.14

Release files / centrex_tlf-0.2.7-cp313-cp313-macosx_11_0_arm64.whl

Download URL centrex_tlf-0.2.7-cp313-cp313-macosx_11_0_arm64.whl
Size 899.6 kB
Tags CPython 3.13 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
390328b3b00df5c845cd743e7e2890ea22335aa0ae31d2f5cc93c775295578ad
BLAKE2b-256 checksum
How to use checksums
9fb42894793bff271956dd40f484fb05f3d2a831b89a93db53f51028402219f1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.14

Release files / centrex_tlf-0.2.7-cp312-cp312-win_amd64.whl

Download URL centrex_tlf-0.2.7-cp312-cp312-win_amd64.whl
Size 891.7 kB
Tags CPython 3.12 Windows x86-64
SHA-256 checksum
How to use checksums
508c1818afdf053218cfa96105faacfe8bdc8ee16165eff92374875e7afca7e6
BLAKE2b-256 checksum
How to use checksums
e32c5bf127c4e269787d4d371738f47db797b5402f7d13bbe5ce8bb5c85c99b9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.14

Release files / centrex_tlf-0.2.7-cp312-cp312-manylinux_2_28_x86_64.whl

Download URL centrex_tlf-0.2.7-cp312-cp312-manylinux_2_28_x86_64.whl
Size 982.6 kB
Tags CPython 3.12 Linux glibc 2.28+ x86-64
SHA-256 checksum
How to use checksums
499b8c04a0e7483803df5f6559fb2f348535eb79a85114f940f2424a587ad856
BLAKE2b-256 checksum
How to use checksums
09f1c82c2bdde445cd96c5a4aac08fa6c0d5fedb1383679c79ef6a7f6e653884
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.14

Release files / centrex_tlf-0.2.7-cp312-cp312-macosx_11_0_arm64.whl

Download URL centrex_tlf-0.2.7-cp312-cp312-macosx_11_0_arm64.whl
Size 897.8 kB
Tags CPython 3.12 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
c99a8f400004ee02b8c9b13bade3e623fef010381c81262ecef25d79cf95ee94
BLAKE2b-256 checksum
How to use checksums
16cb2fae9d0db9ef0b0b7b312967fd8e2ed3ceb76fd87c1ad072c5444c25a778
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.14

Release files / centrex_tlf-0.2.7-cp311-cp311-win_amd64.whl

Download URL centrex_tlf-0.2.7-cp311-cp311-win_amd64.whl
Size 895.4 kB
Tags CPython 3.11 Windows x86-64
SHA-256 checksum
How to use checksums
f61dbab8a452666cd0ad23ed3c4721527943a2342a38f195f066fdb9d6916c4d
BLAKE2b-256 checksum
How to use checksums
cbf9c52bb019d0f79082523d514b83ab84050d02ae2d53c3431c029f8e6a1501
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.14

Release files / centrex_tlf-0.2.7-cp311-cp311-manylinux_2_28_x86_64.whl

Download URL centrex_tlf-0.2.7-cp311-cp311-manylinux_2_28_x86_64.whl
Size 984.4 kB
Tags CPython 3.11 Linux glibc 2.28+ x86-64
SHA-256 checksum
How to use checksums
cf1b85c09b682e59006d12057a21c71e8f6a50be9fe2112768d8bb7a4356c820
BLAKE2b-256 checksum
How to use checksums
2d449c98917f5482c975bbb06e67ab24ba6946c9d31919e428a3edb088ded9fb
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.14

Release files / centrex_tlf-0.2.7-cp311-cp311-macosx_11_0_arm64.whl

Download URL centrex_tlf-0.2.7-cp311-cp311-macosx_11_0_arm64.whl
Size 899.4 kB
Tags CPython 3.11 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
37f4a7ffb2cd03b3254cbafcb509323b71a2e87802e8d8a0d159b989e2d6668b
BLAKE2b-256 checksum
How to use checksums
7f5646e36c40d346f3c70e48402e3562692764f35c851d2dfed870ee477e42ba
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.14

Release files / centrex_tlf-0.2.7-cp310-cp310-win_amd64.whl

Download URL centrex_tlf-0.2.7-cp310-cp310-win_amd64.whl
Size 895.8 kB
Tags CPython 3.10 Windows x86-64
SHA-256 checksum
How to use checksums
9b60c586af35b9c7cb936d2a340c56abb7e1b6b2d8d0046899b81aa7a7723d57
BLAKE2b-256 checksum
How to use checksums
836ce929c79c4aa8bbba530d66c52801258979ea7828ffff1296d0a8b3629eaf
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.14

Release files / centrex_tlf-0.2.7-cp310-cp310-manylinux_2_28_x86_64.whl

Download URL centrex_tlf-0.2.7-cp310-cp310-manylinux_2_28_x86_64.whl
Size 984.5 kB
Tags CPython 3.10 Linux glibc 2.28+ x86-64
SHA-256 checksum
How to use checksums
983d3e538d7379cb16940253c93b9c5764ccca44eb6ad2f987f09a5acf7e436c
BLAKE2b-256 checksum
How to use checksums
41750aa7f3af4107252f852b42405be4923aa781efee66886067306088aa6973
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.14

Release files / centrex_tlf-0.2.7-cp310-cp310-macosx_11_0_arm64.whl

Download URL centrex_tlf-0.2.7-cp310-cp310-macosx_11_0_arm64.whl
Size 899.6 kB
Tags CPython 3.10 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
20de8ff299e2b3f5e3da7c0a0344115d65e6b994557014b99122846a35a731ab
BLAKE2b-256 checksum
How to use checksums
c98ad11db5f98d7b8b85dbcb95330aea7e04cd12a5eaad6928c0bbcf5797bc25
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.14
Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page