[WIP] Linear-optics Twiss functions#1412
Draft
ax3l wants to merge 1 commit into
Draft
Conversation
| float(init.get("disp_py", 0.0)), | ||
| ] | ||
| ) | ||
| tunes = None |
9a1e4af to
fa61eba
Compare
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
commented
Apr 20, 2026
| # 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). |
Member
Author
There was a problem hiding this comment.
This is useful doc, but a bit ill placed here. Belongs in compute_twiss or other user-facing docs.
ax3l
commented
Apr 20, 2026
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 |
Member
Author
There was a problem hiding this comment.
We have a value for this now in CovarianceMatrix.H and SmallMatrix.H that we can bind.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Two modes are supported:
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 equationtuneskey.initgiven): the user supplies initial uncoupled Courant-Snyder parameters; Twiss is then propagated from the entrance through the lattice without matching.