# Presentation: 530796

## SCDyn

*Paolo Pierini*INFN Milano LASA
- Paolo.Pierini@mi.infn.it

## Background: TRASCO

- TRASCO: design of a high beam power (>30 MW) SC proton linac as a driver for a subcritical system for nuclear waste transmutation
- Funded accelerator activities (TRASCO project) include the design of the driver accelerator (from source to the high energy end) and prototypical activities on the main components (source, RFQ, DTL, superconducting cavities, see **Carlo Pagani** Talk)
- Our group is involved in the TTF/TESLA collaboration since its starting phase
- Procurement of SC cavities through Italian industries
- Design, fabrication and installation of the cryostats
- Our “natural” interest is the design of the high energy SC section of the proton linac (and related prototypical activities
- The basic lattice of the SC linac is that of a periodic doublet array with cavity cryomodules in the long drifts between the warm magnets. The linac is divided in three sections

## Motivation of This Work

- After completing the linear beam dynamics design of the linac, multiparticle simulations are needed to assess the design and investigate its reliability
- A 3D space charge algorithm is needed to properly take into account the non axially symmetric nature of the beam envelopes.
- A z-dependent description of the cavity fields would allow to properly describe the dynamics in the reduced  cavities, where the field “escapes” out of the large bore at the end cells
- To simulate the SC linac, only few element types are needed: RF cavities, quadrupoles and drifts (plus RF gaps)

*On the basis of these considerations we started developing an ad-hoc code for the dynamics in the SC linac with a 3D space charge algorithm.*

- TRACE3D has been a starting point for the linear beam dynamics

## The Code - General Layout

- The F9x code is written in a modular approach for the data and program design
- Space charge calculations require knowing the position of all the particles at the same time
- advance by **phase steps **t
- checks are done for the element boundary crossing in the step  (substepping)
- t code
- Z-dependent cavity field
- 3D space charge by multigrid scheme
- Simple second order integration scheme
- Space charge is evaluated every chosen number of steps, as input to the program
- Beam matching is performed with linear design codes: Trace3D/TraceWin/DoLinac

## Integration in the RF Cavities

- Analytical field

- Off-axis expansion

- 11 doublet periods (2 cavities each) 100-190 MeV

- The on-axis cavity field profile is expressed analytically and a direct integration in the field is performed for the particles

## Different Cavity Modeling

- We used 2 different cavity models:
- RF gaps computed from the SUPERFISH files, that give exactly the right energy gain at each particle , but a different transport matrix (both longitudinally and transversally)
- A "Sine-like" equivalent field computed from SUPERFISH files, that gives approximately the same energy gain in the same  range, and a closer transport matrix to the real field
- Implemented same modeling

- Red triangles: single RF gap, Blue dots: Sine-like, Blue line: Superfish file

- Longitudinal

- Transverse

## Transit Time Equivalence

## Synchronous Phase Scan

- Doing a direct integration we need to know each cavity phase c
- For simplicity, we like to define the synchronous phase of the cavity as the relative phase at which the reference particle arrives at the center of the cavity
- This is done in a pre-processing iterative phase:
- Launch the reference particle (only) along the beamline
- Push it until the cavity mid-position, with a guess cavity phase
- If the phase tc is not equal to the desired synch, c is reset and the cavity is restarted (until convergence)
- It is a convenient way to set a large number of cavity phases, taking a few seconds for hundreds of cavities

-  =============================
-  Start  synchronous phase scan
-  At mid cavity with wt+phis= 59.90448
-  Goal for wt+phis is  60.00000 and distance is 0.9552E-01
-  Phis changed to -285.72015 and element is restarted
-  At mid cavity with wt+phis= 59.99610
-  Goal for wt+phis is  60.00000 and distance is 0.3903E-02
-  Phis changed to -285.71625 and element is restarted
-  At mid cavity with wt+phis= 59.99999
-  Goal for wt+phis is  60.00000 and distance is 0.6517E-05
-  Phis changed to -285.71608 and element is restarted
-  At mid cavity with wt+phis= 60.00000
-  Goal for wt+phis is  60.00000 and distance is 0.2663E-06
-  Element #   6, Phis changed to -285.72
- ...
-  Element # 622, Phis changed to -292.81
-  End    synchronous phase scan
-  =============================

## Choice of the Multigrid Algorithm

- Space charge evaluation is performed by solving the 3D Poisson equation in the beam rest frame
- CIC scheme used for charge density reconstruction
- Linear interpolation for force assignment on the particles
- The Poisson solver is based on a simple (almost straightforward) implementation of a multigrid scheme (V cycle and F cycle)
- Multigrid schemes are iterative schemes based on:
- Standard (and simple) relaxation techniques (weighted Jacobi or Gauss-Seidel)
- Discretization of the problem on a series of nested grids levels (obtained, for example, by step doubling)
- Relaxation is used at each grid level to eliminate the fast oscillating errors
- When convergence deteriorates (after few relaxation cycles, say 3-4) due to the presence of smooth errors, the estimate of the solution is restricted to a coarser grid, where some of the errors are no longer smooth.
- Then the solution on the coarse grid is used as a correction

## The Multigrid V-cycle (2D)

- S is the standard Gauss-Siedel (normal or red-black) smoothing algorithmR is the coarse to fine restriction operatorP is the fine to coarse prolongation operator
- Makes use of the spectral properties of the normal relaxation algorithms (very efficient with fast oscillating error components, bad for smooth components), combined with the discretization of the problem on a series of grids.

## Implementation in the Code

- V-cycling and FMV-cycling strategies are implemented
- V-cycling is preferable since it allows to use the potential map
- at the previous space charge step as a better initial guess
- (allowed 1/3 CPU time reduction in most cases)
- Restriction operator is implemented as a trilinear averaging
- (full weighting) of the 27 neighboring nodes of the fine grid
- Prolongation operator is trilinear interpolation of the coarse grid
- The smoothing operator is the gauss-seidel operator
- (no mesh ordering, which is needed for a parallel version)
*! Associates g to the nth level grid*
- G => Grid(n)
- ...
- G%U(i,j,k)= (G%U(i-1,j  ,k  ) + g%U(i+1,j  ,k  )   &
-            + G%U(i  ,j-1,k  ) + g%U(i  ,j+1,k  )   &
-            + G%U(i  ,j  ,k-1) + g%U(i  ,j  ,k+1)   &
-            - G%RHO(i,j,k)*G%Delta**2)/6.0d0

- All sorts of cycling strategies are possible

## Test Case for the Poisson Solver

- As a test case consider the potential and fields generated by a uniformly charged sphere (generated depositing a set of 10 k particles uniformly on a sphere with radius a=0.1).
- The Poisson equation is solved on a 65x65x65 cubical mesh extending from five times the sphere radius in each direction.
- Here the contour and density plots of the potential are shown in the plane z=0

## Analytical Check - Uniform Sphere

- Mesh is 653 points, extending to five times the sphere radius in each direction

- 10 k particles

- Field interpolated on the particle positions

- Mesh values for the radial field (derived from the potential values), compared with the analytical expression

## Interpolation of Er Along Circles

- The only interpolated curve that show strong asymmetries is the curve at the charge radius due to
- the square mesh
- a low order interpolation scheme (trilinear interpolation)

## Scaling with grid and particle #

- It is possible to simulate
- long beamlines with 100 k to 1 M particles

## Simulations of the TRASCO Linac

- The code has been used to simulate the Superconducting high energy end of the TRASCO linac, from 85-100 to 2000 MeV
- The rms beam emittance growth is limited to below 6% along the whole 350 m linac, for the matched case and in the absence of misalignment and errors
- Calculations with a direct (point-to-point) space charge routine give the same results (with a limited resolution on the number of particles and a higher noise)
- The beam dynamics of the 30 mA nominal current agrees noticeably with the TRACE-3D and TRACEWin beamlines that we routinely use to determine
- the matched input beam
- the quad setting for the chosen transverse phase advance behavior
- the choice of the quadrupole gradients and cavity phases at the three section interfaces (necessary for section matching)
- Very confident that the SpaceCharge-MultiGrid scheme works reliably (made some tests with Nicolas)

## Nominal Linac Beam Dynamics (1 GeV TRASCO linac)

- Beam Emittances

- Control of the particle distribution

**From: ****	**EPAC 2000
- 	Vienna, June 2000

## Beam Envelopes

- Transverse rms envelopes (red=x, blue=y) [mm]

- Longitudinal rms envelopes[deg]

## Emittance Growth

- gxy [mm mrad]

- z [deg MeV]

- nxy [mm mrad]

- Ek [MeV]

## Phase advances

- In this case: zero current matched beam from **Trace3D**

**Trace3D** <I> 20 mA beam

**SCDyn**, numerically computed <I> 20 mA beam

## Tune depression & Tune ratio

## Beam Size Fractions

**Beam Size Fractions**

- 90%

- 99%

- 99.9%

- 99.99%

- x /xrms

- t /trms

- y /yrms

- z /zrms

## Emittance Fractions

**Emittance Fractions**

- rms

- 90%

- 100%

- ny [mm mrad]

- nx [mm mrad]

- z [deg MeV]

## General Linac Design & Matching

**Collected all “rules” used to constrain the linac design in a single tool**
**Choices of cavity parameters**
- RF Frequency
-  values
- Determined mainly by the machine energy range and number of sections
- Number of cells
- Determined by efficient use
- How many cavities per cryomodule?
- Many: good use of space (beware of too much acceleration in one lattice cell!)
- Few: waste of space
**Cavity design provides constraints:**
- Max B surface field (and Bpeak/Eacc)
- Max E surface field (and Epeak/Eacc)
**Longitudinal beam dynamics constraints:**
- Longitudinal phase advances
- Longitudinal focussing (synch. phase)
**Beamline space inventory**

## DoLinac: Design & Matching

- Wrote a code for D & M:
- (with linear space charge forces, as Trace3D)
- Cavity design + Limits on z
- Long. Phase advance law
- Choose (GUI, as TraceWin) a transverse phase advance shape
- Quad field settings
- Adiabatic matching within each section
- Matching at section interface

- Transverse Phase Advance Shaping

- Setting of quadrupoles

- Matching along each section

- Matching between sections

## DoLinac (INFN, PP&MN) builds linac from simple rules, with control of longitudinal and transverse phase advances

**DoLinac **(INFN, PP&MN) builds linac from simple rules, with control of longitudinal and transverse phase advances

**TraceWin** (CEA, Uriot & Pichoff)Longitudinal plane in inputLattice cell (Maille) based, very convenient to useVery elaborate matching with great control over the transverse phase advance lawsCan directly give input and control multiparticle simulations with different codes

**TRACE3D** (originally by LANL)Standard beam optics codeAwkward to use in this context, since it ignores the lattice periodicityDifficult to implement transverse phase advance laws as TraceWin (so the two codes need to “talk”)

**Linac design life cycle 1/2**

**From: ****	**Workshop on R&D on SC Proton Linac
- 	Saclay, October 19-20, 2000

## Linac design life cycle 2/2

**Linac design ****life cycle 2/2**

**PARMILA/****(PARTRAN?)**(CEA/Pichoff) 2D(scheff)/3D(PICNIC) space charge routinesError studiesz-dependent“Standard” code

**SCDyn **(INFN/PP) Multigrid space charge codeCavities as on-axis “sin”-like fieldt-dependent

**Code Comparisons** 	INFN/CEA/IN2P3 Meeting
- (by NP)		Saclay, Oct 18-19, 1999

**From: ****	**Workshop on R&D on SC Proton Linac
- 	Saclay, October 19-20, 2000

## Multigrid Solver Is a PRIVATE MODULE With PUBLIC Interfaces

- Type **GRID_STRUCTURE**
-      Real (Kind=8), Pointer, Dimension(:,:,:) :: U, Rho, EPS
-      Real (Kind=8) :: Delta
-      Real (Kind=8), Dimension(1:3) :: Xi
-      Integer :: NPT
-   End Type **GRID_STRUCTURE**
- Type (**GRID_STRUCTURE**), Dimension(:), Allocatable, Target :: Grid *! Array storing all grids*
*! Ng is the number of grid levels in the structure*
*! Presmooth and postsmooth are the pre-post-smoothing cycles*
- Integer, **PRIVATE** :: NG,PRESMOOTH,POSTSMOOTH,MAXIT,NVCYCLES
- Real (Kind=8), **PRIVATE** :: EPS    *! eps is the desired convergence ratio*
- Real (Kind=8), Dimension(3), **PRIVATE** :: LOW,HIGH *! low and high are the grid ranges*
**Private** :: Grid, **GRID_STRUCTURE**
**PRIVATE** :: Restrict,Prolongate,Correct,Gauss_Siedel,                    &
-            Evaluate_Residual,Evaluate_Norm,Zero_Solution, Direct_Solve
**PUBLIC**  :: Grid_Allocation,Grid_Deallocation,Load_Source,               &
-            Evaluate_Residual_Norm,Refresh_Solver,                       &
-            Gridpoints,Stepsizes,Potential,Potential_Matrix,Fields,      &
-            Field_Matrix,Total_Charge,VCycle,FVcycle,                    &
-            Set_Smoothing,Set_Max_Iterations,Set_Vcycles,                &
-            Set_Precision,Set_Grid_Range,                                &
-            Interpolate,Interpolate_Fields