Skip to content

Commit d48bbe9

Browse files
committed
Test tracking after broadcast through EA gives same result
1 parent 2b2b882 commit d48bbe9

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

tests/test_batched.py

+21
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,27 @@ def test_enormous_through_ares():
172172
assert outgoing.total_charge.shape == (100_000,)
173173

174174

175+
def test_before_after_broadcast_tracking_equal():
176+
"""
177+
Test that when tracking through a segment after broadcasting, the resulting beam is
178+
the same as in the segment before broadcasting.
179+
"""
180+
segment = cheetah.Segment.from_ocelot(ares.cell).subcell("AREASOLA1", "AREABSCR1")
181+
incoming = cheetah.ParameterBeam.from_astra(
182+
"tests/resources/ACHIP_EA1_2021.1351.001"
183+
)
184+
segment.AREAMQZM1.k1 = torch.tensor([4.2])
185+
outgoing = segment.track(incoming)
186+
187+
broadcast_segment = segment.broadcast((10,))
188+
broadcast_incoming = incoming.broadcast((10,))
189+
broadcast_outgoing = broadcast_segment.track(broadcast_incoming)
190+
191+
for i in range(10):
192+
assert torch.all(broadcast_outgoing._mu[i] == outgoing._mu[0])
193+
assert torch.all(broadcast_outgoing._cov[i] == outgoing._cov[0])
194+
195+
175196
def test_broadcast_customtransfermap():
176197
"""Test that broadcasting a `CustomTransferMap` element gives the correct result."""
177198
tm = torch.tensor(

0 commit comments

Comments
 (0)