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

New Lattice.reduce method #429

Merged
merged 6 commits into from
Jul 4, 2022
Merged

New Lattice.reduce method #429

merged 6 commits into from
Jul 4, 2022

Conversation

lfarv
Copy link
Contributor

@lfarv lfarv commented Jun 30, 2022

The Lattice.reduce method is similar to the atreduce Matlab function: it removed all elements with an IdentityPass passmethod, and then merges compatible consecutive elements.

A keep keyword allows to keep selected elements even if they have an IdentityPass passmethod. By default, Lattice.reduce keeps Monitor and RFCavity elements.

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.

This is very nice!

@lfarv
Copy link
Contributor Author

lfarv commented Jul 1, 2022

@simoneliuzzo : there was a bug when comparing PolynomA/B (missing the last term, PolynomB[MaxOrder]). Your example now seems to run. Can you check ?

Copy link
Contributor

@simoneliuzzo simoneliuzzo left a comment

Choose a reason for hiding this comment

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

I have tested with two lattice files. One EBS SR lattice, with few elements to reduce and an ARC cell of 10000 elements that has been correctly reduced to 141 elements. The optics after reducing are identical a part the last few digits of some parameters (numerical).

@lfarv
Copy link
Contributor Author

lfarv commented Jul 1, 2022

@simoneliuzzo: thanks for testing, I rely on you for that !

Did you try "keep=None" which should be even more agressive by removing Monitor and RFCavity elements, or any other "keep" combination ?

@simoneliuzzo
Copy link
Contributor

Dear @lfarv ,
no I did not try, I find that is a very good idea to keep RF and BPMs by default.
Now I tried it.
On a very segmented ARC cell it gives no errors and the optics are identical to those of the default reduce. So, good for me.
On an EBS SR lattice with RF cavities it works without issues. I think the cavities are CavityPass (or RFCavityPass) and thus they are not removed.

@lfarv
Copy link
Contributor Author

lfarv commented Jul 1, 2022

@simoneliuzzo:

I think the cavities are CavityPass (or RFCavityPass) and thus they are not removed.

Of course, this is useful only if radiation is OFF: thin cavities are then set to IdentityPass.

@lfarv lfarv merged commit d0af8e4 into master Jul 4, 2022
@lfarv lfarv deleted the reduce_lattice branch July 4, 2022 08:40
@swhite2401 swhite2401 mentioned this pull request Aug 16, 2022
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.

None yet

3 participants