Skip to main content

bloch4spin — Generalized Bloch toolkit for spin-j systems

bloch4spin is a small NumPy/SciPy/SymPy toolkit for finite spin systems using the generalized Bloch (COBITO) representation. It supports operator conversion, Hamiltonian and Lindblad evolution, Kraus/POVM/projective measurements, and sequential joint probabilities.

Requirements

  • Python 3.10 or newer
  • NumPy 1.24 or newer
  • SciPy 1.11 or newer
  • SymPy 1.10 or newer

Installation

Install from a local checkout:

python -m pip install .

Quick start

import numpy as np
from bloch4spin import (
    BlochBasis,
    GeneralizedBlochEvolutionMatrix,
    GeneralizedBlochObservable,
    GeneralizedBlochState,
    run,
)

# Use one explicit basis throughout the calculation.
basis = BlochBasis(2)

# Spin-1/2 Hamiltonian H = J_y and its Bloch-space generator.
H = np.array([[0, -0.5j], [0.5j, 0]])
L = GeneralizedBlochEvolutionMatrix.from_Hamiltonian(H, basis=basis)

# Maximally mixed initial state.
state = GeneralizedBlochState.from_matrix(np.eye(2) / 2, basis=basis)

# Projective J_z measurements.
projectors = [np.diag([1, 0]), np.diag([0, 1])]
observables = [
    GeneralizedBlochObservable.from_projector(P, basis=basis)
    for P in projectors
]

# joint[i, j]: probability of outcome i at t=0.7 and outcome j at t=1.9.
joint = run(L, state, [(0.7, observables), (1.9, observables)])
print(joint)

A BlochBasis owns its dimension and caches, so independent dimensions can coexist. Initialization constructs the COBITO basis; tensor-product coefficients are computed only when needed. Code that performs many tensor products can call basis.precompute_products() once.

Pass the same explicit basis to every state, evolution matrix, and measurement in a calculation. Objects from different basis instances are not mixed implicitly.

Measurement normalization

  • normalized: check for a complete, trace-preserving measurement;
  • renormalized: normalize the retained outcome probabilities, as in explicit postselection;
  • unnormalized: return raw outcome probabilities.

Further reading

Licensed under the MIT License.

Metadata

Release files for bloch4spin 0.2.0

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

Source distribution (sdist)

Source distribution for bloch4spin 0.2.0
File Size Uploaded Provenance Actions
bloch4spin-0.2.0.tar.gz 15.2 kB Without provenance Details for bloch4spin-0.2.0.tar.gz

Built distribution (wheel)

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

Total release size: 29.9 kB

Release files / bloch4spin-0.2.0.tar.gz

Download URL bloch4spin-0.2.0.tar.gz
Size 15.2 kB
Tags Source
SHA-256 checksum
How to use checksums
c7e245286334deba5df3bf1e4483e941f89877e985f33e587cac79f2bf20c050
BLAKE2b-256 checksum
How to use checksums
32e852b94d2fcf74e677986cdf79b47053c422bc60b6dd5a43b251fda3686713
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.2

Release files / bloch4spin-0.2.0-py3-none-any.whl

Download URL bloch4spin-0.2.0-py3-none-any.whl
Size 14.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
709d99e5ffce56abe04e6326f727db94d55cb1a7bc7eb37753dea63d594b71d7
BLAKE2b-256 checksum
How to use checksums
b8dafafc5a7cfd63df487babd6bed66e83638ea0b6f00aeaa2cb007a9ac2458c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.2

Security for bloch4spin 0.2.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.2.0 This release

2 release files No provenance

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