DA-based FFAG accelerator tracking using differential algebra
Project description
pyffag
DA-based FFAG accelerator tracking using differential algebra.
Built on daceypy for arbitrary-order transfer map computation through FFAG sector magnets via integration of the exact midplane Hamiltonian.
Installation
pip install pyffag
Quick start
import numpy as np
from daceypy import DA
from pyffag import sector_map, compose_sequence, compose_n, tune, twiss
from pyffag.constants import kinetic_to_brho, M_PROTON
# 150 MeV proton FFAG ring: 12 FDF-triplet cells
DA.init(7, 2) # DA order 7, 2 variables (x, px)
Brho = kinetic_to_brho(150.0, M_PROTON) # magnetic rigidity [T·m]
# F magnet: B(x) = 1.2 + 3.0*x + 4.0*x² [T], 12° sector
F = sector_map([1.2, 3.0, 4.0], Brho, angle=np.radians(12.0))
# D magnet: B(x) = 1.2 − 5.0*x − 5.0*x² [T], 6° sector
D = sector_map([1.2, -5.0, -5.0], Brho, angle=np.radians(6.0))
# One cell = F + D + F, full ring = 12 cells
cell = compose_sequence([F, D, F])
ring = compose_n(cell, 12)
print(f"Cell tune: {twiss(cell)['tune']:.4f}")
print(f"Ring tune: {tune(ring):.4f}")
Features
- Sector magnet tracking: Exact midplane Hamiltonian integration (no paraxial approximation) through sector magnets with polynomial field profiles B(x) = B₀ + B₁x + B₂x² + ...
- Element maps: Drift (exact), thin quadrupole, sextupole, octupole, edge kicks for rectangular magnets
- Ring operations: Map composition, N-fold composition, closed orbit finding via Newton's method with DA Jacobian
- Optics: Tune, Twiss parameters, stability check, symplecticity error
Physics
The core sector_map() integrates the equations of motion in Frenet-Serret
(curvilinear) coordinates with arc length as the independent variable:
dx/ds = (1 + hx) · px / √(1 − px²)
dpx/ds = h · √(1 − px²) − (1 + hx) · By(x) / (Bρ)
where h = 1/ρ is the reference curvature. Sector magnets have radial edge faces (no edge focusing). The exact sqrt formulation captures kinematic nonlinearities that the paraxial approximation misses.
Integration with danf
Use with danf for nonlinear normal form analysis (amplitude-dependent tune shifts, resonance driving terms):
from danf import NormalForm
nf = NormalForm(ring)
nf.compute()
print(f"ADTS: dν/dε = {nf.detuning['dnux_dJx'] / 2:.4f}")
License
MIT
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file pyffag-0.1.0.tar.gz.
File metadata
- Download URL: pyffag-0.1.0.tar.gz
- Upload date:
- Size: 14.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
bfc30cf1df398ca6e7ecef227fd619ea3f40deae71d5c5cb14e2b7ffc3ece955
|
|
| MD5 |
4a457515e4e55f0d2b094d4051e3bc07
|
|
| BLAKE2b-256 |
d8e0d1c2f3595d19f637d383b0a496138613fc23744eeab26670b19a4457ce59
|
File details
Details for the file pyffag-0.1.0-py3-none-any.whl.
File metadata
- Download URL: pyffag-0.1.0-py3-none-any.whl
- Upload date:
- Size: 10.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3bc06b6755cfd1b717263844456f450c8ba2f1421ea4b4c120f70aba4b15f084
|
|
| MD5 |
f0c5de5f20325d9ab629f9544e5d74b8
|
|
| BLAKE2b-256 |
1923f3862f1f3725e875164259ec6e52d2a7679647b22cf42dd4c7b901a4fbc2
|