DiPAS is a framework for differentiable simulations of particle accelerators.
DiPAS is a program for differentiable simulations of particle accelerators. It acts as a framework and thus supports a wide range of use cases such as particle tracking or optics calculations such as closed orbit search or computation of Twiss parameters.
The involved computations are backed by the PyTorch package which also provides the relevant functionality for differentiation of user-defined quantities as well as a variety of gradient-based optimizers that integrate with the thus derived quantities.
The DiPAS package can parse MADX lattice definitions and hence allows for zero-overhead importing of existing lattices. In addition it supports custom lattice definitions from provided element classes.
Minimizing loss along beamline by tuning quadrupoles:
import numpy from dipas.build import from_file from dipas.elements import Quadrupole import torch lattice = from_file('example.madx') for quad in lattice[Quadrupole]: quad.k1 = torch.nn.Parameter(quad.k1) optimizer = torch.optim.Adam(lattice.parameters(), lr=1e-3) particles = torch.from_numpy(numpy.load('particles.npy')) while True: tracked, loss_val = lattice.linear(particles, recloss='sum') lost = 1 - tracked.shape / particles.shape if lost < 0.01: # Fraction of particles lost less than 1%. break optimizer.zero_grad() loss_val.backward() optimizer.step()
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
|Filename, size||File type||Python version||Upload date||Hashes|
|Filename, size DiPAS-1.3.1-py3-none-any.whl (185.7 kB)||File type Wheel||Python version py3||Upload date||Hashes View|
|Filename, size DiPAS-1.3.1.tar.gz (2.0 MB)||File type Source||Python version None||Upload date||Hashes View|