DiPAS is a framework for differentiable simulations of particle accelerators.

## Project description

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 program 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.

DiPAS can also be used via command line interface, see dipas --help for more information.

## Example usage

Minimizing loss along beamline by tuning quadrupoles:

import numpy
from dipas.build import from_file
import torch

while True:
tracked, loss_val = lattice.linear(particles, recloss='sum')
lost = 1 - tracked.shape[1] / particles.shape[1]
if lost < 0.01:  # Fraction of particles lost less than 1%.
break
loss_val.backward()
optimizer.step()


## Project details

Uploaded source
Uploaded py3