Skip to content

Conversation

ZeugAusHH
Copy link
Collaborator

Add support for callback functions to the lattice writing code in OCELOT adaptor for "GENESIS 1.3", v4.

If provided when calling the function write_gen4_lat, the callback function gets called for every lattice element while writing a lattice file. This enables the user to override the default behavior and manipulate/replace what is written to the file. As demonstrated by the included demo, one use case is to support new (developer) features of "GENESIS 1.3", v4 without having to modify the adaptor code.

Also reorganized the lattice file generation code in the adaptor.

The included demo script generates a short SASE1-type undulator beamline and matches periodic FODO solution. Then the lattice is written twice:
(i) with standard behavior (not using a callback function); and
(ii) demonstrating the new callback feature, overriding the aw values in the UNDULATOR lines in the lattice with references to a user-defined sequence name (sequences were introduced in "GENESIS 1.3", v4.6.6 and allow for instance for undulator tapering using values generated by a linear polynomial defined in GENESIS main input file).

(Note: The successful execution of the demo script requires the changes in pull request #216 ).

@sserkez
Copy link
Collaborator

sserkez commented Mar 20, 2024

a bit redundant in my opinion but may be useful for some developers

@sserkez sserkez merged commit 69a8b8b into ocelot-collab:dev_gen Mar 20, 2024
sergey-tomin pushed a commit that referenced this pull request Jul 17, 2025
callback functionality for lattice writing code (adaptor for "GENESIS 1.3", v4)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants