Skip to main content

spinoct

Optimal control paths and energy-efficient switching pulses for classical spin dynamics (Landau-Lifshitz-Gilbert).

spinoct computes the control (an applied magnetic field, an electric current, or both) that drives a magnetic moment from one state to another in a given time for the least dissipated energy. It is the reusable engine behind Espira, and it is deliberately independent of any material database, so it works on any spin Hamiltonian.

Why this exists

The optimal control of magnetization switching has a small, rigorous literature (Kwiatkowski, Badarneh, Berkov and Bessarab, Phys. Rev. Lett. 126, 177206 (2021), and the papers that follow it), but no open implementation. The analytic solutions live only as equations in journal articles, and the group's own code is not public. spinoct is that implementation, with the closed-form results built in as positive controls that every numerical solver is validated against before it is trusted.

Install

pip install spinoct              # core: numpy + scipy
pip install "spinoct[torch]"     # add the batched GPU solvers

The dimensional contract

Read spinoct.units first. The same physical quantity is written four different ways across this literature, and the central quantity of the package, the switching cost Phi = int |b|^2 dt, is in tesla-squared-seconds, not joules. It becomes an energy only through an explicit circuit model. The package refuses to hide that assumption: spinoct.units.CircuitModel is a required, described object, never a buried constant.

Status

Pre-1.0, under active development. The analytic uniaxial optimal control path, its closed-form pulse and cost, and the negative-parameter Jacobi elliptic machinery it needs are complete and validated, as are the numerical image-based solver and the constrained solvers. GRAPE, CRAB and the field-plus-current hybrid are driven by the exact adjoint gradient through their linear control bases, and each answer is required to be a real reversal before its cost is reported; see docs/theory/13-constrained-control-and-the-price-of-realizability.md for what they measure and for the two defects that shipped before they did. The batched lane (spinoct[torch]) solves many independent optimal control problems as one tensor, on a GPU when one is present, and is accepted against the CPU lane problem by problem; docs/theory/14-the-batched-lane.md has what it is for, what it is not for, and where the crossover actually is.

License

MIT. See LICENSE.

Release files for spinoct 0.19.1

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

Source distribution (sdist)

Source distribution for spinoct 0.19.1
File Size Uploaded
spinoct-0.19.1.tar.gz 113.9 kB Details

Built distribution (wheel)

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

Total release size: 215.0 kB

Release files / spinoct-0.19.1.tar.gz

Download URL spinoct-0.19.1.tar.gz
Size 113.9 kB
Tags Source
SHA-256 checksum
How to use checksums
bc2a7cfc77222816087c62018e98a6a52097bc93a9e24915a0487a3187805d04
BLAKE2b-256 checksum
How to use checksums
46ef3777fde13c5b5086566c6e8d6d6d629a9b9ff22473902b6ce35b15e7762a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 24, 2026.

Transparency log

Release files / spinoct-0.19.1-py3-none-any.whl

Download URL spinoct-0.19.1-py3-none-any.whl
Size 101.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
75b0e6d6e50b4e60f58c208f6ae6ae233a5307400ae691ca52f8d26b08e13623
BLAKE2b-256 checksum
How to use checksums
eed241cc41ffbb7b46ea07c628c1ccfd93f5664b81e4059aa5172f676d3ee3c9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 24, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

0.19.1 This release

2 release files

0.19.0

2 release files

0.18.0

2 release files

0.17.0

2 release files

0.16.0

2 release files

0.15.0

2 release files

0.14.0

2 release files

0.13.0

2 release files

0.12.0

2 release files

0.11.0

2 release files

0.10.0

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