Line helpers¶
- xtrack_tools.line.resolve_element_name(line, element_name)[source]¶
Return the line’s canonical name for
element_name(case-insensitive).Element names in the xsuite line are lower case, while callers commonly use the upper-case MAD-X convention (e.g.
MKQA.6L4.B1). Match on a case-insensitive basis and return the actual name stored in the line.
- xtrack_tools.line.get_element_s_centre(line, element_name, table=None)[source]¶
Return the longitudinal position of an element in a line.
- xtrack_tools.line.get_explicit_element_s_centre(line, element_name)[source]¶
Return the source-resolved centre position when the line retains one.
MAD-X sequence import preserves placement definitions in the line composer. Once materialised, a line stores intervening drifts and its table reconstructs
sby summation, which can differ by a few ulps from the source-resolved coordinate. This uses the composer’s own resolver rather than inspecting placement implementation details. A line without a composer has no retained source-placement result, so callers must useget_element_s_centre()instead.
- xtrack_tools.line.next_available_element_name(line, base_name)[source]¶
Return an element name that is unused in both the line and its environment.
- xtrack_tools.line.make_element_thin(line, element_name, length_tol=1e-12)[source]¶
Collapse a thick element to a zero-length marker at its centre, in place.
The thick body is preserved as an equal-length drift so the lattice length and downstream optics are unchanged, while a zero-length
xt.Markerkeeps the original element name and sits at the element centre. This pins the element’s Twiss row to its centre, which is where point-like insertions (a single-turn kick, an AC dipole) actually act — reading optics from the original thick element’s entry row would otherwise be off by half its length.The element’s own transfer map is discarded (replaced by a drift), so this is intended for passive position markers such as tkickers and AC-dipole markers that carry no active strength in the optics. Elements already thin (within
length_tol) are left untouched.- Parameters:
- Returns:
The canonical (line) name of the now-thin element.
- Raises:
ValueError – If
element_nameis not present in the line.- Return type: