Example of computing Touschek lifetime with a parastic 4th-harmonic
cavity. Includes main and harmonic cavity beamloading, rf feedback,
beam feedback, and longitudinal impedance for 81 bunches.
The bunch form factor is used in setting up the rf phase setpoint.

M. Borland, 2/2/2019

Source files:
lattice.lte
        Lattice file, including the full element-by-element lattice and 
        beamlines for use in fast tracking

AmpFeedbackFilters.sdds
PhaseFeedbackFilters.sdds
        From T. Berenc, used to model rf feedback for main cavity.

Basic.ele
        Basic run for setting up fast tracking, getting lattice parameters

ILMatrixSetup
ILMatrix.xref
        Set up ILMATRIX for fast tracking

SREffectsSetup
SREffects.xref
        Set up SREFFECTS For fast tracking

beamLoadCalcHHC
computeBunchLength
beamLoadXref.sdds
        Precalculate beamloading including iterative solution for the bunch length.
        Allows computing the synchronous phase setpoint for the main cavities
        Create parameter file to set up RFMODE elements including feedback
        Used by runCase

makeBunch
makeBunch.ele
        Makes a single bunch (duplicated for tracking).
        Used by runCases.

ring_rw.impe
ring_zz.impe
        Old impedance files from Y.C. Chae
        Should really sum these to make a single impedance for better performance.

lma.ele
        Compute local momentum acceptance

runTemplate.ele
        Template for running with impedance and longitudinal feedback
runCase
        Set up a script file for a case (particular value of harmonic cavity detuning)
runCases
        Run a series of cases.
        Needs modification for local queueing system.
        Read the comments in this script!

====        

Sequence of operations

** Set up lattice model
elegant Basic.ele
SREffectsSetup
ILMatrixSetup

** compute LMA
mpiexec -np 13 Pelegant lma.ele 
sddssort -col=s lma.mmap
sddsplot -col=s,delta????tive lma.mmap

** set up jobs
runCases
for file in run-*.csh ; do $file; done

**
Post-process
