callback functionality for lattice writing code (adaptor for "GENESIS 1.3", v4) #217
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 ).