Welcome to elementary’s documentation!
Generic differentiable accelerator elements modeling in JAX. Single particle hamiltonian function:
where \(\beta\) and \(\gamma\) are the relativistic factors, \(h(s)\) is the reference trajectory curvature and \(t(s)\) is the reference trajectory torsion, \(a_x(q_x, q_y, q_s; s)\), \(a_y(q_x, q_y, q_s; s)\) and \(a_s(q_x, q_y, q_s; s)\) are the scaled vector potential components, and \(\varphi(q_x, q_y, q_s; s)\) is the scaled scalar potential. Additionaly, longitudinal coordinate and momentum are given by:
Common predefined elements are available or you can create your own by specifying scaled potentials and reference trajectory parameters (curvature and torsion). All but vector potentials arguments are optional for hamiltonian and element construction. Vector and scalar potentials are assumed to have matching signatures.
def vector(qs:Array, s:Array, *args:Array) -> tuple[Array, Array, Array]:
q_x, q_y, q_s = qs
...
def scalar(qs:Array, s:Array, *args:Array) -> Array:
q_x, q_y, q_s = qs
...
This is also the case for curvature and torsion functions. Note, same extra arguments as in vector and scalar functions should be passed.
def curvature(s:Array, *args:Array) -> Array:
...
def torsion(s:Array, *args:Array) -> Array:
...
The resulting hamiltonian and element signatures are:
def hamiltonian(qs: Array, ps: Array, s: Array, *args: Array) -> Array:
q_x, q_y, q_s = qs
p_x, p_y, p_s = ps
...
def element(qsps:Array, length:Array, start:Array, *args:Array) -> Array:
qs, ps = jax.numpy.reshape(qsps, (2, -1))
q_x, q_y, q_s = qs
p_x, p_y, p_s = ps
...
Examples:
- Example-01: Functional iteration
- Example-02: Hamiltonian factory
- Example-03: Element factory
- Example-04: Drift element factory
- Example-05: Quadrupole element factory
- Example-06: Sextupole element factory
- Example-07: Octupole element factory
- Example-08: Multipole element factory
- Example-09: Dipole element factory
- Example-10: Dipole element factory (cylindrical multipole)
- Example-11: Alignment errors (straight layout)
- Example-12: Alignment errors (curved layout)
- Example-12: TM010 cavity factory
API:
- Util
bessel()
beta()
gamma()
momentum()
ptc()
rigidity()
- Hamiltonian
autonomize()
hamiltonian_factory()
- Element
element_factory()
- Drift
drift_factory()
mapping()
vector()
- Quadrupole
quadrupole_factory()
vector()
- Sextupole
sextupole_factory()
vector()
- Octupole
octupole_factory()
vector()
- Multipole
multipole_factory()
vector()
- Dipole
curvature()
dipole_factory()
mapping()
vector_dipole()
vector_octupole()
vector_quadrupole()
vector_sextupole()
- Alignment
alignment_factory()
rx()
ry()
rz()
tx()
ty()
tz()
- Cavity
cavity_factory()