lnls-fac/trackcpp

Create fast and dirty calc_twiss

Opened this issue · 6 comments

calc_twiss now takes 80 ms on my I7 computer. 60 ms are from findm66 using TPSA which gives transfer matrices from passmethods with computer accuracy. For VACA purpose, should a fast and dirty calc_twiss (like AT) with numerical calculation of transfer matrices suffice?

How much do you think we would gain in time?
How much time does it spend finding the closed orbit?

6d closed orbit only takes 1-2 ms. ⚡ ! but it takes this eternity only because it iterates a few times (around 6-10) calculating 7 linepass each. I believe a dirty calc_twiss can be as fast as 4-7 ms for SI (3200 elements), if eta is also calculated numerically.

wow!! If those numbers are correct, this is pretty impressive! I think it would be worth having a flag in findm66 allowing the user to choose which method to use. Specially as it is not that dirty...

We could add another function instead of a flag, something like calc_fast_twiss.

But the code which would in fact change would be findm66 and not calc_twiss, is that right?
If that's the case, the only difference in calc_twiss would be a call to a different version of findm66 and to the method which calculates the dispersion function. It seems an unnecessary duplication of code to create a calc_fast_twiss, isn't it?

We can wrap the common code into a lower level function and then call it from two differently named high level functions.