# Presentation: 211953

## Comparison of Linac Simulation Codes

-  S. Nath, R. Ryne, J. Stovall,  H. Takeda,
- J. Qiang, L. Young,  LANL
-  K. Crandall, TechSource
- N. Pichoff, D. Uriot,  CEA, Saclay

## PARMELA is the Most Detailed Simulation Code 

- PARM_E_LA : Phase & Radial Motion in _E_lectron Linacs
- Originally written to simulate electron beam dynamics
- now extended to simulate ion dynamics
- It does not design linacs
- Main features
- time step integration
- composite E & H fields
- 2-D & 3-D space charge
- note that 3-D space-charge requires 100k particles
- Er, Ez & H field maps computed by SUPERFISH

## PARMILA is the Design and Primary Simulation Code 

- PARM_I_LA : Phase & Radial Motion in Ion Linacs
- Initially written to design DTLs and simulate beam dynamics
- can now design integrated linacs including DTLs, CCLs, CCDTLs , SRFs & transport systems
- includes large variety of design & simulation options
- special quad & phase laws, errors, phase advance, steering, ...
- Main features
- z-based with impulse approximations
- presently uses 2-D space charge (3-D pending)
- gap transformation includes transit time integrals T, T’, S & S’
- off-axis fields derived using Bessel-function expansions
- 100k - 1M particle typical

## LINAC is a Code Similar to PARMILA

- Initially written for CCLs and CCDTLs only
- Now extended to integrated linacs including DTL, CCL, CCDTL & SRF
- Does only simulation through linacs
- Dynamics similar to PARMILA
- uses only T in CCL & SRF
- Can use either 2-D or 3-D space charge
- Includes large variety of simulation options including errors and steering

## PARTRAN is the CEA, Saclay Linac Code

- Design & simulation functions are handled in two separate codes
- Written to be compatible with PARMILA
- Dynamics i.e., gap transformation, transport through other elements are treated as in PARMILA
- radial field treated via Bessel function expansion
- Can use either 2-D or 3-D space charge
- 3 options for SRF linacs
- use field per cavity, per cell or assume a sinusoidal field
- step integration (z) through SRF axial field from SUPERFISH;
- More flexible and user friendly graphics than PARMILA
- Er, Ez & H field map (from SUPERFISH) integration (Pending)

## IMPACT Uses Parallel Computation

- IMPACT is a linac code written for “parallel mode” computation
- used for simulations only, no design
- Uses 3D space charge applied impulsively multiple times per element
- Transfers through the cell using linear transfer map
- map calculated from vector potential
- in between space-charge kicks, uses fine scale integration for computation of transfer-map for the external fields
- multipole expansion truncated at the quadratic term
- linear variation of Er and H with r
- Can run very large particle arrays (could run 108)

## Key Features of the Codes

- Five linac codes, PARMILA, PARMELA, LINAC, PARTRAN, and  IMPACT considered
- PARMELA: a t-code; all others:  z-code
- PARMELA uses time-step integration through field maps; others use impulse approximation at the electrical center
- off-axis fields derived using Bessel-function expansions
- PARMILA and PARTRAN: design and simulation, both; Others: only simulation
- IMPACT is specifically written for parallel mode computation
- can handle large array of particles i.e., 10 8
- Space-charge calculation: PARMILA: 2D (3D pending), IMPACT: 3D, All others: 2D or 3D

## Essential Differences Between  the 5 Codes

- Primary differences between the 5 codes
- speed of execution
- 2 & 3-D space-charge, minor differences in method of field calculation
- time integration vs. impulse approximation
- number of particles usable in the calculation
- characterization of gap fields
- Main difficulty
- describing exactly the same linac to each code in its unique input format

## Acceleration Across Gaps

- PARMILA, PARTRAN and LINAC, all use about the same gap impulses applied at electrical center
- off-axis fields derived using Bessel-function expansions
- PARMELA does time-step integration thro composite field-maps
- 10 X 60 [r,z] grid for half DTL cell
- integration step-size: 5 deg i.e.,72 steps through a DTL cell
- IMPACT transfers through the cell using linear transfer map
- map calculated from vector potential
- In between space-charge kicks, uses fine scale integration for computation of transfer-map for the external fields
- multipole expansion truncated at the quadratic term
- linear variation of Er and H with r

## Simulations

- 1 M particle (4D Waterbag distribution) at the entrance to the RFQ
- Use TOUTATIS to get the RFQ output beam
- Use PARMELA (with 3D space-charge); Transport the beam through the MEBT in front of the DTL
- All codes start with the same distribution
- Transport beam through the 1st Tank with different codes
- Output at the mid-point between 1st and 2nd tanks.

## SCHEFF

- The SCHEFF subroutine is widely used for applying space-charge impulses in many beam-dynamics codes
- It is a particle-in-cell (PIC) code that calculates the electric field components, *E**r*  and *E**z*, on a two-dimensional (2D) r-z grid, and interpolates these field components to get the force on each particle
- For purposes of calculating the space-charge fields, each particle is considered to be a ring of charge.  The elliptical cross section on the x-y plane is taken into account when calculating the effective radius of the rings of charge

## SCHEFF (Continued)

- The amount of charge in each rectangular box of the grid is then determined. *E**r*  and *E**z* are calculated at every node in the vicinity of the beam
- The ellipticity of the beam cross section is taken into account when applying to each particle the impulse due to *E**r*.  The x’, y’ and longitudinal energy of each particle is changed by applying the *E**r* and *E**z* for a given time or distance interval
- Relativistic corrections are made for transforming the beam coordinates from the lab frame to the beam frame and back again

## PICNIC

- The PICNIC (Particle In Cell Numerical Integration between Cube) is a full 3D code
- As in SCEFFF, it applies the space charge impulses to a beam at a given z or time
- Particles in each cube formed by the 3D grid are counted
- The field is calculated at each node of the grid as the sum of the contributions from all the grid-cubes, each of which is assumed to be uniformly populated
- The field at the position of the particle is interpolated from the neighboring nodes, allowing a calculation of space-charge impulse

## PICNIC (Continued)

- The field acting on particles outside the mesh is the one of a Gaussian beam with the same RMS dimensions as the real beam
- Relativistic corrections are made by transforming the beam-coordinates from the lab frame to the beam frame and back again
- The mesh size is adjusted to  3.5 times the RMS beam-size in all directions

## Space-charge Force

- All use PIC method
- LINAC: 3D (PICNIC); 3 space-charge kicks per cell
- PARTRAN: 3D (PICNIC); 1 kick per cell (can use any no.)
- PARMILA: 2D (SCHEFF); 1 kick per cell (can use any no.)
- PARMELA: 3D; 12 kicks per cell (can use any no.)
- IMPACT:  3D; 10 kicks per cell (can use any no.)

## Computation Time - PIC Code

- One part depends linearly on Np
- time needed to count particles in a cell (10%)
- time needed to compute field at each particle position (90%)
- Other part depends on the method  of computing field at mesh nodes i.e., Nc
- For SCHEFF,  Nc4
- For PICNIC,  Nc6  (present version about  Nc5 )
- For 1 M particle runs, with usual mesh-size choice nearly same computation time is needed for PICNIC and SCHEFF

## The Particle Distribution Developes a Halo in the MEBT

## Transverse Phase Space at Input and Output, All Codes

**Transverse Phase Space at Input and Output, All Codes**

- INPUT

- PARMELA

- PARTRAN

- PARMILA

- LINAC

- IMPACT

## Longitudinal Phase Space at Input and Output, All Codes

**Longitudinal Phase Space at Input and Output, All Codes**

- INPUT

- PARMELA

- PARTRAN

- PARMILA

- LINAC

- IMPACT

## Emittance Profiles  From 5 Codes

## Output Radial Distribution, All Codes

## IMPACT Gap Fields: Er & H are Linear in r

## Phase Space at the OutputLINAC with SCHEFF and PICNIC

**Phase Space at the Output****LINAC with SCHEFF and PICNIC**

- SCHEFF

- PICNIC

## Simulations Differ at the 10 nA Level in the Distribution but Not in the Extent

**Simulations Differ at the 10 nA Level in the Distribution but Not in the Extent**

## Small & Large Distributions Yield Consistent Results

**Small & Large Distributions Yield Consistent Results**

- 1.25 GeV
- 6-D waterbag
- SRF only , no errors

## Summary

- Good qualitative and quantitative agreement between predictions from different codes
- no gross physics and/or coding errors in the codes
- Close agreement between results with t-code (PARMELA) and z-codes
- dynamics calculation seems not to be critically dependent on this issue
- Calculations with LINAC using 2D (SCHEFF) and 3D (PICNIC) show little difference
- needs to be pursued with other codes
- Phase -space plots from IMPACT show some differences
- assumption of linear variation of Er and H with r should be   replaced.

## Comments

- What “Figure of Merit” to use ?
- R density plot , 99%, 99.9%, x,y, profile plots, phase space plots, xmax,, ymax profiles, kurtosis or a combination of them ?
- How to interpret differences quantitatively ? What percentage difference is significant ?
- need estimated confidence level on simulated prediction values
- Predictions from different codes differ in the nano-amp level. Absent experimental results, how to attach more confidence to one in preference to another ? Looking for “More Physics” is subjective and controversial.
- Need to focus on studies relevant to prediction of potential losses