Skip to content

add Matrix66RadPass passmethod#1071

Open
swhite2401 wants to merge 11 commits intomasterfrom
matrix66rad
Open

add Matrix66RadPass passmethod#1071
swhite2401 wants to merge 11 commits intomasterfrom
matrix66rad

Conversation

@swhite2401
Copy link
Copy Markdown
Contributor

This PR adds a Matrix66RadPass passmethod to allow switching radition on or off for an M66 element using the standard enable_6d/disable_6d function.

This is the first step to a complete refurbishment of the fastring module.

This is for the comment a proposal, any comments or suggestions are more than welcome.

@swhite2401 swhite2401 requested review from lcarver and lfarv March 31, 2026 09:11
@swhite2401 swhite2401 added enhancement WIP work in progress Python For python AT code labels Mar 31, 2026
@swhite2401
Copy link
Copy Markdown
Contributor Author

Test script:

import at
import numpy as np
import matplotlib.pyplot as plt

ring = at.load_lattice("../lattice/hmba.mat", periodicity=1)
cavs = ring.get_uint32_index(at.RFCavity)
newring = []
allcavs = []
for ii, ic in enumerate(cavs[::-1]):
    print(ii, ic)
    allcavs.append(ring[ic])
    if ic < len(ring):
        ring = ring[:ic]+ring[ic+1:]
    else:
        ring = ring[:ic]
ring = ring.repeat(32)
ring += allcavs
ring.rf_voltage = 5.5e6
ring.set_rf_frequency()

print(ring.enable_6d(copy=True).envelope_parameters())

ring_norad = ring.disable_6d(copy=True)
ring_norad.enable_6d(at.RFCavity)
ring_rad = ring.enable_6d(copy=True)

m66 = at.gen_m66_elem(ring_norad, ring_rad)

fring = at.Lattice([m66], energy=ring.energy)

fring.disable_6d()
pout, *_ = fring.track(np.ones(6)*1e-4, nturns=10000)
pout=np.squeeze(pout)

plt.subplot(231)
plt.plot(pout[0,:], pout[1,:], '.')
plt.subplot(232)
plt.plot(pout[2,:], pout[3,:], '.')
plt.subplot(233)
plt.plot(pout[5,:], pout[4,:], '.')

fring.enable_6d()
pout, *_ = fring.track(np.ones(6)*1e-4, nturns=10000)
pout=np.squeeze(pout)

plt.subplot(234)
plt.plot(pout[0,:], pout[1,:], '.')
plt.subplot(235)
plt.plot(pout[2,:], pout[3,:], '.')
plt.subplot(236)
plt.plot(pout[5,:], pout[4,:], '.')

plt.tight_layout()
plt.show()

Result:
image

@swhite2401 swhite2401 marked this pull request as ready for review April 10, 2026 11:46
@swhite2401
Copy link
Copy Markdown
Contributor Author

@lfarv @lcarver I believe this is ready for review. I will start the new fastring development based on this in a new branch.

@swhite2401 swhite2401 removed the WIP work in progress label Apr 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement Python For python AT code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant