DiPAS-2.0
توضیحات
DiPAS is a framework for differentiable simulations of particle accelerators.
| ویژگی | مقدار |
|---|---|
| سیستم عامل | - |
| نام فایل | DiPAS-2.0 |
| نام | DiPAS |
| نسخه کتابخانه | 2.0 |
| نگهدارنده | [] |
| ایمیل نگهدارنده | [] |
| نویسنده | Dominik Vilsmeier |
| ایمیل نویسنده | d.vilsmeier@gsi.de |
| آدرس صفحه اصلی | https://gitlab.com/Dominik1123/dipas |
| آدرس اینترنتی | https://pypi.org/project/DiPAS/ |
| مجوز | GPL-3.0 |
<div align="center">
<a href="https://gitlab.com/Dominik1123/dipas">
<img
alt="dipas-logo"
src="https://gitlab.com/Dominik1123/dipas/-/raw/develop/logo/logo.png"
width="30%"
style="display: block; margin-left: auto; margin-right: auto;"
>
</a>
</div>
[](https://gitlab.com/Dominik1123/dipas/-/commits/develop)
[](https://gitlab.com/Dominik1123/dipas/-/commits/develop)
[](https://pypi.org/project/DiPAS/)
[](https://pypi.org/project/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](https://dipas.readthedocs.io/en/stable/usage/tracking.html)
or [optics calculations](https://dipas.readthedocs.io/en/stable/usage/optics.html) such as closed orbit search or
computation of Twiss parameters.
The involved computations are backed by the [PyTorch](https://pytorch.org/) 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](https://dipas.readthedocs.io/en/stable/usage/building.html#Parsing-MADX-scripts)
lattice definitions and hence allows for zero-overhead importing of existing lattices.
In addition, it supports [custom lattice definitions](https://dipas.readthedocs.io/en/stable/usage/building.html#Using-the-build-API)
from provided element classes.
DiPAS can also be used via command line interface, see [`dipas --help`](https://dipas.readthedocs.io/en/stable/usage/cli.html)
for more information.
## Relevant links
* [Documentation](https://dipas.readthedocs.io/)
* [Examples](https://gitlab.com/Dominik1123/dipas/blob/master/examples)
* [PyPI Project](https://pypi.org/project/dipas/)
## Example usage
Minimizing loss along beamline by tuning quadrupoles:
```py
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()
```
نیازمندی
| مقدار | نام |
|---|---|
| >=7.1 | click |
| >=0.3.2 | click-inspect |
| >=2.10.1 | jinja2 |
| - | matchable |
| - | matplotlib |
| >=1.21.0 | numpy |
| >=0.25.1 | pandas |
| >=0.9 | pint |
| - | rich |
| >=1.5.0 | scipy |
| >=1.10.0 | torch |
| >=3.7.4 | typing-extensions |
زبان مورد نیاز
| مقدار | نام |
|---|---|
| >=3.7 | Python |
نحوه نصب
نصب پکیج whl DiPAS-2.0:
pip install DiPAS-2.0.whl
نصب پکیج tar.gz DiPAS-2.0:
pip install DiPAS-2.0.tar.gz