Simple example of running ion_effects in elegant. 
J. Calvey, M. Borland (APS)

aps.lte
        Lattice file

* Setup files:
Basic.ele
        Use to create file with twiss parameters.
makeBunch.ele
        Used to make an initial bunch distribution.

* Ion simulation files
gasMix.sdds
        Simple pressure vs s file. Just have uniform pressure for
        several species.
ionProperties.sdds
        Cross sections for ion production.
ion[123].ele
        Run ion simulation for 324 uniformly spaced bunches

There are 3 .ele files for ionEffects simulations:
ion1.ele:  There are 10 IONEFFECTS elements, placed every 4 sectors.  The ILMATRIX element is used for tracking between IONEFFECTS elements.  There is no chromaticity or synchrotron radiation.

ion2.ele:  Tracking is done element-by-element around the ring.  There are 11 IONEFFECTS elements, placed after every 37th quadrupole.  The chromaticity is set to 3 in both planes.  The SREFFECTS element is used for synchrotron radiation effects.

ion3.ele: Same as ion2.ele, except for the bunch pattern, which is now generated by the script makeBunchTrainWF:
makeBunchTrainWF -rootname ion3 -bunchSlots 324 -nPerBunch 1000 -bunchWF bunchWF.sdds 

  The script requires a reference bunch (<rootname>.bunRef), and a fill file.   The fill file should have two columns: Index, and WaveformNorm. Index is the bunch index (including empty buckets). WaveformNorm should be 1 for the highest charge bunch, and 0 for empty buckets. For other bunches, WaveformNorm should be the fraction of the bunch charge relative to the highest charge bunch.  A bunch with a WaveformNorm of 1 will be identical to the reference bunch; a bunch with a WaveformNorm of 0.5 will have half the particles in the reference bunch.  In the example provided (bunchWF.sdds), there are 324 bunches, with a different number of particles in each bunch.


=== 

Sequence for ion1.ele:

elegant Basic.ele
        Uses aps.lte
        Makes Basic.twi, Basic.mag, Basic.mom

elegant makeBunch.ele 
        Uses aps.lte, Basic.twi, Basic.mom
        Makes makeBunch.out

mpiexec -np <numberOfCores> Pelegant ion1.ele
        Replace <numberOfCores> with appropriate value for your system. Up to 64 recommended for this problem.
        Uses aps.lte, Basic.twi, gasMix.sdds, ionProperties.sdds, makeBunch.out
        Makes
        ion1.wp00 --- turn-by-turn parameter data for bunch 0 from WATCH element
        ion1.wp162 --- turn-by-turn parameter data for bunch 162 from WATCH element
        ion1.ebeam --- turn-by-turn, bunch-by-bunch data for electron beam from ion elements
        ion1.ionDens --- turn-by-turn, bunch-by-bunch data for ions from ion elements

makePlots ion1
	  Makes plots of the ion density, instability amplitude, average beam size, and beam spectrum


Similarly, for ion2.ele:
mpiexec -np <numberOfCores> Pelegant ion2.ele
makePlots ion2


Extra steps are required for ion3.ele:
cp makeBunch.out ion3.bunRef
makeBunchTrainWF -rootname ion3 -bunchSlots 324 -nPerBunch 1000 -bunchWF bunchWF.sdds 
mpiexec -np <numberOfCores> Pelegant ion3.ele
makePlots ion3





