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.4-cp313-cp313-win_amd64.whl (328.9 kB view details)

Uploaded CPython 3.13Windows x86-64

centrex_tlf-0.1.8.4-cp313-cp313-manylinux_2_28_x86_64.whl (485.0 kB view details)

Uploaded CPython 3.13manylinux: glibc 2.28+ x86-64

centrex_tlf-0.1.8.4-cp313-cp313-macosx_11_0_arm64.whl (436.7 kB view details)

Uploaded CPython 3.13macOS 11.0+ ARM64

centrex_tlf-0.1.8.4-cp312-cp312-win_amd64.whl (329.4 kB view details)

Uploaded CPython 3.12Windows x86-64

centrex_tlf-0.1.8.4-cp312-cp312-manylinux_2_28_x86_64.whl (485.4 kB view details)

Uploaded CPython 3.12manylinux: glibc 2.28+ x86-64

centrex_tlf-0.1.8.4-cp312-cp312-macosx_11_0_arm64.whl (436.8 kB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

centrex_tlf-0.1.8.4-cp311-cp311-win_amd64.whl (332.2 kB view details)

Uploaded CPython 3.11Windows x86-64

centrex_tlf-0.1.8.4-cp311-cp311-manylinux_2_28_x86_64.whl (489.4 kB view details)

Uploaded CPython 3.11manylinux: glibc 2.28+ x86-64

centrex_tlf-0.1.8.4-cp311-cp311-macosx_11_0_arm64.whl (442.8 kB view details)

Uploaded CPython 3.11macOS 11.0+ ARM64

centrex_tlf-0.1.8.4-cp310-cp310-win_amd64.whl (332.2 kB view details)

Uploaded CPython 3.10Windows x86-64

centrex_tlf-0.1.8.4-cp310-cp310-manylinux_2_28_x86_64.whl (489.6 kB view details)

Uploaded CPython 3.10manylinux: glibc 2.28+ x86-64

centrex_tlf-0.1.8.4-cp310-cp310-macosx_11_0_arm64.whl (442.8 kB view details)

Uploaded CPython 3.10macOS 11.0+ ARM64

File details

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

File metadata

File hashes

Hashes for centrex_tlf-0.1.8.4-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 48f10e9c1dbaf060677700719e169927a32312ba1280ca7de5ab1b6999f3eeee
MD5 229162575f6e67b1db9279d52a1f05c3
BLAKE2b-256 6af9ba83f44bd824cdc279522ca9278b0300b0588d0358eb080847452ef3829c

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for centrex_tlf-0.1.8.4-cp313-cp313-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 97f52601194a97c4400fd248e081835163db056cdd963e0d0c0869f7204db5d8
MD5 dcf58d0bd1b9277cfe1652c054a3c707
BLAKE2b-256 b7dee7721d1f768645db1112698f70b325b2f99ebc4de8022057a7f4c8f4529d

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for centrex_tlf-0.1.8.4-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 77208689d4e538ac730717d60af4fab2f0ad0793613acd1273af3da5efe0d5ab
MD5 441ee4a96e910a0491fd715921663b4b
BLAKE2b-256 10beb4fab2a51c8125875670065b31dbb086d431e6918096a8d26f4dd583b4e3

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for centrex_tlf-0.1.8.4-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 66577ca915e00559489556ebff4eb36053c0f6b43d53cb5848b4d1602b9eb365
MD5 c1d4e2e8aa11c9b5dd5ad9e4dfc377e5
BLAKE2b-256 c745658551581365e124137e734fd71dd686a756da5af02399154f8f7664292a

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for centrex_tlf-0.1.8.4-cp312-cp312-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 b6e6c05aca1dc14909decf3d7788f5b5801989508c0b4131e5c24bd9ad1b1e68
MD5 9eab5557a00faa92becdc22039eda45a
BLAKE2b-256 53f44fb9fb7f92158a5286d35ec457b57db4d03bbe235304a4d88cf00724bc8e

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for centrex_tlf-0.1.8.4-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 6202308808ad87fa303321ba636acd1e58e4b1b5fd738f4bf883a80cb756207a
MD5 9e3a89a0a30bf91d2ca5760259d1eb21
BLAKE2b-256 c24e31aa2d15e4f5bcff4232253d009eaa3fb8aace490dc478e088764ac4feae

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for centrex_tlf-0.1.8.4-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 ee0c0937284c19859091f7819a967ebca68d19eb5e445a2980b22647c58eed59
MD5 f8abe50acea75a479ab61170c741f2b8
BLAKE2b-256 f9497881c3df962475eff898e8b2b94f1811507ca2a558b97852e5b697eadc6d

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for centrex_tlf-0.1.8.4-cp311-cp311-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 285b1860e8f175475986fe9eb024f793325f51d39973518eea4343e8b242faa9
MD5 1d98ed5e830da7267828797a9f3d243a
BLAKE2b-256 2129bb2f60c350f321df28ae8916ff77805a09faa578c47d0a3ab49d84ef4ac2

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for centrex_tlf-0.1.8.4-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 9a571eb827a717dacc9a91c1f4415a59da31a7aac4a66adde6e37ddc9ffe6835
MD5 11f3365c5c4d906f590924f29911a69b
BLAKE2b-256 598928ffee08f17c9e4becfdb1ac997fb86b5e56e313341913631ad7623313d1

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for centrex_tlf-0.1.8.4-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 f8435c4b3c32c5dbe349c60ef616d9a3a4d0db08e71b72a68e8d571f925ee602
MD5 2b4ea3f4849ec43974766fe96b8ae335
BLAKE2b-256 905cbf69e27113124c2b47dc21592f890f06c72cfbb226c9fd4c292f44f1547f

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for centrex_tlf-0.1.8.4-cp310-cp310-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 0936ba09e0e40cbb0f94eee041f756ac36794a1af4f77498f4b894b51df676e1
MD5 961f0d98585d065f44c6c6889236fa2b
BLAKE2b-256 f239397f44f563a21cdc52f7def4bb314d5ddc3fb0b5d6a1c4387c21cbe64217

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for centrex_tlf-0.1.8.4-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 02e66a9585a1bb74b53a59be58d588c339f1a3360983f35de1e7f69b9e97518c
MD5 c9548a2d0a983567a753efbcbf0d1a6b
BLAKE2b-256 d0d22c819f7e5a43a11b5a086ae0257dcfcff2fa875b3b9b3e0361744bf6e4e3

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