Skip to content

Commit

Permalink
Add test to see if Solenoid.misalignment has broadcasting issue
Browse files Browse the repository at this point in the history
  • Loading branch information
jank324 committed Oct 3, 2024
1 parent 456ba7c commit 8366221
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions tests/test_vectorized.py
Original file line number Diff line number Diff line change
Expand Up @@ -424,3 +424,28 @@ def test_broadcasting_corrector_angles(ElementClass):
assert outgoing.particles.shape == (3, 2, 100_000, 7)
assert outgoing.particle_charges.shape == (100_000,)
assert outgoing.energy.shape == (2,)


def test_broadcasting_solenoid_misalignment():
"""
Test that broadcasting rules are correctly applied to the misalignment in solenoids.
"""
incoming = cheetah.ParticleBeam.from_parameters(
num_particles=100_000, energy=torch.tensor([154e6, 14e9])
)
element = cheetah.Solenoid(
length=torch.tensor(0.15),
misalignment=torch.tensor(
[
[[1e-5, 2e-5], [2e-5, 3e-5]],
[[3e-5, 4e-5], [4e-5, 5e-5]],
[[5e-5, 6e-5], [6e-5, 7e-5]],
]
),
)

outgoing = element.track(incoming)

assert outgoing.particles.shape == (3, 2, 100_000, 7)
assert outgoing.particle_charges.shape == (100_000,)
assert outgoing.energy.shape == (2,)

0 comments on commit 8366221

Please sign in to comment.