Home‎ > ‎How To's‎ > ‎Particles‎ > ‎

Advancing particles

Particles loaded are advanced one step with the default LeapFrog mover by calling

step()

This will advance particles loaded a single timestep specified by top.dt in all types of simulations other the the x-y slice code and envelope codes. In the slice code step() advances on axial distance step specified by top.ds along the reference orbit of the lattice. In the envelope code step() does a complete envelope advance. To advance nstep postitive integer steps call:

step(nstep)

Every time the code is back at the interpreter particle positions and momenta/velocities are properly synched in the leapfrog advance cycle of the mover.  In the 3D and r-z packages, top.dt defines the time advance step. In the x-y slice code, wxy.ds defines the axial slide advance step along the reference orbit. In the envelope code step() advances the envelope fully from env.zl to env.zu axial coordinates with step size env.dzenv.  

Numerous built-in "hooks" can be exploited to apply interpreter defined functions in the particle advance cycle without modifying compiled code.  For example:

installbeforestep()   # installs a function to be called before a step
installafterstep()    # installs a function to be called after  a step


These can be used as in the following schematic example where one might want to call a particular diagnostic function after taking a step in the particle advance:

def my_diagnostic()
  ... code to define user diagnostic function


installafterstep(my_diagnostics)

Then the diagnostic defined in my_diagnostic() will be called each step the simulation is advanced. 
Comments