bmad-sim / bmad-ecosystem

Bmad simulation ecosystem for simulating high energy storage rings.
https://www.classe.cornell.edu/bmad/
11 stars 13 forks source link

Add `set twiss` to Tao #962

Open ChristopherMayes opened 4 months ago

ChristopherMayes commented 4 months ago

Currently the user can set the beginning element Twiss via a command like set ele beginning beta_a = 1.2345. However, it is often needed to set the Twiss in the middle of a lattice. Rather that rely on the Tao optimizer, I would like to have a command to do this by efficiently propagating the twiss backwards then forwards. This should allow multiple items to be set at once, including coupling terms. For example:

Tao> set ele <ele> beta_a = 1.2 alpha_b = -1.2
DavidSagan commented 4 months ago

Under what conditions is it legal to set the Twiss in the middle of a lattice?

ChristopherMayes commented 4 months ago

Shouldn't it be possible for any open lattice?

DavidSagan commented 4 months ago

No since the Twiss at any point in the lattice is determined by propagating the Twiss from the beginning. This is true for both open and closed lattices. It is just that the Twiss at the beginning is determined differently for open and closed lattices.

ChristopherMayes commented 4 months ago

The command should take the twiss as the user defined, propagate it backwards to the beginning, and then propagate forward through the lattice (as usual).

DavidSagan commented 4 months ago

This will take some development... And will have to be address mode flip issues.