Skip to content

at.Wiggler does not handle kz=0 #1075

Description

@SebastienJoly

I am currently trying to implement undulators with different H and V harmonics in pyAT. For that, I use the By and By arguments in at.Wiggler.
I have a list of H/V harmonics, each with a different amplitude, wavenumbers, and phase. The By harmonics respect the condition ky^2 = kx^2 + kz^2, and the Bx ones kx^2 = ky^2 + kz^2.
pyAT consistently returns an unstable ring as soon as kz=0, whether with By or Bx harmonics.
From the integrator gwig.c, there are several kw/kz when calculating the vector potentials. Yet, this special case is not documented nor safely handled in GWigSymplecticPass.c and GWigSymplecticRadPass.c.

Should we add some safeguards in gwig.c or in a different integrator?

You can find a reproducible example below. Note that it is working if I am using By=(1, 1, 0, 1, 1, 0) (kx=0, ky=1, kz=1) instead.

import numpy as np
import at

QF = at.Multipole("QF", 0.5, poly_b=np.array([0,1.2]), poly_a=np.zeros(2))
Dr = at.Drift("Dr", 0.5)
HalfDr = at.Drift("Dr2", 0.25)
Dr3 = at.Drift("Dr3", 0.075)
QD = at.Quadrupole("QD", 0.5, -1.2)
Bend = at.Dipole("Bend", 1, 2 * np.pi / 20)
Und = at.Wiggler('und', length=0.425, wiggle_period=0.425/50, b_max=1,
                 #By=(1, 1, 0, 1, 1, 0))
                 By=(1, 1, 1, 1, 0, 0))

FODOcell = at.Lattice(
    [HalfDr, Bend, Dr, QF, Dr, Bend, Dr, QD, Dr3, Und],
    name="Simple FODO cell",
    energy=1e9,
)

print(FODOcell[-1:].track(r_in=np.zeros(6)))

print(FODOcell.radiation_parameters())

I use the following AT and numpy versions:
print(at.__version__) print(np.__version__)

0.8.1.dev6+gfd9eed9e
1.26.4

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions