Every chapter of my thesis stalled on the same thing. I would have a physics question, and before I could answer it I had to write the program that could ask it. The question behind all of them was whether 0.2 mm·mrad of slice emittance (how much the electrons spread in position and angle) at 200 pC, the best any injector measured then, was a floor, or whether a gun could reach 0.1. Four programs came out of six years at Tsinghua with Prof. Chuanxiang Tang, and I defended in December 2016. Two years later I gave a job talk at SLAC and called it "How Many Codes Does It Take to Get an Accelerator Physics PhD".
- 1.044emittance growth factor from the roughness of a measured copper surface
- ~400×charge the silver nanoholes gave in infrared light, once the laser spot is deconvolved
- 25%lower emittance at the same peak current, with a C-band buncher after the gun
A rough copper cathode
Dowell's photoemission formula matches measured quantum efficiency, but several labs saw emittance about twice what it predicts. Roughness was the usual suspect. Simulating it hit two walls. Copper's quantum efficiency is of order , so firing photons at a surface and asking whether an electron came out throws nearly all of them away. And the field above a random surface normally means a solver on a mesh that follows every bend.
So I borrowed the point spread function from imaging and wrote PyPES around it. The PSF's rms radius comes out under a nanometre and its tail dies fast outside that, so the laser is effectively constant over the patch that feeds any one point of the surface. The phase space emitted at a point then factorises, , the laser's intensity at the landing point times a momentum distribution, and what is left to draw from is that momentum half.
is the point spread function with the landing position integrated away, a normalisation built from the reflectivity, the two mean free paths and the photon energy, the momentum away from the surface and the least of it an electron needs to escape (the step functions that keep the electron going forward and cap its total momentum are left off).
The sampler draws a position from the laser spot and takes that point's momentum from there, tilted by the local slope. About one try in six survives. The field is a first-order Fourier expansion worked out one thin layer at a time, and a Runge-Kutta integrator steps each electron up until the sideways field is gone.

The same function splits the statistical emittance exactly in two. The first piece is Dowell's formula, so the second is its error, and it works out to one length, 0.40 nm, against laser spots around 100 µm.
Roughness itself came next. Two things happen on a surface that is not flat. Each facet emits into its own tilted frame, and the field just above the bumps has a sideways component that keeps pushing while the electron climbs out. I worked both into one expression for a random slowly varying surface, first in two dimensions and then in three. The two land inside the same square. They act on the same electron at the same time, so adding them as separate terms would throw away the cross term.
is the emittance with roughness and the value on a smooth cathode, is the mean square slope of the surface along , the primed momenta are the ones a facet emits in its own frame, is the imaginary unit, carries the applied field , and the term with the integral is the sideways momentum the field above the bumps has added by the time the electron is clear of it, built from the Fourier coefficients of that same surface, with the length of .
I ran the simulation on a real copper cathode (W. Li helped me measure the surface). The growth came out far below the 1.5 to 2 that other labs had measured (IPAC'15), and the analytic formula agreed on the same bunch, from the wrong side. It should have landed just under the analytic value and crept up to it, and came out above instead, 4.826 against 4.822 µm·keV/c. My step was too big, I think, since each Runge-Kutta step uses the field from where the electron was and that field falls off with height, so the kick is overestimated. Prof. Tang and I wrote it up in PRAB (2015, when it was still Phys. Rev. ST Accel. Beams).


The analytic formula is cheap, so I could sweep the applied field, and for that surface the growth factor stays under 1.1 even at 120 MV/m. For a machine-polished cathode, rms height under 30 nm and rms slope under 3 mrad, at the 50 MV/m an S-band gun runs at, roughness is negligible, which left the missing factor of two looking for another cause. Avoid hand polishing, which leaves roughness at the hundred-nanometre scale.

Silver nanoholes at UCLA
In 2014 I spent most of a year in Pietro Musumeci's Pegasus group at UCLA on the opposite idea, a cathode patterned on purpose. Nanoholes in silver, sized to resonate with 800 nm light, absorb more of the laser than flat metal does.

To check a pattern you light it at one wavelength after another and take a picture each time. The patch looks dark against the bright flat silver, and its reflectivity is its brightness over the background's. Processing the frames afterwards was slow, and I wanted the curve during the scan. So I wrote NPC Analyzer in PyQt. It finds the patch with scikit-image's edge detector, then grows or shrinks sampling boxes inside and around it, each until its brightness is flat enough to trust, and a table of reflectivity against wavelength builds up as you go.


The dip landed at about 801 nm for holes designed for 800, and it was shallow, down to 45% where the design had said 0.63%. The group re-ran Lumerical with the dimensions the SEM actually measured, and the dip came out in the same place and nearly as shallow. What is left over is hole-to-hole variation from the milling, plus a probe that was broad.
The pattern did not survive the gun. After the high-power run the wafer went back on the spectrometer, the 800 nm resonance was gone, and reflectivity had dropped across nearly the whole band, so the structure had been destroyed and the surface was rough enough now to scatter. The likely moment is the run where we stepped the laser up to trace how the yield scales with intensity, the highest intensity the wafer ever saw, and nobody measured the damage threshold.

I sized the hole array, in simulation, for the resonance at 800 nm. The group made the wafers and built the reflectivity setup and a cathode plug for high-power tests, all reported in the NIM A paper I first-authored. The yield map showed only about ten times the silver around it. But the laser spot was 1.3 mm across and the pattern 0.2 mm, so most of what the map averaged was flat metal, and deconvolving that is worth another factor of forty at the pattern itself. The map has a bright ring on it too, out at the wafer's edge, and that is the plug. The wafer sits 1.5 mm below the copper plate, which sharpens the field at its rim and leaves about two thirds of the normal field on its face, so the emission phase moves and space charge is less suppressed than on a flush cathode. That is the trade. Far more charge under an infrared laser, nearly double the thermal emittance of flat copper, so it suits a high-charge machine better than an ultra-low-emittance one. We published a caveat next to it, though. Morphology affects emittance strongly, so the damage may be part of why the emittance came out large, and the recessed wafer is the other thing I would not measure this way twice.
Pancake and cigar
Then a question I could answer with algebra. There are two ways to light a cathode, a short fat pulse people call a pancake and a long thin one they call a cigar. Each has a floor under its thermal emittance at a given field, reached where emission cuts itself off, the charge already in flight screening the surface until the next electron cannot leave. I worked out both. (A higher field only lowers a floor if the photon clears the work function at all. With 266 nm light on copper it clears it by 0.35 eV, so it does.)
One correction had to go in first. Schottky lowering of the work function assumes a single electron in front of a clean surface. In a bunch, each slice looks out through the charge that left before it, so each carries its own effective work function and its own emittance. Skip that averaging and the answer comes out about 20% low at the space-charge limit, 222 pC or so for copper at 50 MV/m.

The pancake floor falls out of the space-charge condition, and once the charge and the field are named there is no free parameter left in it. At 50 MV/m and 200 pC it works out to 0.11 mm·mrad, with a laser radius of 379 µm.
is the bunch charge and the field at the cathode, the bare work function, since the Schottky lowering is written out as the second term under the root at four ninths of , which is what averaging over the slices leaves at the limit, and is the permittivity of free space rather than an emittance.
The cigar is the interesting one. Once the pulse is long, the screening reaches only about one laser radius into the bunch, so the floor stops tracking the total charge and starts tracking the cathode's saturation current, and at fixed charge the longer pulse wins. (The saturation current and the one-radius result are Filippetto and colleagues'; the slice picture built on them is mine.) At 200 pC and 10 ps it comes out at 0.09 mm·mrad, with a radius of 390 µm.
is the pulse length on the cathode, so what the floor tracks is the emitted current , and the work function carries no Schottky lowering here, since at the limit the charge already in flight has cancelled the field at the surface.
You cannot stretch the pulse forever, though. A long bunch sits across real RF phase, the higher-order terms take hold, and the emittance they add downstream never comes back. All of this is analysis, with no measurement anywhere in it.
Splitting the gun in two
A cigar bunch is too long to be useful on its own. An FEL injector wants 20 to 50 A at the exit, so something has to compress it, and squeezing a long bunch with a plain sinusoid leaves the current profile badly lopsided. The fix in the literature is to run the fundamental and its third harmonic together in one cavity, which flattens a stretch of field for the beam to ride (that idea is Raguin's at PSI, and Dowell's). Lovely on paper. It also means two couplers, a mode filter, and getting both modes tuned and flat in one piece of copper.
We took the modes apart instead and gave each its own cavity, pushed together until the leakage complained. That is a BNL-type 1.6-cell S-band gun with an X-band cavity right behind it, the fourth harmonic and not the third, aiming for 30 A at 200 pC (IPAC'16, with Prof. Tang, Houjun Qian at LBL, and a Zhen Zhang who is not me). We tried it two ways. Combined, with the cavity hard against the gun and the solenoid after both. Separated, with the solenoid in between and a C-band buncher after it. None of it left Superfish and ASTRA, and no cavity was ever built.
Before any beam dynamics, both cavities had to be tuned. Three radii to move, one in the X-band cavity and two in the S-band gun. Three things to hit, the two frequencies and the flatness of the S-band field. Three of each, because a Jacobian has to be square before it has any hope of being invertible. Superfish gives the response and finite differences the Jacobian around it.
is the Jacobian and the distance still to go, and I arrived at the half by trying halves, so four Superfish runs buy one step and a design costs about a dozen.
The tuning also had to run unattended, because the leakage into the gun depends on where the X-band cavity sits, and beam dynamics might later want it somewhere else, so the whole shape optimization gets redone. And the loop does not stop on tolerance. Dimensions mean nothing below about 10 µm of machining precision, so after a few iterations the new numbers round to the old ones and it stops, target met or not. Out came a gun on frequency with its two cells level to within 0.04%, and of the X-band field leaking into it, against a target of one part in a thousand.
Every question there was an ASTRA scan, and the class that drives ASTRA in PyGAS still says what I thought of that: "A tool that eases the painful scans in ASTRA simulations." The NSGA-II and SPEA2 operators are DEAP's; mine is the plumbing that turns each individual into an ASTRA run and the run back into two numbers. SCOOP farms the individuals out in parallel (Christos Papadopoulos helped with the genetic algorithm and the parallel computing). I drew the framework so the simulator and the optimizer could be swapped, and only ASTRA and the two GAs ever got wired in.
The separated layout did best. The combined one went through the same optimization and finished between the other two, hugging the no-buncher front under 0.65 mm rms and drifting towards the C-band front above it. Why the two differ I never analysed.
What I would flag is the laser pulse. The optimizer had up to 15 ps available and stopped short of it, around 13 ps at its longest and 10 at the 30 A solution, which is odd when a long pulse is the premise of the whole scheme, and I said as much in the paper. My guess is chromatic, the solenoid acting on the energy spread a long bunch picks up from the RF. The thesis leaves it open.
It did a second thing I never explained. Adding the buncher doubled the pulse it asked for, 5 ps to 10, while the radius came down only from 0.4 to 0.32 mm. Cigar saturation says a doubled pulse should shrink the radius by 37%, and it took 20%. So with a buncher in the line, tuning the cathode for maximum brightness no longer maximises brightness at the exit. Without one, it does.


A run was half an hour to an hour on Tsinghua's cluster, and a full optimization took days. What the chapter ends on is the part that did not work. The buncher's compression went mostly unused, and the initial bunch never grew to the length I had expected. None of the best solutions sat at space-charge-limited emission either, so the beam never got near the floor I had derived at the start of the chapter. What I could answer was 0.15 mm·mrad of core slice emittance at 30 A. The 0.1 turned up only after I handed the optimizer a cooler cathode, 0.9 µm/mm down to 0.5. Which is not a cheat, as the thesis reads it. 0.1 at 200 pC is open to anyone with a cathode under 0.5 µm/mm (some semiconductor cathodes run in a low-QE mode are), a cigar pulse, and one harmonic cavity in the line.
PyeGun
February 2017, after the defence, I pulled that tuning loop out of the injector work and gave it a repository of its own, PyeGun. Two numbers go in, a frequency and a cell count, and Superfish and Newton do the rest, stepping the radii until the frequency and the flatness both land. It stayed a prototype.
Spot grids, from a summer practice project
The "etc." A Hartmann-Shack sensor puts tiny lenses in front of a camera, so the light shows up as a grid of spots, and each spot's shift gives the local tilt of the wavefront. HS WFS Toolbox finds each spot's row and column, even on frames that come streaky, split or bitten, by projecting onto x and y and picking the peaks (its peak finder is someone else's Python port of peakdet, a MATLAB script). Cutting the frame into strips, each with its own peaks, lets the grid bend where the frame does. Then every spot gets a Gaussian fit for its centre and brightness.



Numbers come from the thesis (Tsinghua, 2016) and its code appendices, the two 2015 roughness papers, the NIM A paper and IPAC'16.