Skip to content

[WIP] Linear-optics Twiss functions#1412

Draft
ax3l wants to merge 1 commit into
BLAST-ImpactX:developmentfrom
ax3l:topic-diags-twiss
Draft

[WIP] Linear-optics Twiss functions#1412
ax3l wants to merge 1 commit into
BLAST-ImpactX:developmentfrom
ax3l:topic-diags-twiss

Conversation

@ax3l
Copy link
Copy Markdown
Member

@ax3l ax3l commented Apr 19, 2026

Two modes are supported:

  • Periodic ring (init=None): the one-turn map is computed from the current lattice, the Wolski 6D eigendecomposition provides the matched initial Courant-Snyder / Mais-Ripken Twiss, and the closed-orbit dispersion is obtained from the periodic equation $$(I - M_{4 \times 4}) D = M[0{:}4, 5]$$. Fractional tunes are extracted from the eigenvalue phases and returned in the tunes key.
  • Transfer line / linac (init given): the user supplies initial uncoupled Courant-Snyder parameters; Twiss is then propagated from the entrance through the lattice without matching.

float(init.get("disp_py", 0.0)),
]
)
tunes = None
@ax3l ax3l force-pushed the development branch 2 times, most recently from 9a1e4af to fa61eba Compare April 20, 2026 04:08
Two modes are supported:

* **Periodic ring** (``init=None``): the one-turn map is computed from the
  current lattice, the Wolski 6D eigendecomposition provides the matched
  initial Courant-Snyder / Mais-Ripken Twiss, and the closed-orbit
  dispersion is obtained from the periodic equation
  :math:`(I - M_{4 \times 4}) D = M[0{:}4, 5]`. Fractional tunes are
  extracted from the eigenvalue phases and returned in the ``tunes`` key.
* **Transfer line / linac** (``init`` given): the user supplies initial
  uncoupled Courant-Snyder parameters; Twiss is then propagated from the
  entrance through the lattice without matching.
@ax3l ax3l force-pushed the topic-diags-twiss branch from 4296979 to 58df7fa Compare April 20, 2026 05:14
# alpha, phase advance mu, and dispersion along s, plus the fractional tunes
# for rings. The underlying lattice-level building blocks are available as
# ``sim.lattice.transfer_map(ref)`` (end-to-end map) and
# ``sim.lattice.map_trace(ref)`` (per-element cumulative trace).
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is useful doc, but a bit ill placed here. Belongs in compute_twiss or other user-facing docs.

Comment on lines +127 to +140
def _symplectic_form() -> np.ndarray:
"""Return the 6x6 canonical symplectic form J for ordering
(x, p_x, y, p_y, t, p_t).

J is block-diagonal with three 2x2 blocks ``[[0, 1], [-1, 0]]``. A
matrix ``A`` is symplectic iff ``A^T J A = J``; the Poisson bracket
of two phase-space functions f, g satisfies
``{f, g} = (grad f)^T J (grad g)``.
"""
J = np.zeros((6, 6))
for i in range(3):
J[2 * i, 2 * i + 1] = 1.0
J[2 * i + 1, 2 * i] = -1.0
return J
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We have a value for this now in CovarianceMatrix.H and SmallMatrix.H that we can bind.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants