-
ext-calvo_p authoredext-calvo_p authored
- 1. Field Solver
- 1.1. FFT Based Particle-Mesh (PM) Solver
- 1.1.1. FFT-based Convolutions and Zero Padding
- 1.1.2. Algorithm used in OPAL
- 1.1.3. Interpolation Schemes
- 1.2. Iterative Space Charge Solver
- 1.3. Energy Binning
- 1.4. The FIELDSOLVER Command
- 1.5. Define the Fieldsolver to be used
- 1.6. Define Domain Decomposition
- 1.7. Define Number of Grid Points
- 1.8. Define Boundary Conditions
- 1.9. Define Greens Function
- 1.10. Define Bounding Box Enlargement
- 1.11. Define Geometry
- 1.12. Define Iterative Solver
- 1.13. Define Interpolation for Boundary Points
- 1.14. Define Tolerance
- 1.15. Define Maximal Iterations
- 1.16. Define Preconditioner Behavior
- 1.17. Define the number of Energy Bins to use
- 1.18. Define AMR Solver
- 1.18.1. Hardware-Architecture Independent AMR Poisson Solver
- 1.18.2. Use of AMR
- 1.18.3. AMR Example
- 1.19. References
-
1. Field Solver
- 1.1. FFT Based Particle-Mesh (PM) Solver
- 1.2. Iterative Space Charge Solver
- 1.3. Energy Binning
- 1.4. The
FIELDSOLVER
Command - 1.5. Define the Fieldsolver to be used
- 1.6. Define Domain Decomposition
- 1.7. Define Number of Grid Points
- 1.8. Define Boundary Conditions
- 1.9. Define Greens Function
- 1.10. Define Bounding Box Enlargement
- 1.11. Define Geometry
- 1.12. Define Iterative Solver
- 1.13. Define Interpolation for Boundary Points
- 1.14. Define Tolerance
- 1.15. Define Maximal Iterations
- 1.16. Define Preconditioner Behavior
- 1.17. Define the number of Energy Bins to use
- 1.18. Define AMR Solver
- 1.19. References
1. Field Solver
Space charge effects are included in the simulation by specifying a field solver described in this chapter and attaching it to the track command as described in Chapter Tracking. By default, the code does not assume any symmetry i.e. full 3D. In the near future it is planed to implement also a slice (2D) model. This will allow the use of less numbers of macro-particles in the simulation which reduces the computational time significantly.
The space charge forces are calculated by solving the 3D Poisson equation with open boundary conditions using a standard or integrated Green function method. The image charge effects of the conducting cathode are also included using a shifted Green function method. If more than one Lorentz frame is defined, the total space charge forces are then the summation of contributions from all Lorentz frames. More details will be given in Version 2.0.0.
1.1. FFT Based Particle-Mesh (PM) Solver
The Particle-Mesh (PM) solver is one of the oldest improvements over the PP solver. Still one of the best references is the book by R.W. Hockney & J.W. Eastwood [1]. The PM solver introduces a discretization of space. The rectangular computation domain
The solution of Poisson’s equation is an essential component of any self-consistent electrostatic beam dynamics code that models the transport of intense charged particle beams in accelerators. If the bunch is small compared to the transverse size of the beam pipe, the conducting walls are usually neglected. In such cases the Hockney method may be employed [1], [2] and [3]. In that method, rather than computing
When the beam bunch fills a substantial portion of the beam pipe transversely, or when the bunch length is long compared with the pipe transverse size, the conducting boundaries cannot be ignored. Poisson solvers have been developed previously to treat a bunch of charge in an open-ended pipe with various geometries [4] , [5].
The solution of the Poisson equation,
for the scalar potential,
where
For an isolated distribution of charge this reduces to
where
A simple discretization of Convolution solution on a Cartesian grid with cell size
where
1.1.1. FFT-based Convolutions and Zero Padding
FFTs can be used to compute convolutions by appropriate zero-padding of the sequences. Discrete convolutions arise in solving the Poisson equation, and one is typically interested in the following,
where
One can zero-pad the sequences to a length
Define a periodic Green function,
Now consider the sum
where
Now use the relation
It follows that
But
In the physical (unpadded) region,
As stated above, the zero-padded sequences need to have a length
The above FFT-based approach – zero-padding the charge density array, and circular-shifting the Green function in accordance with Periodic Green function – will work in general. In addition, if the Green function is a symmetric function of its arguments, the value at the end of the Green function array (at grid point
simply by changing the direction of the Fourier transform of the Green function and changing the direction of the final Fourier transform.
1.1.2. Algorithm used in OPAL
As a result, the solution of Open brute force convolution is then given by
where the notation has been introduced that
1.2. Iterative Space Charge Solver
This is a scalable parallel solver for the Poisson equation within a Particle-In-Cell (PIC) code for the simulation of electron beams in particle accelerators of irregular shape. The problem is discretized by Finite Differences. Depending on the treatment of the Dirichlet boundary the resulting system of equations is symmetric or `mildly' non-symmetric positive definite. In all cases, the system is solved by the preconditioned conjugate gradient algorithm with smoothed aggregation (SA) based algebraic multigrid (AMG) preconditioning. More details are given in [6].
1.3. Energy Binning
The beam out of a cathode or in a plasma wake field accelerator can have a large energy spread. In this case, the static approximation using one Lorentz frame might not be sufficient. Multiple Lorentz frames can be used so that within each Lorentz frame the energy spread is small and hence the electrostatic approximation is valid. More details will be given in Version 2.0.0.
1.4. The FIELDSOLVER
Command
See Table 1 for a summary of the Fieldsolver command.
Command | Purpose |
---|---|
|
Specify a fieldsolver |
|
Specify the type of field solver: |
|
If x is distributed
among the processors |
|
If y is distributed
among the processors |
|
If z is distributed
among the processors |
|
Number of grid points in x specifying rectangular
grid |
|
Number of grid points in y specifying rectangular
grid |
|
Number of grid points in z specifying rectangular
grid |
|
Boundary condition in x [OPEN ]. (FFT + AMR_MG only) |
|
Boundary condition in y [OPEN ]. (FFT + AMR_MG only) |
|
Boundary condition in z [OPEN,PERIODIC ]. (FFT + AMR_MG only) |
|
Defines the Greens function for the FFT Solver. ( |
|
Enlargement of the bounding box in % |
|
Geometry to be used as domain boundary. ( |
|
Type of iterative solver. ( |
|
Interpolation used for boundary points. ( |
|
Tolerance for iterative solver. ( |
|
Maximum number of iterations of iterative solver. ( |
|
Behavior of the preconditioner. ( |
1.5. Define the Fieldsolver to be used
At present FFT based solver is the most stable solver. Other solvers include Finite Element solvers and a Multigrid solver with Shortley-Weller boundary conditions for irregular domains.
1.6. Define Domain Decomposition
The dimensions in
TRUE
) or serial FALSE
. The default settings are:
parallel in 1.8. Define Boundary Conditions
Two boundary conditions can be selected independently among
OPEN
and for OPEN
& PERIODIC
. In the case you select for 1.10. Define Bounding Box Enlargement
The bounding box defines a minimal rectangular domain including all
particles. With BBOXINCR
the bounding box can be enlarged by a factor
given in percent of the minimal rectangular domain. Default value is 2.0.
1.11. Define Geometry
The list of geometries defining the beam line boundary. For further details see Chapter Geometry.
1.12. Define Iterative Solver
The iterative solver for solving the preconditioned system: CG
(default),
BiCGSTAB
or GMRES
.
1.13. Define Interpolation for Boundary Points
The interpolation method for grid points near the boundary: CONSTANT
,
LINEAR
(default) or QUADRATIC
.
1.14. Define Tolerance
The tolerance for the iterative solver used by the SAAMG
solver.
Default value is 1e-8.
1.15. Define Maximal Iterations
The maximal number of iterations the iterative solver performs. Default value is 100.
1.16. Define Preconditioner Behavior
The behavior of the preconditioner can be: STD
, HIERARCHY
or
REUSE
. This argument is only relevant when using the SAAMG
solver and
should only be set if the consequences to simulation and solver are
evident. A short description is given in the
Table below.
Value | Behavior |
---|---|
|
The preconditioner is rebuilt in every time step |
|
The hierarchy (tentative prolongator) is reused (enabled by default) |
|
The preconditioner is reused |
1.17. Define the number of Energy Bins to use
Suppose
NNEIGHBB
) i.e.
The variable MINSTEPFORREBIN
defines the number of integration step
that have to pass until all energy bins are merged into one.
1.18. Define AMR Solver
After compiling OPAL with ENABLE_AMR=ON
, the option AMR=TRUE
enables further
commands to be used in the Fieldsolver command (cf. Table 3).
The current AMR interface in OPAL is based on AMReX [10] which provides the
multigrid solvers FMG
(till release 18.07) and ML
. We also provide a Trilinos based solver
which is described in the section Hardware-Architecture Independent AMR Poisson Solver.
In order to setup an AMR simulation, the user has to specify the number of AMR levels. The
hierarchy is built based on the values of the refinement ratios, blocking factors and
maximum grid sizes of the base level. The maximum grid size of the next higher level is
given by the division with the refinement ratio. The same is true for
the blocking factors. The mesh refinement follows user-dependent rules that are
provided by AMR_TAGGING
. The various mesh refinement methods are provided in
Table 4.
Command | Purpose |
---|---|
|
AMR Poisson solvers: |
|
Maximum adaptive mesh refinement level (single level if
|
|
Grid cell refinement ratio in x, only |
|
Grid cell refinement ratio in y, only |
|
Grid cell refinement ratio in z, only |
|
Maximum grid size of base level in x. It has to be smaller than
|
|
Maximum grid size of base level in y. It has to be smaller than
|
|
Maximum grid size of base level in z. It has to be smaller than
|
|
AMReX blocking factor in x. |
|
AMReX blocking factor in y. |
|
AMReX blocking factor in z. |
|
Mesh-refinement strategy [ |
|
Charge density refinement threshold when |
|
Refinement threshold for |
|
Refinement threshold for |
|
Refinement threshold for |
|
Box ratio of the AMR computation domain. It is an array of size 3. The entries define the ratio in (x, y, z) direction. For example, [1, 0.75, 0.75] yields
a computation domain of [-1, 1]\times [-0.75, 0.75]\times [-0.75, 0.75] . |
Value | Behavior |
---|---|
|
Mark each cell if \phi^{level}_{cell}\ge\alpha\max\phi^{level} , where
\alpha\in[0, 1] is the scaling factor AMR_SCALING |
|
Mark each cell if the electric field component of any direction satisfies E^{level}_{d, cell}\ge\alpha\max E_{d}^{level} , where
d=x, y, z and \alpha\in[0, 1] is the scaling
factor AMR_SCALING |
|
It performs a loop over all particles of a level and computes the dot product of the momenta. Every cell that contains a particle with ||\mathbf{p}|| \ge \alpha \max_{level} ||\mathbf{p}|| is
refined. The scalar \alpha\in[0, 1] is a user-defined
value AMR_SCALING . |
|
If the charge density of a cell is greater or equal
to the value specified with |
|
Cells with equal or more particles are
refined. The bound is specified with |
|
Cells with equal or less particles are
refined. The bound is specified with |
1.18.1. Hardware-Architecture Independent AMR Poisson Solver
This solvers is enabled with ENABLE_AMR_MG_SOLVER=ON
and requires a working
Trilinos installation with at least the following packages:
Some base level linear solvers may require additional third party libraries. These
are SUPERLU
[15], UMFPACK
[16], PARDISO_MKL
[17] [18],
MUMPS
[19] and LAPACK
[20]. A full list of the arguments
and linear solvers is given in Table 5. The solver is tested with
Trilinos version 12.14.1. The corresponding paper is [21].
Command | Purpose |
---|---|
|
The pre- and post-smoother which is either
[ |
|
The number of smoothing steps. Default: 8 |
|
The preconditioner of the bottom linear solver. Please see
[12] for further information.
[ |
|
The prolongator of the level solution to next higher level
[ |
|
The norm of the convergence criterion [ |
|
Boolean to enable/disable solver output. It writes an SDDS file.
Default: |
|
Boolean to rebalance the smoothed aggregation preconditioner or
linear solver (if |
|
Reuse type of the smoothed aggregation multigrid solver of MueLu.
Please see [14] for further information.
[ |
|
The tolerance of the solver. Default: 10^{-10} |
|
The solver of the linear system of equations on the base level.
[ |
1.18.2. Use of AMR
AMR is only available in the multi-bunch mode (cf. [sec.opalcycl.MultiBunch]) of OPAL-cycl. As soon as
more than one bunch is in the simulation, the AMR hierarchy is built. Note that AMReX handles the MPI parallelism,
hence, other Poisson solvers of OPAL (cf. FSTYPE
in Table 1) are not available.
1.18.3. AMR Example
In the example below we show an AMR simulation setup. It has a
// global options
OPTION, AMR = TRUE;
OPTION, AMR_REGRID_FREQ = 10;
OPTION, AMR_YT_DUMP_FREQ = 100000;
...
// initialize kinetic energy etc.
REAL Edes = .072;
REAL turns = 8;
REAL nstep = 360;
REAL frequency = 50.650;
...
// define the cyclotron
ring: Cyclotron, ...
rf0: RFCavity, ...
rf1: RFCavity, ...
rf2: RFCavity, ...
rf3: RFCavity, ...
rf4: RFCavity, ...
l1: Line = (ring, rf0, rf1, rf2, rf3, rf4);
// define the distribution
Dist1: DISTRIBUTION, ...
// fieldsolver command
Fs1:FIELDSOLVER, FSTYPE=AMR_MG,
MX=128, MY=128, MT=128,
PARFFTX=true, PARFFTY=true, PARFFTT=true,
BCFFTX=open, BCFFTY=open, BCFFTT=open,
BBOXINCR=20, AMR_MAXLEVEL=2,
AMR_MAXGRIDX=32, AMR_MAXGRIDY=32, AMR_MAXGRIDZ=32,
AMR_BFX=16, AMR_BFY=16, AMR_BFZ=16,
AMR_REFX=2, AMR_REFY=2, AMR_REFZ=2,
AMR_DOMAIN_RATIO={1.0, 0.75, 0.75},
AMR_TAGGING=CHARGE_DENSITY, AMR_DENSITY=1.0e-9,
AMR_MG_VERBOSE=true, AMR_MG_REBALANCE=true, AMR_MG_REUSE=FULL,
ITSOLVER=SA, AMR_MG_NORM=LINF, AMR_MG_NSWEEPS=12;
beam1: BEAM, PARTICLE=PROTON, pc=P0, NPART=1e5, BCURRENT=2.0E-3, CHARGE=1.0, BFREQ= frequency;
Select, Line=l1;
TRACK,LINE=l1, BEAM=beam1, MAXSTEPS=nstep*turns, STEPSPERTURN=nstep,TIMEINTEGRATOR="RK-4";
run, method = "CYCLOTRON-T", beam=beam1, fieldsolver=Fs1, distribution=Dist1,
MBMODE=FORCE, TURNS=11, MB_BINNING=GAMMA, MB_ETA=0.25;
endtrack;
Stop;
1.19. References
[1] R. W. Hockney, The potential calculation and some applications, Methods Comput. Phys. 9, 136–210 (1970).
[2] J. W. Eastwood and D. R. K. Brownrigg, Remarks on the solution of poisson’s equation for isolated systems, J. Comput. Phys. 32, 24–38 (1979).
[3] R. W. Hockney and J. W. Eastwood, Computer simulation using particles (Taylor & Francis Group, 1988).
[4] J. Qiang and R. Ryne, Parallel 3d poisson solver for a charged beam in a conducting pipe, Comput. Phys. Commun. 138, 18–28 (2001).
[5] J. Qiang and R. L. Gluckstern, Three-dimensional poisson solver for a charged beam with large aspect ratio in a conducting pipe, Comput. Phys. Commun. 160, 120–128 (2004).
[6] A. Adelmann, P. Arbenz, and Y. Ineichen, A fast parallel poisson solver on irregular domains applied to beam dynamic simulations, arXiv (2009).
[7] J. Qiang et al., A three-dimensional quasi-static model for high brightness beam dynamics simulation, tech. rep. LBNL-59098 (LBNL).
[8] J. Qiang et al., Three-dimensional quasi-static model for high brightness beam dynamics simulation, Phys. Rev. ST Accel. Beams 9 (2006).
[9] J. Qiang et al., Erratum: three-dimensional quasi-static model for high brightness beam dynamics simulation, Phys. Rev. ST Accel. Beams 10, 12990 (2007).
[10] W. Zhang, A. Almgren, et al., AMReX: a framework for block-structured adaptive mesh refinement, Journal of Open Source Software, 4(37):1370 (2019).
[11] C. G. Baker and M. A. Heroux, Tpetra, and the use of generic programming in scientific computing, Scientific Programming, 20(2):115–128 (2012).
[12] A. Prokopenko, C. M. Siefert, J. J. Hu, M. Hoemmen, and A. Klinvex, Ifpack2 User’s Guide 1.0, Technical Report SAND2016-5338, Sandia National Labs (2016).
[13] E. Bavier, M. Hoemmen, S. Rajamanickam, and H. Thornquist, Amesos2 and Belos: Direct and iterative solvers for large sparse linear systems, Scientific Programming, 20(3):241–255 (2012).
[14] L. Berger-Vergiat, C. A. Glusa, J. J. Hu, M. Mayr, A. Prokopenko, C. M. Siefert, R. S. Tuminaro, and T. A. Wiesner, MueLu User’s Guide, Technical Report SAND2019-0537, Sandia National Laboratories (2019).
[15] X. Li, J. Demmel, J. Gilbert, L. Grigori, M. Shao, and I. Yamazaki, SuperLU Users' Guide, Technical Report LBNL-44289, Lawrence Berkeley National Laboratory (1999).
[16] T. A. Davis, Algorithm 832: UMFPACK V4.3—an Unsymmetric-Pattern Multifrontal Method, ACM Trans. Math. Softw., 30(2):196–199 (2004).
[17] O. Schenk and K. Gärtner, Solving unsymmetric sparse systems of linear equations with PARDISO, Future Generation Computer Systems, 20(3):475–487 (2004).
[18] Developer Guide for Intel® oneAPI Math Kernel Library for Linux, last updated: February 7, 2020.
[19] P. R. Amestoy, I. S. Duff, J.-Y. L’Excellent, and J. Koster, A Fully Asynchronous Multifrontal Solver Using Distributed Dynamic Scheduling, SIAM Journal on Matrix Analysis and Applications, 23(1):15–41 (2001).
[20] E. Anderson, Z. Bai, C. Bischof, L. S. Blackford, J. Demmel, J. Dongarra, J. Du Croz, A. Greenbaum, S. Hammarling, A. McKenney, and D. Sorensen, LAPACK Users' Guide, SIAM, third edition, 1999, ISBN 978-0-89871-447-0.
[21] M. Frey, A. Adelmann, and U. Locans, On architecture and performance of adaptive mesh refinement in an electrostatics Particle-In-Cell code, Computer Physics Communications, 247:106912 (2020).