- description: Increases the number of particles in a particle input file by sampling a simplified
distribution based the input file. Intended to be used to increase the number of particles
produced by a photoinjector simulation to improve stability of CSR and LSC simulations.
Can also add energy and density modulations for performing gain studies.
The algorithm is as follows:

- Fit a 12
^{th}-order polynomial to p as a function of t. Evaluate the polynomial at 10,000 equispaced points to generate a lookup table for the momentum variation with time. - Compute the standard deviation of the momentum p
_{sd}for blocks of 2,000 successive particles. Fit this data with a 12^{th}-order polynomial and evaluate it a 10,000 equispaced points to generate a lookup table for p_{sd}as a function of t. - Create a histogram of t and smooth it with a low-pass filter having a cutoff at 0.1 THz. This may resulting in ringing at the ends of the histogram, which is clipped off by masking with the original histogram.
- Optionally modulate the histogram H(t) with a sinusoid, by multiplying the histogram
by (1 + d
_{m})cos2πct∕λ_{m}, where d_{m}is the modulation depth and λ_{m}is the modulation wavelength. For non-zero d_{m}, this will result in a longitudinal-density-modulated distribution when the histogram is used as a probability distribution and sampled to create time coordinates. - Sample the time histogram N times using a “quiet start” Halton sequence with
radix 2, where N is the number of desired particles. The sampling operation is
performed by first numerically computing the cumulative distribution function C(t) =
∫
_{-∞}^{t}H(t^{′})dt^{′}∕∫_{-∞}^{∞}H(t^{′})dt^{′}. Inverting this to obtain t(C), we generate each sample from H(t) by evaluating t(U), where U is a quantity on the interval [0, 1] generated from the Halton sequence. - Create samples for other coordinates by quiet-sampling of gaussian distributions:
- Scaled transverse coordinates , , ŷ, and using Halton radices 3, 5, 7, and 11,
respectively. For convenience in scaling (step 9), these are defined such that the
standard deviation of each coordinate is 10
^{-4}and all coordinates are uncorrelated. - Scaled fractional momentum deviation δ
_{1}using Halton radix 13, with unit standard deviation.

- Scaled transverse coordinates , , ŷ, and using Halton radices 3, 5, 7, and 11,
respectively. For convenience in scaling (step 9), these are defined such that the
standard deviation of each coordinate is 10
- Interpolate the look-up tables to determine the mean p
_{mean}and standard deviation p_{sd}of the momentum at each particle’s time coordinate. Use these to compute the individual particle momenta using p = p_{mean}+ δ_{1}p_{sd}. - Compute the projected transverse rms emittances and Twiss parameters for the original beam.
- Transform the scaled transverse phase-space coordinates to give the desired projected Twiss parameters in the x and y planes. The x and y planes are assumed to be uncorrelated.

- Fit a 12
- synopsis:
smoothDist6 -input name -output name -factor number -rippleAmplitude % -rippleWavelength microns -smoothPasses num(500) -energyMod % -betaSlices n

- files:
- input — A particle distribution file, such as might be used with sdds_beam.
- output — A particle distribution file, such as might be used with sdds_beam.

- switches:
- -factor number — Factor by which to multiply the number of particles.
- -rippleAmplitude value — Density ripple amplitude, in percent.
- -energyMod value — Energy modulation amplitude, in percent. The wavelength is fixed at 1 μm.
- -rippleWavelength value — Density ripple and energy modulation wavelength, in microns.
- -betaSlices n — Number of longitudinal slices to use for analysis of twiss parameters. The twiss parameters of the beam will vary step-wise from slice to slice. This discontinuous variation may cause problems (e.g., unstable behavior).
- -smoothPases num — Presently ignored.

- author: M. Borland, ANL/APS.
- see also: doubleDist6

TFBFirSetup