desy-ml / cheetah

Fast and differentiable particle accelerator optics simulation for reinforcement learning and optimisation applications.
https://cheetah-accelerator.readthedocs.io
GNU General Public License v3.0
30 stars 13 forks source link

Remove Ocelot dependencies in Cheetah #8

Closed cr-xu closed 1 year ago

cr-xu commented 1 year ago

Fixes #4

Particle distribution conversion validated with astraBeam2particleArray:

import ocelot.adaptors as oca
import numpy as np
from cheetah.utils import from_astrabeam

parray = oca.astraBeam2particleArray("benchmark/astra/ACHIP_EA1_2021.1351.001")
particles, energy = from_astrabeam("benchmark/astra/ACHIP_EA1_2021.1351.001")

print("Maximal dev:", np.max((parray.rparticles.transpose() - particles)))
# > Maximal dev: 4.51461784622964e-16
cr-xu commented 1 year ago

I thinke for now this would be sufficient.

Installing Cheetah with Ocelot as optional dependency will happen once Ocelot is on PYPI.