Improvement of RF frequency control #414
Merged
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.
The
get_acceptance
function is an example of a function which may internally modify the ring RF frequency, to satisfy itsdp
ordct
argument. The newfrequency_control
decorator avoids this and offers a cleaner solution to handledp
anddct
in future similar functions.This decorator can be applied to any function like
func(ring, *args, **kwargs)
. Example:It looks at the 1st argument of the decorated function, which must be a Lattice object (
ring
)ring.radiation
isTrue
anddp
ordct
is specified, it makes a copy ofring
with a modified RF frequency, removes thedp
anddct
keywords and call the decorated function with the copy of ring,So the decorated function does not need to care about RF frequency: It uses
ring
as it is, thedp
ordct
arguments will be present only when they are allowed (in 4D only).In addition,
get_revolution_frequency
is improved whendp
is specified: rather that relying on the momentum compaction factor, it uses closed orbit computation, giving a more accurate result.