Setting up field solvers

Registering solvers

Various field solvers can be setup and registered into Warp. For example:

solver = MultiGrid3D()

registersolver(solver)

before the call to generate() sets up a 3D multi-grid field solver. Similarly, for the 3-D multi-grid solver with mesh refinement:

solver = MRBlock3D()

solver.addchild(mins=...,maxs=...)

registersolver(solver)

See mesh refinement for details on setting up multigrid fieldsolvers with mesh refinement. Mesh refinement allows use of higher resolution regions in the mesh so that zones can be placed where they are most needed. This can result in substantial computational savings -- particularly in 3D field solvers.

For the multigrid solvers, there are various parameters that can be used to control the operation of the solver. These are described in the group Multigrid3d which is listed in the file f3d.v. These parameters can be set explicitly before hand or set via argument list parameters when setting up the field solver. Argument list parameters are described in the example above by doc(MultiGrid3D). If conducting objects are loaded on the mesh as described in conducting objects, this should be done after registersolver() is called and before the call to generate().

The solver instance has useful attributes and methods. For example:

print solver.dx, solver.xmmin,solver.xmmax

prints the increment (dx), max (xmmin), and min (xmmax) values of the x-mesh used by the solver. To plot contours of the potential in the z-x plane:

solver.pfzx()

Available field solvers include:

MultiGrid3D() # multi-grid Poisson solver in 3-D geometry

MultiGrid2D() # multi-grid Poisson solver in 2-D x-z or r-z geometry

MultiGridRZ() # multi-grid Poisson solver in 2-D r-z geometry

MRBlock3D() # multi-grid Poisson solver in 3-D geometry with mesh refinement

MRblock2D() # multi-grid Poisson solver in 2-D geometry with mesh refinement

MultiGridImplicit3D() # multi-grid implicit Poisson solver in 3-D geometry

MultiGridImplicit2D() # multi-grid implicit Poisson solver in 2-D geometry

MultiGrid2DDielectric() # multi-grid Poisson solver in 3-D with variable dielectric constant (does not work in parallel)

EM3D() # electro-magnetic solver in 3-D

All these solvers work with a wide variety of conducting objects loaded on the mesh. All except the MultiGrid2DDielectric() solver work in parallel. In most of these solvers conductors are placed on the mesh with subgrid resolution. Numerous parameters can be set to control the numerical convergence of the solution.

Fast Fourier transform and various other non-registered solvers

A separate method is used to set up the FFT field solver and several other solverse, via the variable top.fstype. The FFT solver is the default Warp field solver if one if the above solvers is not registered. It is turned on when top.fstype=0 (default value). When there are no internal boundary conditions, the FFT solver is faster than multigrid solvers. However, it is more constrained, requiring that the number of grid cells in each dimension must be a power of 2 for efficient operation. Mesh refinement also does not work with the FFT based solvers. There are also capacity matrix/FFT solvers that augment the FFT method to handle internal boundary conditions. However, except for simple boundaries, these tend to be slower and more difficult to work with than the multigrid solvers described above. These field solvers are chosen by setting top.fstype and setting various parameters described in top.v. Relevant settings of fstype to use these solvers include:

-1: No field solver

0: sine-sine-periodic FFT (default).

1: 8-fold symmetric capacity matrix in kz space.

2: Capacity matrix for quadrupoles.

3: Not used.

4: 2D sine-sine FFT + tridiag in z. This is somewhat faster than

the FFT solver but has Dirichlet boundaries in z.

5: General capacity matrix in kz space (special purpose solver -- only be used with good reason).

6: General capacity matrix (special purpose solver -- only be used with good reason).

7: Multigrid solver.

8: Parallel solver (in development, don't use).

9: Parallel solver (in development, don't use).

10: RZ multigrid solver (autoset using solvergeom).

11: Chombo AMR/multigrid solver (in development, don't use).

12: Use field solver registered in python (autoset by registersolver).

13: 3D multigrid with Boltzmann electrons (autoset when electrontemperature is set).

No field solver and/or simulations without beam self-fields

Simulations with no field solver can be useful to model a beam evolving without self-field effects, i.e., as a collection of non-interacting single particles evolving in the applied fields of the lattice. In situations where all applied fields are defined in terms of lattice elements, this is easily accomplished by setting

top.fstype = -1

Then if no field solvers are subsequently registered, no field solves will be done, and the only fields will be the applied fields of specified lattice elements.

In some cases, applied fields are generated by biased conducting elements placed on the mesh and it is desired to include these applied fields but not beam self fields. We now outline how to accomplish this first for fixed grid simulations as might be carried out to model an injector with biased conductors loaded on the mesh. Assuming a field solver is registered with say:

solver = MultiGrid3D()

registersolver(solver)

then

solver.ldosolve = False

can be set to turn off the field solver and deposition of the beam on the mesh. Any field values on the mesh when solver.ldosolve = False is set will still be applied in subsequent calls to step(). This procedure is carried out as follows. The problem is setup and biased conductors are loaded on the mesh, generate() is called with no beam present which makes an initial field solve generating the applied field values on the mesh, and then solver.ldosolve = False is set prior to generating/advancing the beam on the fixed mesh. Potentials employed will then be consistent with the biased conductors on the mesh in the absence of beam self-fields.

Simulations including applied electrostatic fields generated by conducting structures but without self fields can also be carried out using egrd or pgrd lattice elements. Follow the model that is used in the function addgriddedgap() in lattice.py, setting up a conductor geometry in a separate field solver and then saving the solution as a lattice element. Turn off the field solver and deposition.