Skip to main content

DiPAS is a framework for differentiable simulations of particle accelerators.

Project description

https://gitlab.com/Dominik1123/dipas/badges/develop/pipeline.svg https://gitlab.com/Dominik1123/dipas/badges/develop/coverage.svg https://img.shields.io/pypi/v/dipas.svg

DiPAS

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.

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-1.2.tar.gz (1.9 MB view details)

Uploaded Source

Built Distribution

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

DiPAS-1.2-py3-none-any.whl (176.2 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for DiPAS-1.2.tar.gz
Algorithm Hash digest
SHA256 a61e54b6206d82455cc479f7670effce4f02d0ad692ef424a49aa3fd9826d9c3
MD5 a990e3573add10648663652827782f44
BLAKE2b-256 72c41e520a3c6531bebff2052bcab954bad1eba0e045d8cb148083574c711727

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for DiPAS-1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 6e27cffecffc648d3b9168453ae7b1aff13733976aba7073a7dbba5ff3cce7fc
MD5 9ff286677c9ec78ec4339baa3f3b6bd8
BLAKE2b-256 86aed426d247c5597035211afe0dbf6fe7cf84e6e23a476e2ba538dd2e40fc41

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