Python Library for Simulated Commissioning of Synchrotrons Accelerator Toolbox Workshop

Slide Note
Embed
Share

This workshop presented by Lukas Malina introduces a Python library for simulated commissioning of synchrotrons, focusing on commissioning simulations using AI translation from Matlab. The Python library aims to replicate machines with random errors, provide correction methods, and enhance performance analysis in accelerator commissioning. Collaboration with ESRF and LBNL has led to the development of robust correction methods and new features like charge-scaled BPM noise. The bottom-up approach and incremental advancements in correction methods are emphasized, aiming to improve the efficiency of the commissioning process.


Download Presentation

Please find below an Image/Link to download the presentation.

The content on the website is provided AS IS for your information and personal use only. It may not be sold, licensed, or shared on other websites without obtaining consent from the author. Download presentation by click this link. If you encounter any issues during the download, it is possible that the publisher has removed the file from their server.



Uploaded on May 13, 2024 | 0 Views


Presentation Transcript


  1. Python library for simulated commissioning of synchrotrons Accelerator Toolbox Workshop Luk Malina On behalf of: Thorsten Hellert, Simone Liuzzo, Lina Hoummi, Bianca Veglia, and Elaf Musa Grenoble, October 2nd, 2023

  2. Outline Commissioning simulations and/in Python Translation from Matlab with the help of AI Contents of the Python library DESY. | Accelerator Toolbox Workshop | Python library for simulated commissionning of synchrotrons | Lukas Malina et al. Page 2

  3. What consists an accelerator? How does it define commissioning simulations? Designed: Groups of perfect and identical elements which are perfectly aligned Specify (realistic) tolerances on the components themselves and their alignment Can we pass from Built to Operational? -> Commissioning simulations Store and interface errors, which are different for each single element Provide high-level correction methods and separated performance analysis Replicate many machines with all sorts of random errors (given the tolerances) Built: Neither perfect nor identical elements, which feature residual misalignments Does not work! Need to commission, i.e. adjust settings using beam as a diagnostics tool Single replication with errors -> Commissioning simulation with only changed interface Operational: Same as built. However, with adjusted settings, it provides a designed performance DESY. | Accelerator Toolbox Workshop | Python library for simulated commissionning of synchrotrons | Lukas Malina et al. Page 3

  4. Python library for commissioning being developed Collaboration with ESRF (EURIZON project) and LBNL Written in Python and pyAT for beam dynamics Python-based solutions gain momentum and user base Translated the SC library with the help of AI Improved the code maintainability and test coverage Advancing correction methods Bottom-up approach Implementing robust methods for the typically skipped steps in the commissioning chain Focus (temporarily) on single cases and fixing them Advancing incrementally from the (commissioning) start to its end Trajectory BBA, RF-setup New features Charge-scaled BPM noise, error propagation DESY. | Accelerator Toolbox Workshop | Python library for simulated commissionning of synchrotrons | Lukas Malina et al. Page 4

  5. ChatGPT-aided translation

  6. Translation workflow made more efficient Creating a project stub Raw conversion by ChatGPT (Engine: code-davinci-002) Python API or browser-based Quotas and lower quality with distance in the text Stripping off comments Fix problems and stitch together manually Method signatures, implicit definitions, etc Create reasonable data structures, write type hints Making everything run, producing correct results Write automated tests DESY. | Accelerator Toolbox Workshop | Python library for simulated commissionning of synchrotrons | Lukas Malina et al. Page 6

  7. ChatGPT helped to translate SC Python API def remove_comments_in_file(ffile: str, source_dir: str = "") -> str: with open(f"{source_dir}{ffile}", "r") as mfile: lines = mfile.readlines() new_lines = [l.replace("\t", " ").strip("\n") for l in lines if not l.strip().strip("\t").startswith("%")] new_lines = [l for l in new_lines if l.strip(" \t\n")] return "\n".join(new_lines) def matlab_to_python(matlab_code: str, python_start: str = "") -> str: intro = "# Convert this from Matlab to Python:\n# Matlab version \n\n" ending = "\n# End\n# Python version\n\n prompt = intro + matlab_code + ending + python_start response = openai.Completion.create(model="code-davinci-002", temperature=0, top_p=1, frequency_penalty=0, presence_penalty=0, max_tokens=len(prompt), stop=[intro[:20]], prompt=prompt) return python_start + response.choices[0].text Run on all SC Matlab files A bigger part of the SC was roughly translated within an hour! DESY. | Accelerator Toolbox Workshop | Python library for simulated commissionning of synchrotrons | Lukas Malina et al. Page 7

  8. ChatGPT helped to translate SC Browser-based translation DESY. | Accelerator Toolbox Workshop | Python library for simulated commissionning of synchrotrons | Lukas Malina et al. Page 8

  9. Python library contents

  10. Commissioning simulation library: General workflow SimulatedCommissioning class High-level methods Ideal lattice pyAT Lattice Moddeling Settings interface Adds errors to ideal setpoints Uncertainties data Physical Uncertainties Trajectory Orbit BBA RF setup Realistic lattice machine BPM reading Adds errors to tracking data DESY. | Accelerator Toolbox Workshop | Python library for simulated commissionning of synchrotrons | Lukas Malina et al. Page 10

  11. Error sources included BPM Errors: Support structures (3 stackable types): BPM offsets (3D) Offsets (3D) BPM noise (CO, TBT) Rolls (3D) BPM roll (1D) RF errors: BPM calibration RF phase RF frequency Magnet Errors: Magnet offsets (3D) RF Voltage Magnet rolls (3D) Injection errors: Magnet calibration (strength) Static errors (6D) Multipole errors (offsets and calibration) Jitter (6D) Ring circumference error DESY. | Accelerator Toolbox Workshop | Python library for simulated commissionning of synchrotrons | Lukas Malina et al. Page 11

  12. Methods chained in commissioning simulation: PETRA IV First turn steering Done Done Trajectory BBA Multipole ramp-up Done RF setup Done Tune scan Done Orbit BBA Dynamic Aperture Orbit correction Done Tune correction Optics correction (LOCO and TBT) DESY. | Accelerator Toolbox Workshop | Python library for simulated commissionning of synchrotrons | Lukas Malina et al. Page 12

  13. Where to find it? Public repository on GitHub https://github.com/lmalina/pySC https://lmalina.github.io/pySC/ Soon to be released on PyPI With a possible name change ICALEPCS 23 conference (next week) L. Malina et al., Python library for simulated commissioning of storage-ring accelerators DESY. | Accelerator Toolbox Workshop | Python library for simulated commissionning of synchrotrons | Lukas Malina et al. Page 13

  14. Conclusions and plans Commissioning simulations are an indispensable part of the design accelerator Presented a Python library to facilitate the task Started as a translation from Matlab (SC toolkit) We are approaching the first (alpha) release DESY. | Accelerator Toolbox Workshop | Python library for simulated commissionning of synchrotrons | Lukas Malina et al. Page 14

  15. Thank Thankyou youfor foryour yourattention attention Contact Contact Luk Malina Lukas.malina@desy.de +49 40 8998 5475 DESY. Deutsches Elektronen-Synchrotron www.desy.de

Related


More Related Content