Skip to main content

DiPAS is a framework for differentiable simulations of particle accelerators.

Project description

pipeline coverage pypi python


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.

Relevant links

Example usage

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[1] / particles.shape[1]
    if lost < 0.01:  # Fraction of particles lost less than 1%.
        break
    optimizer.zero_grad()
    loss_val.backward()
    optimizer.step()

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

DiPAS-2.0.tar.gz (2.0 MB view details)

Uploaded Source

Built Distribution

DiPAS-2.0-py3-none-any.whl (201.3 kB view details)

Uploaded Python 3

File details

Details for the file DiPAS-2.0.tar.gz.

File metadata

  • Download URL: DiPAS-2.0.tar.gz
  • Upload date:
  • Size: 2.0 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.27.1 setuptools/50.3.1.post20201107 requests-toolbelt/0.9.1 tqdm/4.45.0 CPython/3.7.9

File hashes

Hashes for DiPAS-2.0.tar.gz
Algorithm Hash digest
SHA256 f0ab8ef2ba88f7661fda06efc7dfba2efc29c0595a6ad3757c0e55ad5b51272b
MD5 6321ee87eb4ec980ccbc71945c6c7e31
BLAKE2b-256 08d08fe0467c713b704ced37076f3737818efef0ee85b4ea8c1711948e9c6f7e

See more details on using hashes here.

File details

Details for the file DiPAS-2.0-py3-none-any.whl.

File metadata

  • Download URL: DiPAS-2.0-py3-none-any.whl
  • Upload date:
  • Size: 201.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.27.1 setuptools/50.3.1.post20201107 requests-toolbelt/0.9.1 tqdm/4.45.0 CPython/3.7.9

File hashes

Hashes for DiPAS-2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 1389102549084977c1b989ed60dc7e3eca141b45b2ef5f5d177f13d228be6794
MD5 5fc87c531345d89bb111d39b4b4103f2
BLAKE2b-256 db6d969ebbe53c800b5796f840e875a14f9bcfecb52ddb9b088362dcb7b70537

See more details on using hashes here.

Supported by

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