DANF
Differential Algebra Normal Forms for symplectic maps, built on DACEyPy.
Computes amplitude-dependent tune shifts (detuning), chromaticity, and the complex-basis normal form of nonlinear symplectic maps via order-by-order elimination in the complex eigenvector basis.
Installation
pip install danf
Quick start
import numpy as np
from daceypy import DA
from danf import NormalForm
from danf.elements import rotation, thin_sext, compose
# Initialize DA engine: order 7, 2 variables (x, px)
DA.init(7, 2)
# Build a one-turn map: rotation (tune 0.31) + sextupole kick (k2L = 1.0)
one_turn = compose(rotation(0.31), thin_sext(1.0))
nf = NormalForm(one_turn)
nf.compute()
print(f"Tune: {nf.tunes[0]:.6f}")
print(f"dnu/dJ: {nf.detuning['dnux_dJx']:.8f}")
API
NormalForm(da_map)
The central class. Accepts a 2-, 4-, or 6-component DA map (1-, 2-, or 3-DOF).
nf.compute()— run the full computation.nf.tunes— linear tunes, one per DOF.nf.detuning— amplitude-dependent tune-shift dict.- 1-DOF keys:
dnux_dJx,alpha_xx,c21. - 2-DOF keys:
dnux_dJx,dnux_dJy,dnuy_dJx,dnuy_dJy, plus the complex order-3 coefficientsc21_xx,c21_xy,c21_yx,c21_yy.
- 1-DOF keys:
nf.nf_map— the post-transformation Floquet normal-form map (real-coord DA).nf.to_complex_basis(plane=0)—{(k, l): complex}forz = (x - i*px)/√2.nf.driving_terms(plane=0, tol=1e-12)— non-Birkhoff (k - l ≠ 1) coefficients only; empty to tolerance away from resonance.
chromaticity_1d(da_map)
Linear and higher-order chromaticity from a 1-DOF map built with one or more
passive parameters (e.g. δ as the third DA variable via DA.init(N, 3)).
from daceypy import DA
from danf import chromaticity_1d
DA.init(5, 3) # 1 DOF + δ as DA(3)
x, px, delta = DA(1), DA(2), DA(3)
mu = 2*np.pi*(0.28 + 1.5*delta - 3.0*delta*delta)
xr = x*mu.cos() + px*mu.sin()
axr = -x*mu.sin() + px*mu.cos()
chrom = chromaticity_1d([xr, axr - 0.5*xr*xr])
print(chrom.tune) # 0.28
print(chrom.dnu_ddelta()) # 1.5
print(chrom.d2nu_ddelta2()) # -6.0
danf.elements
DA-map convenience functions: rotation, thin_quad, thin_sext, thin_oct,
drift, compose.
compute_detuning_1d(da_x, da_px, tune)
Low-level 1-D normal-form primitive; returns (dnu_dJ, c21, nf_x, nf_px). Use
NormalForm for the standard path.
Cross-validation
DANF's numerical output is regression-tested against COSY INFINITY v10.2
(DANF and TS commands) to 10–12 significant figures on:
| Quantity | Agreement |
|---|---|
| Linear tune, 1-DOF | < 1e-14 |
dnu/dJ, 1-DOF sextupole map |
< 1e-10 |
dnu_x/dJ_x, dnu_x/dJ_y, 2-DOF |
< 1e-10 |
dnu/ddelta, d²nu/ddelta² (chrom.) |
< 1e-10 |
Birkhoff c_{2,1} complex coeff |
< 1e-10 |
License
MIT
Metadata
Release files for danf 0.5.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| danf-0.5.0.tar.gz | 25.6 kB | Without provenance | Details for danf-0.5.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| danf-0.5.0-py3-none-any.whl | Python 3 | none | any | Details for danf-0.5.0-py3-none-any.whl |
Total release size: 48.4 kB
Release files / danf-0.5.0.tar.gz
| Download URL | danf-0.5.0.tar.gz |
|---|---|
| Size | 25.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
77c2cb496749c4018b3e9ff882574eff9fa4a866315b5bcca7d25657325347b4
|
|
BLAKE2b-256 checksum How to use checksums |
a9ac831091a96ad3ee7e851e827bef78dfa46572dfcf4b32e6d9638971c18ce2
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.12.12
|
Release files / danf-0.5.0-py3-none-any.whl
| Download URL | danf-0.5.0-py3-none-any.whl |
|---|---|
| Size | 22.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
7a0f4d066648dc369cf3d5f98073af36857cdf2053471302ec09761ff80c5354
|
|
BLAKE2b-256 checksum How to use checksums |
1f57778762b33cacce65ea288c327d238b6e52528c55ae56cf8717ae23b267e4
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.12.12
|
Security for danf 0.5.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.