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

Matching paired quadrupoles #270

Open
delaossa opened this issue Jan 17, 2025 · 2 comments
Open

Matching paired quadrupoles #270

delaossa opened this issue Jan 17, 2025 · 2 comments

Comments

@delaossa
Copy link
Contributor

delaossa commented Jan 17, 2025

Hello!
Ocelot's match function is working well for me to find the quadrupole's strengths to match the Twiss parameters of the beam at a certain element location. 👍
In my script, match is varying the strength of 4 quadrupoles to find the optimum.
Let's call these quadrupoles Q1, Q2, Q3 and Q4.
My question: is it possible to use match in a way that the strengths are paired, e.g. Q1.k1 = Q2.k1 and Q3.k1 = -Q4.k1?
A trick that seems to work is to make, for example, Q2 = Q1, and remove Q2 from the list of varying elements.
However, this does not work like this for the case where Q3.k1 = -Q4.k1, because Q4 = - Q3 is not allowed.
Any ideas?
Cheers.

@iagapov
Copy link
Collaborator

iagapov commented Jan 17, 2025 via email

@delaossa
Copy link
Contributor Author

delaossa commented Mar 7, 2025

Hello Ilya,
Thanks for your answer and apologies for the delay in getting back to this.
I have just noticed that the match function actually allows for coupling a series of quads to the same strength value:

if isinstance(vars[i], tuple): # all quads strength in tuple varied simultaneously

One just needs to add the coupled quads as a tuple to the list of varying parameters for match.
However, the way is implemented does not allow for "anti coupling", i.e. quads of opposite strengths.

I think that a similar and more general approach would be to pass a dictionary with the quads as keys and the coupling parameters as values, e.g.:

vars = [{Q1: 1, Q2: 1}, {Q3: 1, Q4: -1}]

I have just given it a try in this PR #275 and it seems to work well.

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

No branches or pull requests

2 participants