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.

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
)

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

Uploaded CPython 3.13Windows x86-64

centrex_tlf-0.2.0-cp313-cp313-manylinux_2_28_x86_64.whl (1.0 MB view details)

Uploaded CPython 3.13manylinux: glibc 2.28+ x86-64

centrex_tlf-0.2.0-cp313-cp313-macosx_11_0_arm64.whl (911.3 kB view details)

Uploaded CPython 3.13macOS 11.0+ ARM64

centrex_tlf-0.2.0-cp312-cp312-win_amd64.whl (839.8 kB view details)

Uploaded CPython 3.12Windows x86-64

centrex_tlf-0.2.0-cp312-cp312-manylinux_2_28_x86_64.whl (1.0 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.28+ x86-64

centrex_tlf-0.2.0-cp312-cp312-macosx_11_0_arm64.whl (911.9 kB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

centrex_tlf-0.2.0-cp311-cp311-win_amd64.whl (843.9 kB view details)

Uploaded CPython 3.11Windows x86-64

centrex_tlf-0.2.0-cp311-cp311-manylinux_2_28_x86_64.whl (1.0 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.28+ x86-64

centrex_tlf-0.2.0-cp311-cp311-macosx_11_0_arm64.whl (917.2 kB view details)

Uploaded CPython 3.11macOS 11.0+ ARM64

centrex_tlf-0.2.0-cp310-cp310-win_amd64.whl (843.5 kB view details)

Uploaded CPython 3.10Windows x86-64

centrex_tlf-0.2.0-cp310-cp310-manylinux_2_28_x86_64.whl (1.0 MB view details)

Uploaded CPython 3.10manylinux: glibc 2.28+ x86-64

centrex_tlf-0.2.0-cp310-cp310-macosx_11_0_arm64.whl (917.4 kB view details)

Uploaded CPython 3.10macOS 11.0+ ARM64

File details

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

File metadata

File hashes

Hashes for centrex_tlf-0.2.0-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 6531ed861d5732290b3aa111937b4a7f2b5a3974d4761c2a5a4ae5bd9bc65d34
MD5 5feb558ae5d1f9facefe5627c212935c
BLAKE2b-256 bca99d2efb8a70cdfc311d83322bb28ca6aea5a837db6c1288e1d52b296c0726

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for centrex_tlf-0.2.0-cp313-cp313-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 cbcf80ca7a26055330e415c66b11b93f5d2e0f49b1593b02ae71fac21b343ad5
MD5 fc8acf3f5ad059612f1d7d9c3119b97d
BLAKE2b-256 8381b18c0acbdf02cc82c4f2abbf1e5cea462dc57fbc5871e0bc112a52e1df10

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for centrex_tlf-0.2.0-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 97a07bf9c0d68a1ef891fa10073deb40a748e61629054e6d7635bda30dcc1a22
MD5 180744b3f91089047f045cffcdfcc09e
BLAKE2b-256 73e0c4726b52616b2c6e017f850e30fa71670dee5f5a6f638cfd3fdb9a34fd30

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for centrex_tlf-0.2.0-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 5a3f4a911b8d8e912c8dfc084185e5a3c2cf5a89c3c06d0f496ae85654372bf8
MD5 a1cca830d8a9623803da1e2b758a2a75
BLAKE2b-256 8e3a9b2c3e508aa3a0d634a4db732f9547baad5fa6e0c69c65fa14fb420a8d7d

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for centrex_tlf-0.2.0-cp312-cp312-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 22b1ddc957fc8775802792bc76e3526305b21490e7478234d150639ec0a43738
MD5 7632458e0a73c81020ae70df69405fe7
BLAKE2b-256 9683347d7ec45f3236754ccf9cb253e0cb41af7788f4f2f3f15dae6eacd8139a

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for centrex_tlf-0.2.0-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 30770829309ba27952e4267e8695deaf2a6e5abd0870b9c3be353976bef96dbc
MD5 96b06970e33f1bcf40af84ad6cf73006
BLAKE2b-256 94d28222e8979fda52bd6fcc9dc5af7a06d8b4c500c4502dc956b18bda524887

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for centrex_tlf-0.2.0-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 fd957b07fb23db991d246aadaee66d74bd64d94d71139f7ac87532afc2a98dc1
MD5 a061aee0f51c967a2e8aac3dde164ad6
BLAKE2b-256 50c437606ad2c4ab98f15644750a8e1581d6ae8d57fc79bafbd9aeb52e28683c

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for centrex_tlf-0.2.0-cp311-cp311-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 d426b009bce0e14b9eb9c47c022a8ca0ee071a0785f28dbc6d9204eb592f3f5f
MD5 d8a16272d698bd7c0fad435a616f6ac8
BLAKE2b-256 3949a279329872d20a6c80bd05c563ca413729f6dc4a0fb9c8c4aa9b584d5914

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for centrex_tlf-0.2.0-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 9ca78c4a223026e103fc4672a5aa9598e2cac4b5423587dc858846fd7d37a25c
MD5 2656cfb4a7608eb19c85c1ec68ce6b54
BLAKE2b-256 7ed1683c851a6b0e157bbbadc8f5ff85902e3c0708d6485be0f5e166cb10059a

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for centrex_tlf-0.2.0-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 21e185ba8e92fc6296408f90d0f9f41cba03cd9bf8f607d464304dc85b18fe8e
MD5 f7b606ccbb165cc71b5dc47d1c153891
BLAKE2b-256 941975c5471b067fc9fe864c8f1219f598f56075a9cd55c652f60323c21c9f3b

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for centrex_tlf-0.2.0-cp310-cp310-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 7d54a310a588ac870a9dd48fc7f42cb3d2fbc3a8c905d01cc6283337687ba779
MD5 ae189adda6ccee9cea1f3400af10fd2d
BLAKE2b-256 0ff6e5b7fd872e2af4b07d958949f89b18bfc4c8100a5ff04e12f13812a3f159

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for centrex_tlf-0.2.0-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 d886b2f0e99e275ae2f8b1a0d08509ab5011449f001429b79dda5df79ead3a7e
MD5 73d22b7981b52ad41526f98b6df1877f
BLAKE2b-256 b9e692573fa31f31ad997fbf8eb9fd984161d9046ae03158d6d752d429f7457b

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