Episode twelve, and a change of pace. Almost no new tabs today. This one is about the physics that makes intense linacs hard: space charge. Every particle in the bunch repels every other, and most of what is difficult about machines like PIP two traces back to this force. Today we measure it, on camera.
The essentials. Space charge is the collective Coulomb repulsion of the bunch, a defocusing lens in every plane. Its strength is the generalised perveance: current over beta cubed gamma cubed. At low energy the beta cubed bites, slow particles are dense along the line and easy to deflect. Near the speed of light magnetic attraction cancels electric repulsion. So the source, the R F Q and the M E B T are where space charge rules. We measure that law shortly.
The particle in cell cycle from the manual, one F one press from the G U I. Boost into the bunch rest frame, set up the grid, deposit the charge, solve Poisson with a doubled grid F F T and the integrated Green function, gather, kick, boost back. The reference particle is never touched. Each macroparticle carries a fixed share of the current, so the field scales with the surviving current. It is the Qiang two thousand and six algorithm, the kernel OPAL and Cheetah use. Below the figure, the three F F T backends: C P U and CUDA in double precision, Apple's Metal G P U in single.
The knobs. Base step two is the kick cadence, fifty space charge kicks per metre. Grid forty eight cubed and extent seven sigma set the Poisson box. P I C backend: auto means CUDA when present, otherwise the C P U, never the single precision Apple G P U unless you ask for M P S. S C engine numpy is production; torch is the differentiable P I C behind gradient matching, bunched beams only. Green's function stays on I G F; point only reproduces legacy runs. Cloud in cell is the kernel; T S C costs three times more. Adaptive grid mode is for transport lines where the bunch outgrows its box. The D C kernel row comes later.
The experiment. Episode one's matched F O D O at one M e V with a realistic bunch: ten degrees long, three k e V of energy spread. The Param Study manager scanned the current from zero to fifteen milliamps. This is the Overlay view: it pre selects three runs and redraws only on Draw, so we select all four and press it. At zero current the matched beam breathes gently. At five milliamps it peaks twenty four percent bigger. At ten, forty five. At fifteen, sixty seven percent. Matched at zero, badly mismatched at fifteen.
The energy law, measured. Same lattice, fifteen milliamps against zero, the beam matched at zero current for each energy, so within each pair the only difference is space charge. One M e V: the loaded beam peaks sixty seven percent above the unloaded one. Three M e V: thirty percent. Ten M e V: seven percent. Beta gamma squared grows tenfold from one to ten M e V, and the excess swell falls almost exactly tenfold. That is why linacs spend their space charge budget at the front end.
The standard measure is the tune depression, eta: the phase advance the beam accumulates over what it would with no current, per cell. This beam was matched at five milliamps with the space charge aware matcher, so no mismatch warning. The Period combo locked onto the auto detected four cell period; Recompute redraws. Green squares are the model, from the depressed channel maps; amber circles the beam, TraceWin's integrated one over beta ratio, valid only when matched. The model sits at 0.71 in the first cell and climbs to 0.83 by the fourth: no R F, so the bunch lengthens and the force fades. Eta z falls from 0.95 to 0.58.
Every particle sits at a different amplitude, so every particle has its own tune. The footprint popup tracks an amplitude ladder repeatedly through one cell with the space charge field frozen from the first pass and takes each tune with an F F T. Turns sets the resolution, one hundred twenty eight is about two point eight degrees; Particles sets the ladder. Our F O D O is too weakly focused for this tool above two milliamps, so here is the shipped Hofmann demo linac, five milliamps, a bare cell of forty point two degrees. Compute footprint. Core tunes near eleven degrees, the deepest depression at the smallest amplitude, and the cloud stretches up towards thirty five degrees as the amplitude grows.
One level deeper. When both planes are loaded, energy can flow between them through parametric resonances, and the Hofmann stability chart maps where. It is strict about its assumptions, so ask it. Compute chart on the F O D O: no finite longitudinal channel tune in any cell, the chart coordinate R is undefined. No R F, no chart.
The demo linac's fourth section, six solenoid cells. The caption already says transverse equals mode two: coupled normal modes. Compute chart, and it refuses again: an x y coupled lattice's tunes are normal modes one and two, not Hofmann's x and z planes, refusing rather than mislabelling a mode as x. A tool that knows its limits is worth more than one that always draws something.
Back to section A, sixteen quadrupole cells, uncoupled and periodic. Chart steps trades resolution for solver time; one hundred took about three seconds here. Compute chart. The background is the computed growth rate from the corrected anisotropic K V dispersion relations, ported bitwise from the published solver. One dot per cell. Green: valid and stable. Red: flagged, growth above one percent inside the perturbative gate. Grey hollow: outside the gate. Amber ring: fold risk. One of thirteen valid cells is flagged. Legacy bands overlays the old heuristic, qualitative only. P unstable adds a Monte Carlo probability per cell under an engineering jitter budget. Recompute: maximum probability 0.96. That flag is not a fluke.
Does the chart predict reality? HELIX ships a validation pair: two one hundred and fifty cell channels with the same twenty milliamp beam. The resonant one, left, sits on the l equals two coupling band, every cell flagged. The control, right, has quadrupoles ten percent stiffer, off the band, no cell flagged. Both tracked with the full particle in cell solver, twenty thousand particles. On the resonant channel the longitudinal emittance, bottom panel, dips eighteen percent within the first twenty cells while the transverse emittances jump fifty percent, energy exchanged, not created; it then self detunes and settles at plus thirty eight and minus nine percent. The control shows one short transient and its longitudinal emittance ends within one and a half percent of where it started.
The honesty check. The same matched F O D O, five milliamps, ten thousand particles, tracked both ways. Control R runs the envelope, control shift R the particles. This is the particle run's R M S popup with Show aperture on: the bore squashes the beam into a ribbon. Untick it and the plot rescales. Show lattice adds the element strip; Display can switch to dispersion corrected sizes.
Particles left, envelope right, same transverse axes. Along the whole line the sigmas agree to better than one percent, the particle run's own shot noise. That licenses the fast model for everyday work and matching. When they disagree, as in the overloaded D T L of the Results episode, believe the particles.
What the envelope cannot see. The shipped halo benchmark: twenty four F O D O cells, H minus at two point one M e V, five milliamps, matched with space charge and then deliberately mismatched forty percent in both planes. A mismatched beam under space charge pumps particles outward through the resonance between core oscillation and single particle motion. Colour the phase space by transverse radius and the halo skirt separates from the core in every panel.
The halo popup tracks H, the kurtosis measure: zero is a uniform core, the dashed line at two a Gaussian. Matched, left: H x stays near 1.4, never above 1.6, emittance growth two percent. Mismatched, right: H x climbs past 2.2, peaking at 2.6, H y past three, and the R M S emittance grows thirty eight percent. Same lattice, same current, twenty thousand particles each. Transmission claims need particles, not sigmas.
Cloud in cell versus T S C. Cloud in cell spreads each particle to eight grid corners, T S C to twenty seven cells at three times the cost. With R F cavities the restoring force damps grid noise, so cloud in cell is the default. On long R F free transport its self force aliasing accumulates: on the PIP two transfer line the manual measured longitudinal emittance times fourteen with cloud in cell, times one point six with T S C, against TraceWin's one point seven. On the halo benchmark we just ran the two kernels agree within four percent, so that growth is not the kernel. Green's function: I G F always; point only reproduces legacy runs.
Before the R F Q there are no bunches. On the Beam tab, tick Continuous beam: the longitudinal Twiss greys out, D C delta W enables, and Periodic phase un greys. Periodic phase is for a D C beam an R F Q then bunches: the simulation seeds one R F period, space charge pushes particles across the bucket boundary, and folding the phase into one bunch spacing, the Toutatis convention, keeps the solver looking at one compact bunch instead of a three bucket clump. Not invertible, so backtracking refuses it, and it cannot combine with C S R.
Two continuous beam choices live in Numerics. The D C S C kernel: uniform is the analytic linear kick that matches the envelope, gaussian the Bassetti Erskine field, pic two d a two dimensional P I C over the actual particles, TraceWin's PICNIC two D analogue. And the envelope solver can switch from matrix to sacherer, the coupled K V envelope equation, for accelerator free low energy lines.
A continuous beam ionises the residual gas and traps the compensating charge, partly neutralising its own space charge. The shipped S C C demo: thirty k e V H minus, two solenoids, fifteen milliamps, D C envelope with substeps recorded. Gas set to nitrogen, eight times ten to the minus six millibar on the log slider, three hundred kelvin. Computed mode solves the Poisson Boltzmann balance; Assumed takes your eta. Compute: neutralisation along the line, complete in the middle and tapered at the ends, mean 0.76; the on axis potential, three hundred volts deep; the build up time constant, eleven point six microseconds; gas survival, ninety four percent. Set t to ten microseconds and Compute: still building, mean 0.44. Raise the pressure tenfold: the time constant drops to one point two microseconds, but survival falls to fifty five percent. Back at base pressure, Iterate re runs the envelope with damped compensation cards until they stop moving: self consistent in three iterations. Export cards and Apply to lattice write real space charge comp cards; the cleared region row models a chopper sweeping the ions out. The cross section calibration is inherited from a measured machine, not literature, as the manual discloses.
The relative: coherent synchrotron radiation. In a bend, radiation from the tail overtakes the head along the chord and acts back on the bunch. HELIX applies the one dimensional steady state wake per sub step inside every dipole, multi particle only, because the wake needs the actual line density. Under Collective effects, off by default. Tick it.
The shipped six bend chicane, eight hundred M e V H minus, twenty thousand particles, run twice: C S R off left, on right, momentum spread along s rising from four point one to five point seven times ten to the minus five in both. Indistinguishable. The exit energy spread is seventy one point two k e V without and seventy one point three with, a two tenths of a percent effect, the right answer for a heavy ion bunch at this energy. Steady state only: entrance and exit transients are not modelled.
Against the industry reference. Every space charge path is benchmarked against TraceWin partran on the PIP two sections: per section sigmas within about three percent at five milliamps, and over the full two hundred fifty six metre linac 8.6 percent R M S in x and 13.3 in y, within the noise of five thousand particle runs. A three percent P I C calibration offset is known and stable: expect it, do not chase it. One trap: HELIX reports sigma phi at the local cavity frequency, TraceWin at the fixed bunch frequency, up to four times apart at six hundred fifty megahertz for the same bunch length. The Compare with TraceWin partran card overlays your run on a genuine export.
That is space charge: measured on the current scan and the energy law, read in the tune depression and the footprint, refused honestly and then charted by Hofmann, proven by an emittance exchange the chart predicted, checked particles against envelope, caught in a halo, compensated in a L E B T, and joined by its relative in a bend. Still to come, the special one: the voice assistant inside HELIX. See you there.