Skip to content

Refactoring of magnet integrators#1083

Open
lfarv wants to merge 6 commits into
masterfrom
magnet_integrators
Open

Refactoring of magnet integrators#1083
lfarv wants to merge 6 commits into
masterfrom
magnet_integrators

Conversation

@lfarv

@lfarv lfarv commented Jun 1, 2026

Copy link
Copy Markdown
Contributor

Here is a full refactoring of the magnet passmethods.
It uses include files which can be combined to generate all the different magnet passmethods. At the moment, this is based on:

6 Propagation methods:

  • drift_fast.h
  • drift_expanded.h
  • drift_exact.h
  • drift_exactbend.h
  • drift_exactstrbend.h
  • drift_E2.h

5 kick methods

  • kick_kn,h
  • kick_exactkn.h
  • kick_k1h_kn.h
  • kick_h_k0h_k1h_kn.h
  • kick_E2.h

3 geometry descriptions

  • straight_multipole.h
  • curved_dipole.h
  • straight_dipole.h

2 integrators

  • 4th order Forest-Ruth
  • 6th order Yoshida

And a single integrator template: magnet_template.h

With this, the standard StrMPoleSymplectic4Pass pass method is written as:

#define MAGNET_PASS `StrMPoleSymplectic4Pass`
#define INTEGRATOR_4

#include "drift_fast.h"    /* drift */
#include "kick_kn.h"  /* kick */
#include "straight_multipole.h"

#include "magnet_template.h"

And the corresponding radiative passmethod is written as:

#define MAGNET_PASS StrMPoleSymplectic4RadPass
#define INTEGRATOR_4
#define RADIATION
#define DIFFUSION

#include "drift_expanded.h"
#include "kick_kn.h"
#include "straight_multipole.h"

#include "magnet_template.h"

Obviously you can't mix randomly propagation and kicks. But creating new passmethods is easy, like for instance a 6th order StrMPoleSymplectic6Pass:

#define MAGNET_PASS StrMPoleSymplectic6Pass
#define INTEGRATOR_6

#include "drift_fast.h"    /* drift */
#include "kick_kn.h"  /* kick */
#include "straight_multipole.h"

#include "magnet_template.h"

Or a quantum diffusion version ExactSectorBendQuantPass:

#define MAGNET_PASS ExactSectorBendQuantPass
#define INTEGRATOR_6
#define QUANTUM
#define NO_OMP  /* because of problems with random generator and OpenMP */

#include "drift_exactbend.h"
#include "kick_k1h_kn.h"
#include "curved_dipole.h"

#include "magnet_template.h"

@lfarv lfarv added enhancement Matlab For Matlab/Octave AT code Python For python AT code labels Jun 1, 2026
@simoneliuzzo

Copy link
Copy Markdown
Contributor

Dear @lfarv,

to review I may simply run some basic tracking, DA, etc on this branch compared to the master?
May be you already did this.

thank you
best regards
Simone

@lfarv

lfarv commented Jun 15, 2026

Copy link
Copy Markdown
Contributor Author

@simoneliuzzo: of course you are welcome to use the branch for all kinds of optics computation: this helps a lot in validating the modifications. I recall the expected behaviour:

  • the computations should be strictly identical to the ones in the "Quad_curvature_correction" branch, but differ from the master branch for bending magnet core and end faces. The differences are only in the organisation of the code,
  • the speed should be equivalent the the master branch,
  • I made successful comparison of single magnet tracking with XSuite, but I did not run all the various cases that you propose, so please try.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement Matlab For Matlab/Octave AT code Python For python AT code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants