Skip to main content

cavsqueeze

Tests PyPI License DOI

Beyond-mean-field simulation of cavity-mediated spin squeezing (one-axis twisting) for solid-state clock-transition ensembles, and of squeezing by measurement of the spin population through the resonator. Developed for 171Yb3+:CaWO4 and applicable to any spin ensemble coupled to a resonator.

cavsqueeze implements

  • the adiabatically eliminated Tavis-Cummings model with collective emission, collective thermal absorption, single-spin dephasing and coupling inhomogeneity (resonator.py);
  • discretization of Gaussian, Lorentzian and Voigt lines into frequency classes with tail resolution (ensemble.py);
  • a class-resolved second-order cumulant expansion in connected variables, whose cost is set by the number of classes rather than by N, so that N = 1e15 is no harder than N = 1e3, and which loses no precision to cancellation at large N because the means are subtracted analytically (cumulant.py), together with the raw-moment form used as a test reference (cumulant_raw.py); the solver can condition the ensemble on a continuous measurement of J_z through the resonator (Rates.meas, Rates.meas_eta);
  • exact references: QuTiP master equation for distinguishable spins and the permutation-invariant Dicke solver PIQS (exact.py);
  • pulse sequences: echo twist, Ramsey, twist-untwist readout, plain squeezed readout (protocols.py);
  • far-detuned spectator spins propagated analytically, which removes the stiffness of heavy-tailed lines (ensemble.tail_resolved_classes, cumulant.evolve);
  • an independent solver for cross-checking: discrete truncated Wigner trajectories (dtwa.py), which truncate the equations of motion rather than the statistics.

Installation

From PyPI:

pip install cavsqueeze          # core solver (numpy, scipy, matplotlib)
pip install cavsqueeze[exact]   # adds QuTiP for the exact reference solvers

Or from source, to run the tests:

git clone https://github.com/TaN-MM-Org/cavsqueeze
cd cavsqueeze
pip install -e .[test]
pytest tests              # validation testbench (about 2 minutes)

The test suite validates the cumulant solver against exact QuTiP and PIQS references, against closed-form limits, and against the independent discrete truncated Wigner solver; it runs in CI on every push and pull request.

Minimal example

import numpy as np
from cavsqueeze import from_hz, homogeneous
from cavsqueeze.protocols import optimal_squeezing
N = 1e10
p = from_hz(g_hz=1e6/np.sqrt(N), kappa_hz=1e4, Delta_hz=30e6, T=0.02, T2=0.15)
best = optimal_squeezing(p, homogeneous(N), 1e-6, 1e-2)
print(10*np.log10(best["xi2"]), "dB at", best["t"], "s")

Metrology projections

The metrology module turns the solver's collective moments into the quantities an experiment is designed against, for any platform the solver can describe: Kitagawa-Ueda and Wineland squeezing parameters, single-shot phase sensitivity, the projection-noise-limited Allan deviation of a Ramsey clock, and the field sensitivity of a Ramsey magnetometer.

from cavsqueeze import (squeezing_parameters, clock_allan_deviation,
                        metrological_gain_db)
m = squeezing_parameters(state, ens.n)          # xi2_S, xi2_R, contrast, dphi
print(metrological_gain_db(m["xi2_R"]), "dB over the SQL")
print(clock_allan_deviation(m["dphi"], nu0=4.29e14, T_ramsey=0.1, tau=1.0))

The formulas are the standard ones (Kitagawa-Ueda 1993; Wineland 1992; Itano 1993; Ludlow RMP 2015) and are tested against the solver's own exact references and closed-form limits. oat_closed_form (v1.10) provides the exact unitary Kitagawa-Ueda one-axis-twisting moments -- mean spin, extremal transverse variances, optimal angle and both squeezing parameters -- as the decoherence-free benchmark the dissipative solver is compared against; every returned quantity is asserted against brute-force exact evolution in the tests. The pulse-sequence layer (css_x, twist, twist_untwist, optimal_squeezing, plain_squeezed_readout, ...) is exported at the package root as of v1.10.

Into the bosonic quantum stack

The interop module extracts the Holstein-Primakoff mode of the collective spin from any solver state: the 2x2 Gaussian quadrature covariance (a coherent spin state maps to the vacuum), its symplectic eigenvalue, squeezing parameter, angle, thermal occupation and purity, and an export to a QuTiP density matrix that reproduces that covariance. The export verifies itself against the target covariance so Fock truncation can never silently corrupt it, and the QuTiP squeeze-phase convention is locked by a test rather than assumed.

from cavsqueeze import bosonic_mode, to_qutip
mode = bosonic_mode(state, ens.n)     # Sigma, nu, r, theta, n_th, purity
rho, mode = to_qutip(state, ens.n)    # QuTiP density matrix of the mode

Associated paper

The physics, the conventions and the validation of this package are described in: T. M. Mahim, M. M. Rahman, A. S. M. Mohsin, Synchronization sets the coherence and the squeezing limit of a spin ensemble in a cavity. The paper's companion repository, yb-cawo4-cavity-squeezing, contains the scripts, datasets and figures that reproduce the paper and is archived on Zenodo; this repository is the software's home for development, releases and support.

Contributing and support

Bug reports, questions and pull requests are welcome through GitHub issues; see CONTRIBUTING.md for the development setup and the testing requirements. Tagged releases are published to PyPI by CI.

License

Apache-2.0 (see LICENSE). Please cite the paper if you use this code; citation metadata is in CITATION.cff.

Download files

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

Source Distribution

cavsqueeze-1.10.0.tar.gz (45.7 kB view details)

Uploaded Source

Built Distribution

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

cavsqueeze-1.10.0-py3-none-any.whl (39.9 kB view details)

Uploaded Python 3

File details

Details for the file cavsqueeze-1.10.0.tar.gz.

File metadata

  • Download URL: cavsqueeze-1.10.0.tar.gz
  • Upload date:
  • Size: 45.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for cavsqueeze-1.10.0.tar.gz
Algorithm Hash digest
SHA256 3a177ad8bab97cfe078fdee73b7ab5155d177afc4b1d4affbe349c4815b5a8e9
MD5 4f251533eddd34bafc7915f3f12102c5
BLAKE2b-256 11868b5a866e53f5fc2ad29ecc3f002e46f520715acf61c5e90c252703c523c0

See more details on using hashes here.

Provenance

The following attestation bundles were made for cavsqueeze-1.10.0.tar.gz:

Publisher: publish.yml on TaN-MM-Org/cavsqueeze

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file cavsqueeze-1.10.0-py3-none-any.whl.

File metadata

  • Download URL: cavsqueeze-1.10.0-py3-none-any.whl
  • Upload date:
  • Size: 39.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for cavsqueeze-1.10.0-py3-none-any.whl
Algorithm Hash digest
SHA256 d4cb32e3b44dbce8980cb6a8e170f6f9b2b346019d3ddb70d2b3aa4a7eed3384
MD5 aad99c447bb35eac0d36247fd9fa6f73
BLAKE2b-256 35d90540f8fc80cd9e44fa82a9da83a89dbb0b9e04933818384082c3716871ea

See more details on using hashes here.

Provenance

The following attestation bundles were made for cavsqueeze-1.10.0-py3-none-any.whl:

Publisher: publish.yml on TaN-MM-Org/cavsqueeze

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Release history Release notifications | RSS feed

This release

1.10.0 This release

2 files

1.9.0

2 files

1.8.0

2 files

1.7.0

2 files

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