Skip to main content

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

# 250 MeV proton FFAG ring: 8 FD doublet cells
DA.init(5, 2)  # DA order 5, 2 variables (x, px)
Brho = kinetic_to_brho(250.0, M_PROTON)

# F magnet: horizontally focusing sector, 25 degrees
F = sector_map([0.9, 2.0], Brho, angle=np.radians(25.0))

# D magnet: horizontally defocusing sector, 20 degrees
D = sector_map([0.9, -3.0], Brho, angle=np.radians(20.0))

# One cell = F + D, full ring = 8 cells
cell = compose_sequence([F, D])
ring = compose_n(cell, 8)

print(f"Cell tune: {twiss(cell)['tune']:.4f}")
print(f"Ring tune: {tune(ring):.4f}")

Features

  • Sector magnet tracking: Hamiltonian integration through sector magnets with polynomial field profiles. Midplane (sector_map, 2 DOF) and full 4D (sector_map_4d, with Maxwell-consistent off-midplane field expansion)
  • 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 midplane equations of motion in Frenet-Serret (curvilinear) coordinates with arc length as the independent variable. Sector magnets have radial edge faces (no edge focusing).

Integration with danf

Use with danf for nonlinear normal form analysis (amplitude-dependent tune shifts):

from danf import NormalForm

nf = NormalForm(ring)
nf.compute()
print(nf.tunes)
print(nf.detuning)

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

pyffag-0.2.1.tar.gz (17.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pyffag-0.2.1-py3-none-any.whl (11.5 kB view details)

Uploaded Python 3

File details

Details for the file pyffag-0.2.1.tar.gz.

File metadata

  • Download URL: pyffag-0.2.1.tar.gz
  • Upload date:
  • Size: 17.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.12

File hashes

Hashes for pyffag-0.2.1.tar.gz
Algorithm Hash digest
SHA256 a1581734dab4f1fa39669ca2316aa15eeb35f0e33eb0d1de6afabad905ca5c95
MD5 56a7026e88e09b3e69acbdfcba5daddc
BLAKE2b-256 2fc78b3c1010d191d3a3bf0abeaaeb1e33e5629909edf4dd250b2a7e319b0ab8

See more details on using hashes here.

File details

Details for the file pyffag-0.2.1-py3-none-any.whl.

File metadata

  • Download URL: pyffag-0.2.1-py3-none-any.whl
  • Upload date:
  • Size: 11.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.12

File hashes

Hashes for pyffag-0.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 edbafc5d182247dcb9c5604447878d7114a82c5e53f749cca6bfff26994efba1
MD5 e0a6cf5317a1919f38f0bf6b39b7ea24
BLAKE2b-256 c8ce21d3d1800ad219609c3ad7dafced9be1d2bd8bd9919208f8d0e5d2f08fcb

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page