Skip to main content

No project description provided

Project description

Python versions on PyPI CeNTREX-TlF version on PyPI

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

Uploaded CPython 3.13Windows x86-64

centrex_tlf-0.1.9-cp313-cp313-manylinux_2_28_x86_64.whl (950.6 kB view details)

Uploaded CPython 3.13manylinux: glibc 2.28+ x86-64

centrex_tlf-0.1.9-cp313-cp313-macosx_11_0_arm64.whl (858.9 kB view details)

Uploaded CPython 3.13macOS 11.0+ ARM64

centrex_tlf-0.1.9-cp312-cp312-win_amd64.whl (783.0 kB view details)

Uploaded CPython 3.12Windows x86-64

centrex_tlf-0.1.9-cp312-cp312-manylinux_2_28_x86_64.whl (951.2 kB view details)

Uploaded CPython 3.12manylinux: glibc 2.28+ x86-64

centrex_tlf-0.1.9-cp312-cp312-macosx_11_0_arm64.whl (859.6 kB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

centrex_tlf-0.1.9-cp311-cp311-win_amd64.whl (783.4 kB view details)

Uploaded CPython 3.11Windows x86-64

centrex_tlf-0.1.9-cp311-cp311-manylinux_2_28_x86_64.whl (955.9 kB view details)

Uploaded CPython 3.11manylinux: glibc 2.28+ x86-64

centrex_tlf-0.1.9-cp311-cp311-macosx_11_0_arm64.whl (864.9 kB view details)

Uploaded CPython 3.11macOS 11.0+ ARM64

centrex_tlf-0.1.9-cp310-cp310-win_amd64.whl (787.0 kB view details)

Uploaded CPython 3.10Windows x86-64

centrex_tlf-0.1.9-cp310-cp310-manylinux_2_28_x86_64.whl (955.9 kB view details)

Uploaded CPython 3.10manylinux: glibc 2.28+ x86-64

centrex_tlf-0.1.9-cp310-cp310-macosx_11_0_arm64.whl (862.7 kB view details)

Uploaded CPython 3.10macOS 11.0+ ARM64

File details

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

File metadata

  • Download URL: centrex_tlf-0.1.9-cp313-cp313-win_amd64.whl
  • Upload date:
  • Size: 782.7 kB
  • Tags: CPython 3.13, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for centrex_tlf-0.1.9-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 56d9ab825d1c22a148ad81b123d1c926483c1be01336b62f33493555173cd35a
MD5 06aa40015e608417790de80d26556f4c
BLAKE2b-256 79c1ec10b89529233561dda491be18120f8e9b2413cba5a9ed9a80a3adabe317

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for centrex_tlf-0.1.9-cp313-cp313-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 c26a4abb74da58c8036ec4b8669e7dd6d6bd04c1898e33cf7a6cde6d0387926f
MD5 6c675a348aae2a6541ad17644b84121d
BLAKE2b-256 744a610250cda4f6334641d1c5e5a2f0ef251254e01766e32def075536647fad

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for centrex_tlf-0.1.9-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 3516148338ae953ec9c228f0360326effca86e19870d7770b651396d32ce3e39
MD5 94d0a3b08a878745d64401758211778c
BLAKE2b-256 cc1c1e4d95176f2ccead3dd6c2901cc9fa0dbf770e4d59f8855615202a41b05a

See more details on using hashes here.

File details

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

File metadata

  • Download URL: centrex_tlf-0.1.9-cp312-cp312-win_amd64.whl
  • Upload date:
  • Size: 783.0 kB
  • Tags: CPython 3.12, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for centrex_tlf-0.1.9-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 e41caa9a340e98a28f29b521f2c255807fac71d8e5b26a4014d364bd3ebcd8dd
MD5 a25143d6eefa137fcd3a55eff9b72ab3
BLAKE2b-256 5c9168cc719f7da8379234fd25260a4c53ca884928a6bf1ade859d02603886b3

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for centrex_tlf-0.1.9-cp312-cp312-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 b487453b2f1acb03afab679e1f71a0e99e1895eb890ff6b7792fe9552e5f69bb
MD5 0f7ec65edea99179bade05b1a152d523
BLAKE2b-256 3c090ff71c7bce5867ac7406e4abc199f44ff3949667b7c195359747faaac8f0

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for centrex_tlf-0.1.9-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 491d56a6d4db5a5f7ed668ab6ed6c18a58ea99845d4ae6f570bb54f9d3c592fd
MD5 b1781ec1bb91f0d811c5ff83bb51145d
BLAKE2b-256 4ad004240357c1d614dfd6262bd3bd176df9192fb684be392409a1567f4b6be8

See more details on using hashes here.

File details

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

File metadata

  • Download URL: centrex_tlf-0.1.9-cp311-cp311-win_amd64.whl
  • Upload date:
  • Size: 783.4 kB
  • Tags: CPython 3.11, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for centrex_tlf-0.1.9-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 5df8b52e96b60b1233893e89b177ce9b9b790613e0169fa5c4a7722dec3afdc6
MD5 30cc61a8be4db1c0206ea484b6cf7a9f
BLAKE2b-256 1015ff70bef378b80d3ffbb9a561d72e28e7df94c321a983a3a2665ad409ad09

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for centrex_tlf-0.1.9-cp311-cp311-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 7fc5809082897b551087aecbbd2665b9b7c166ec21aaa457ee4c47d910cddc26
MD5 fb1453ac50efd846feffc10fab31bc41
BLAKE2b-256 968fda86683195aace191d4bb6f914f9121253a120e6de92c84f22aef5e01d85

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for centrex_tlf-0.1.9-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 d6f72bb5c3fa2b5d8204a3da3ecf6651d367a119c3f916b7d8061a36331557a2
MD5 a23ee152e43a704b98725720f635e7a9
BLAKE2b-256 1abc35ab5e4f4bd0306ba2e53833ead798e39b127a2aac6080d45dc5df3bc68c

See more details on using hashes here.

File details

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

File metadata

  • Download URL: centrex_tlf-0.1.9-cp310-cp310-win_amd64.whl
  • Upload date:
  • Size: 787.0 kB
  • Tags: CPython 3.10, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for centrex_tlf-0.1.9-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 b366e3ace6a1350f9a68049749e77a498801dab29feceb7e3eb1863f226d4a82
MD5 f821540839a5df31c580f7001bc1bee9
BLAKE2b-256 efcbb33d89bb336302e590ab9b31ac6db90f1524acd383a3c18a15cfeb8dd33c

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for centrex_tlf-0.1.9-cp310-cp310-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 90a53d629b1cf279a6195e2d1a4881d69ddda6f356ce5dbe0c02a67f1c934161
MD5 cdb13052ba5268c27bbcb4acc68dddea
BLAKE2b-256 ff47b62d003d86e704d4a849ea0352dab9517fa69987787282285b218c9cdd0f

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for centrex_tlf-0.1.9-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 3472cf2a7d110c6699db8cda256acc014d9dda47d7b3219d7f8e215a46175f62
MD5 d1f0849eb56e0998f7d06ee1de23dbe0
BLAKE2b-256 1174bbafb5af1a8381214bb47fb82fc1be7a846257d7633ba97fa5385c66305d

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