Skip to content

Commit 8e7038f

Browse files
committed
Add exit aperture after slicing.
1 parent 6aa229e commit 8e7038f

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

xtrack/slicing.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -301,12 +301,20 @@ def _slice_element(self, name, element, chosen_slicing, _edge_markers=True) -> O
301301
for nn in slices_to_add:
302302
ee = self._line._element_dict[nn]
303303
if (type(ee).__name__.startswith('ThinSlice')
304-
or type(ee).__name__.startswith('ThickSlice')):
304+
or type(ee).__name__.startswith('ThickSlice')
305+
or (_edge_markers and nn==exit_marker)):
305306
aper_name = f'{name}_aper..{aper_index}'
306307
self._line._element_dict[aper_name] = xt.Replica(
307308
parent_name=element.name_associated_aperture)
308309
new_slices_to_add += [aper_name]
309310
aper_index += 1
311+
if not _edge_markers:
312+
# If no edge markers, we need to manually add an
313+
# aperture after the last slice.
314+
aper_name = f'{name}_aper..{aper_index}'
315+
self._line._element_dict[aper_name] = xt.Replica(
316+
parent_name=element.name_associated_aperture)
317+
new_slices_to_add += [aper_name]
310318
new_slices_to_add += [nn]
311319
slices_to_add = new_slices_to_add
312320

0 commit comments

Comments
 (0)