Skip to main content

Spylind

Spylind is a Python library for symbolically defining and solving ensembles of quantum systems described by the Lindblad master equation, with a particular focus on rare-earth ion ensembles in solids.

It also includes spyIVP, a utility to bridge multi-dimensional SymPy expressions with numerical initial-value problem (ODE) solvers. This was designed for use in interactive simulation scripts and Jupyter notebooks.

Note: Spylind is research software. APIs and documentation are continuing to evolve.

Core Components

  • spylind.spylind: Formulates symbolic equations of motion for density matrix elements from a given Hamiltonian and collapse operators (with support for QuTiP Qobj operators).
  • spylind.spyIVP: Translates multi-dimensional SymPy differential equations into numerical ODE solver models, handling parameter distributions, driving functions, and ensemble dimensions.

Solvers & Backends

  • CyRK: Runge-Kutta ODE solving via Cython and compiled Numba C-callbacks (CyRK.nbsolve2_ivp), with automatic fallback to pysolve_ivp.
  • Diffrax (JAX): ODE integration with JAX-based JIT compilation.
  • NumPy / SciPy: Standard CPU integration using scipy.integrate.

Installation

Install in development mode:

pip install -e .

To install optional backends:

# CyRK backend
pip install -e .[cyrk]

# Diffrax (JAX) backend
pip install -e .[jax]

# Both backends
pip install -e ".[cyrk,jax]"

Quick Examples

1. Quantum Master Equation (spylind.spylind)

from spylind import spylind as spl
import qutip as q
import numpy as np
import sympy as sm

# Define a 2-level system symbolically
H = [0.1 * np.pi * q.sigmaz(), [sm.symbols('Omega') / 2, q.sigmax()]]
tlist = np.linspace(0, 1.0, 101)

# Solve using CyRK, Diffrax, or NumPy
res = spl.mesolve(
    H,
    q.basis(2, 0),
    tlist,
    t_dep_fL={'Omega': lambda t: 2 * np.pi},
    e_ops=[q.sigmaz()],
    backend='cyrk'  # or 'diffrax', 'numpy'
)

2. General ODE Systems & Ensembles (spylind.spyIVP)

import numpy as np
import sympy as sm
from spylind import spyIVP as so

# Define symbolic variables
x, v = sm.symbols("x, v", real=True)
omega = sm.symbols("omega", real=True)      # Ensemble parameter (e.g. distributed frequencies)
gamma = sm.symbols("gamma", real=True)      # Damping parameter

# Symbolic equations of motion
eqs = {
    x: v,
    v: -(omega**2) * x - gamma * v
}

# Define an ensemble over a parameter distribution
omega_vals = np.linspace(0.8, 1.2, 50)
ode_sys = so.ODESys(
    eqs,
    trans_dims={omega: omega_vals},
    parameters={gamma: 0.1}
)
ode_sys.set_initial_state({x: 1.0, v: 0.0})

# Setup solver model ('cyrk', 'diffrax', or 'numpy')
model = ode_sys.setup_model(backend='cyrk')

# Integrate: returns array of shape (n_times, n_variables, n_ensemble)
t_steps = np.linspace(0, 20.0, 200)
res = model.integrate(t_steps)

License

BSD 3-Clause License.

Release files for spylind 0.23

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

Source distribution (sdist)

Source distribution for spylind 0.23
File Size Uploaded
spylind-0.23.tar.gz 61.1 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for spylind 0.23
File Interpreter ABI Platform
spylind-0.23-py3-none-any.whl Python 3 none any Details

Total release size: 100.7 kB

Release files / spylind-0.23.tar.gz

Download URL spylind-0.23.tar.gz
Size 61.1 kB
Tags Source
SHA-256 checksum
How to use checksums
4e93f320761d6c78d2429632ce5e0066d7ba34eaab24699fc067ce8a88d298d8
BLAKE2b-256 checksum
How to use checksums
c99568409001a5ce38a1021f9c7e9235988cf9a6d9f9d0f40a28087d17b99e71
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.14.0

Release files / spylind-0.23-py3-none-any.whl

Download URL spylind-0.23-py3-none-any.whl
Size 39.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
5a1b888e278e9251356d9981f64682b909099849c6e6715be61d0c6912ba7e70
BLAKE2b-256 checksum
How to use checksums
aef07919bbed69c38ec3cb53dd0ebd3565aca632172510292469d87cfd8e7aa4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.14.0

Release history Release notifications | RSS feed

0.221

2 release files

This release

0.23 This release

2 release files

0.22

2 release files

0.21

2 release 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