atcollab / at

Accelerator Toolbox
Apache License 2.0
48 stars 31 forks source link

Naming of the keyword arguments of simple_ring #647

Closed lfarv closed 1 year ago

lfarv commented 1 year ago

The recent simple_ring function has some arguments in common with the existing sigma_matrix function. However, their names are slightly different. Apart from the mnemonic inconvenience, this prevents from using the same dictionary as input for both functions (I encountered the problem when trying to compare the "design" Σ-matrix with the output of tracking a population through simple_ring: I need both functions).

So I would like to rename the simple_ring arguments coherently with those of sigma_matrix: beta_x -> betax alpha_x -> alphax emit_x -> emitx sigma_dp -> espread For the last one, strictly speaking, it's indeed a momentum spread (not energy), so we could envisage adding an alias in sigma_matrix (mspread or even keeping sigma_dp). But I would not like to alias all the arguments…

Next: simple_ring could accept the same input as sigma_matrix:

Third: we miss the Matlab simple ring: atsimplering

Otherwise, simple_ring worked nicely in all my tests!

lfarv commented 1 year ago

Anybody willing to do something about that ? Or shall I do it ?

swhite2401 commented 1 year ago

I think @lcarver said he would do it, but most likely not for matlab...

lfarv commented 1 year ago

Fine. Apart from naming, better being done before the function gets widely used, all my other suggestions are neither critical nor urgent, just ideas!

For Matlab, same: not urgent, I might do it some time later…

lcarver commented 1 year ago

Sorry, I was off yesterday. I will do it for your first 2 points. But yes, I will not do the MATLAB! Although I am not sure of the following point:

"one could even accept a Σ-matrix, which can replace alpha, beta, emit, sigma_dp.`"

This is not clear to me.

lfarv commented 1 year ago

This is not clear to me.

The Σ-matrix (beam matrix as returned by ohmienvelope, for instance) contains all the optics and emittance information. So, with Σ and tunes, you can get the M66 matrix and the emittances. Adding the damping times, you have everything.

Here, since the longitudinal motion is treated apart, I think we should use a 4D twiss_in input, generate a 4x4 transfer map and add the 44, 45, 54 and 55 terms as you do it now.

So to start from the R matrix in twiss_in, the easiest is first to build Σ = ε1.R1 + ε2.R2, then use a_matrix to get the A matrix, use the tunes to generate the rotation matrix S and finally build M44 = A.S.A-1

If starting directly from Σ, a_matrix will also return the needed emittances.

lcarver commented 1 year ago

fixed in #655