ocelot-collab / ocelot

OCELOT is a multiphysics simulation toolkit designed for studying FEL and storage ring-based light sources.
GNU General Public License v3.0
85 stars 58 forks source link

The number of transfer matrix not match the number of elements #192

Closed ReidarQin closed 8 months ago

ReidarQin commented 1 year ago

Hi Sergey, I found that when using lat.transfer_maps() and lat.sequence() gives different length of outcome (see the quote below). The reason of doing this is that I want to plot s versus transfer matrix element, e.g. R56, so I need a consistent outcome length. You have a second loop in transfer_maps() calculation for some dipoles etc, which causes longer output for matrix than sequence.

Perhaps you can add s as part of the output when output_at_each_step is enabled?

len(lat.transfer_maps(energy=14, output_at_each_step=True)[1]) Out[262]: 1013

len(lat.sequence) Out[263]: 971

Best, WQ

cr-xu commented 1 year ago

I would say this is probably due to the fact that ocelot automatically expands the Dipole to a [Edge, Dipole, Edge] sequence with edge focusing effects. Not sure if that's all though.

sergey-tomin commented 1 year ago

yes, the reason is what Chenran pointed out. Actually, I asked @ReidarQin to open this issue. Because, it might be useful to have s position along the beam line in order to display Rnn(s) or Tnnn(s). I think I will do it next week.

sergey-tomin commented 1 year ago

done, see CHANGELOG and commit https://github.com/ocelot-collab/ocelot/commit/982a67c1c66d2a8cac6b823f2fe3bdabe0c0c1e3