Photocathode & injector codes, etc.

A PhD asking how low a photocathode gun can push emittance, and the four codes it took.

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".

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 104, 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, D|𝐏I(x0,y0)fp, the laser's intensity at the landing point (x0,y0) times a momentum distribution, and what is left to draw from is that momentum half.

fp(px,py,pz)=Cppzpz2+pm2px2+py2+pz2+pm2

fp is the point spread function with the landing position integrated away, Cp a normalisation built from the reflectivity, the two mean free paths and the photon energy, pz the momentum away from the surface and pm 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.

Cut through the cathode at x = 57.47 µm, about 130 µm long and 60 nm tall: the potential in colour above the surface, the measured surface profile as a black line and the potential's zero contour as a white line running on top of it.
One cut through the surface, with the approximate potential's zero contour (white) lying on the measured profile (black).

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.

εx2=εD,x2[1(xR)2+(pzxR+jmπA2dkxdkykxkR(kx,ky)ej(kxx+kyy))2px2]

εx is the emittance with roughness and εD,x the value on a smooth cathode, (xR)2 is the mean square slope of the surface R along x, the primed momenta are the ones a facet emits in its own frame, j is the imaginary unit, A=eE/m carries the applied field E, 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 R(kx,ky) of that same surface, with k the length of (kx,ky).

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).

Height map of a machined copper cathode, about 170 by 130 µm, with vertical stripes a few tens of nanometres deep, and the simulated laser spot drawn on top as a round cloud of points.
The measured copper surface, with the laser spot on top.
Top: transverse phase space at the cathode and 5000 nm above it, the second one rippled by the surface. Bottom: emittance against height above the surface, rising slowly from about 4.62 to 4.83 µm·keV/c at 50 MV/m, with the analytic estimate marked at both ends.
Phase space at the surface and five microns up, and the emittance creeping up in between (triangles are the analytic estimate).

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.

Emittance growth factor against cathode surface field from 0 to 200 MV/m. The measured three-dimensional copper surface rises slowly from 1.0 to about 1.12, a two-dimensional sinusoid with matching roughness parameters lies just above it, a sinusoid with the typical fine roughness of a polished cathode (4 nm every 200 nm) a little above that, and one with the typical coarse roughness (100 nm every 16 µm) climbs to about 1.78.
Growth factor against cathode field, for the measured 3D surface and for 2D sinusoids matched to it and to the typical fine and coarse roughness of a polished cathode.

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.

Scanning electron micrograph at 10,000 times: a regular square array of small holes in silver, with fine scratches across the surface; 5 µm scale bar.
The holes under an SEM, ten thousand times.

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.

NPC Analyzer window: a camera frame with the dark patterned patch outlined, a green sampling box inside it and blue boxes around it, and on the right the file choosers, edge and line sliders, a wavelength and reflectivity table, and Export and Preview buttons.
NPC Analyzer on a real frame, with the patch's edge traced and sampling boxes inside it (green) and around it (blue).
Relative reflectivity against wavelength from 730 to 850 nm: around 0.6 at the short end, a dip to 0.45 at about 801 nm, rising past 0.8 at the long end, with a shaded analysis-error band around the points.
The spectrum, with the analysis error shaded.

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.

Two reflectivity curves for the silver cathode between 730 and 850 nm. Before the high-power test the curve dips to about 0.45 near 800 nm and climbs past 0.8 at the long-wavelength end; after the test the dip is gone and the curve stays below about 0.62 across the whole band.
The same wafer before and after the high-power run.

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.

Normalised thermal emittance against emitted charge at 50 MV/m on copper. The exact and approximate curves fall gently from 0.636 and meet the uncorrected four-ninths-field line at the space-charge limit near 222 picocoulombs, while the curve that ignores the difference between slices sits below both and keeps falling.
Bunch thermal emittance against charge, exact and approximate, the version that ignores the slice-to-slice difference and always reads low, and the uncorrected formula at four ninths of the field, which the exact one meets at the limit.

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.

εmin=123mc2ε0πQωϕwE0+13eeπε01E0

Q is the bunch charge and E0 the field at the cathode, ϕw the bare work function, since the Schottky lowering is written out as the second term under the root at four ninths of E0, which is what averaging over the slices leaves at the limit, and ε0 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.

εmin=(916πε0me)2/3ωϕw3mc2(Qτ)2/31E0

τ is the pulse length on the cathode, so what the floor tracks is the emitted current Q/τ, and the work function ϕw 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.

𝐱=𝐱+η𝐌1𝚫,η=12

𝐌 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 3.02×104 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.

One PyGAS generation: the genetic algorithm (NSGA-II or SPEA2 operators from DEAP) hands each individual to a patcher that writes its knobs into its own ASTRA input; individuals evaluated in parallel with SCOOP; the paper's runs used the LBL and Tsinghua clusters; 100% emittance and rms bunch length at the exit go back as fitness for the next generation. Below, the split S/C injector being simulated: gun, solenoid, C-band buncher and two S-band linac sections. Genetic algorithm Namelist patcher Generator + ASTRA Exit statistics NSGA-II or SPEA2 (DEAP operators) generations saved to disk one folder per individual its knobs written into the ASTRA input many at once (SCOOP) runs for the paper on LBL and Tsinghua clusters 100% emittance rms bunch length (the two objectives) fitness ranks the population, and the next generation goes out gun solenoid C-band buncher S-band linac S-band linac the split S/C injector that ASTRA simulates
One PyGAS generation, and the injector it was simulating.

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.

Scatter of 100% projected rms emittance against rms bunch length at the injector exit for three Pareto fronts: without buncher, with an X-band buncher, and with a C-band buncher; the C-band front sits lowest, and a dotted line marks 0.65 mm.
The best trade-offs the genetic optimizer found between emittance and bunch length, without a buncher and with X-band or C-band.
Slice emittance along the bunch for three cases: about 0.2 mm·mrad without a buncher, about 0.15 with the C-band buncher, and about 0.10 with the C-band buncher and a thermal emittance of 0.5 µm/mm, flat across the core and rising at both ends.
Slice emittance along the bunch, without a buncher, with C-band, and with C-band on a cooler cathode.

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.

Four spot-array frames side by side: sparse streaky spots with the expected positions marked as empty circles where spots are missing, an array split into three vertical blocks, a round array with a large bite out of its top edge, and a square array with rounded corners.
Four frames that a plain grid finder gets wrong.
Raw spot-array frame: a dense array of red spots filling an irregular, partly missing region.
A frame where the spots fill an irregular patch.
The same frame with a yellow grid traced through the detected spots, following the ragged top edge.
The grid the toolbox traced through it.

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