Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improvement of RF frequency control #414

Merged
merged 2 commits into from
Jun 17, 2022
Merged

Conversation

lfarv
Copy link
Contributor

@lfarv lfarv commented Jun 15, 2022

The get_acceptance function is an example of a function which may internally modify the ring RF frequency, to satisfy its dp or dct argument. The new frequency_control decorator avoids this and offers a cleaner solution to handle dp and dct in future similar functions.

This decorator can be applied to any function like func(ring, *args, **kwargs). Example:

@frequency_control
def get_acceptance(ring, planes, npoints, amplitudes, nturns=1024,
                   refpts=None, dp=None, offset=None, bounds=None,
                   grid_mode=GridMode.RADIAL, use_mp=False, verbose=True,
                   start_method=None, divider=2, shift_zero=1.0e-9):

It looks at the 1st argument of the decorated function, which must be a Lattice object (ring)

  • if ring.radiation is True and dp or dct is specified, it makes a copy of ring with a modified RF frequency, removes the dp and dct keywords and call the decorated function with the copy of ring,
  • otherwise, it directly calls the decorated function with the initial arguments.

So the decorated function does not need to care about RF frequency: It uses ring as it is, the dp or dct arguments will be present only when they are allowed (in 4D only).

In addition, get_revolution_frequency is improved when dp is specified: rather that relying on the momentum compaction factor, it uses closed orbit computation, giving a more accurate result.

@lfarv lfarv requested a review from swhite2401 June 15, 2022 12:33
@lfarv lfarv added the Python For python AT code label Jun 15, 2022
@lfarv
Copy link
Contributor Author

lfarv commented Jun 15, 2022

The same improvement on off-momentum revolution frequency is done in Matlab, so I rename the all request.

@lfarv lfarv changed the title Create a "frequency_control" decorator Improvement of RF frequency control Jun 15, 2022
@lfarv lfarv added the Matlab For Matlab/Octave AT code label Jun 15, 2022
Copy link
Contributor

@swhite2401 swhite2401 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems like a very nice improvement

@lfarv lfarv merged commit deaf24f into master Jun 17, 2022
@lfarv lfarv deleted the frequency_control_decorator branch June 17, 2022 08:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Matlab For Matlab/Octave AT code Python For python AT code
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants