Electrostatic solver

Here, we discuss the discretization of the equation

(7)\[\nabla\cdot\left(\epsilon_r\nabla\Phi\right) = -\frac{\rho}{\epsilon_0}\]

where \(\Phi\) is the electric potential, \(\rho\) is the space charge density, and \(\epsilon_0\) is the vacuum permittivity. The relative permittivity is \(\epsilon_r = \epsilon_r\left(\mathbf{x}\right)\) and can additionally be discontinuous at gas-dielectric interfaces.

Note

All current electrostatic field solvers solve for the potential at the cell center (not the cell centroid). The code for the electrostatics solver is given in /Source/Electrostatics and /Source/Elliptic.

FieldSolver

FieldSolver is an abstract class for electrostatic solves in an EB context and contains most routines required for setting up and solving electrostatic problems. FieldSolver can solve over three phases, gas, dielectric, and electrode, and thus it uses MFAMRCellData functionality where data is defined over multiple phases (see Mesh data).

Note that in order to separate the electrostatic solver interface from the implementation, FieldSolver is a pure class without knowledge of numerical discretizations. There are two subclasses, which discretize the problem in the same way but solve it differently: FieldSolverGMG solves it with geometric multigrid, and FieldSolverAMG assembles it as a matrix and solves it with algebraic multigrid from PETSc. FieldSolverMG combines the two: it solves with geometric multigrid, and falls back to algebraic multigrid when that fails. It is the default field solver of the time steppers in /Physics.

Tip

See the FieldSolver C++ API for the complete interface.

On gas-dielectric interfaces we enforce an extra equation

(8)\[\epsilon_1\partial_{n_1}\Phi + \epsilon_2\partial_{n_2}\Phi = \sigma/\epsilon_0\]

where \(\mathbf{n}_1 = -\mathbf{n}_2\) are the normal vectors pointing away from interface, and \(\sigma\) is the surface charge density.

We point out that this equation can be enforced in various formats. The most common case is that \(\partial_n\Phi\) are free parameters and \(\sigma\) is a fixed parameter. However, we can also fix \(\partial_n\Phi\) on one side of the boundary and let \(\sigma\) be the free parameter. When using FieldSolverGMG (see FieldSolverGMG), users can choose between these two natural boundary conditions, see EB boundary conditions.

Using FieldSolver

Using the FieldSolver is usually straightforward by first constructing the solver and then parsing the class options. This usually involves several steps, such as instantiating the solver and providing proper references to AmrMesh and the computational geometry. In addition, the user must set up a voltage curve and associated boundary conditions.

Tip

A complete example of setting up electrostatic problems and solving them is given in Electrostatics model.

Setting the voltage

The function signature for setting the voltage on various parts is

/**
 * @brief Set potential dependence in time.
 * @param[in] a_voltage Function pointer which sets the voltage travel curve.
 * @details If you want something more complex, the voltage can be set individually for each electrode using
 * setElectrodeDirichletFunction.
 */
virtual void

This allows setting a time-dependent voltage on electrodes and domain boundaries. As shown above, one can easily use std::function<Real(const Real)> or lambdas to set the voltage. It is relatively straightforward to turn tabulated data (see LookupTable1D) into lambda functions. A simple example that returns a linearly varying voltage is given below:

FieldSolver* fieldSolver;

Real myVoltage = [] (const Real a_time) -> Real {
   return 1.0*a_time;
};

fieldSolver->setVoltage(myVoltage);

Domain boundary conditions

Domain boundary conditions for the solver must be set by the user through an input script, whereas the boundary conditions on internal surfaces are Dirichlet by default. Note that on multifluid-boundaries the boundary condition is enforced by the conventional matching boundary condition that follows from Gauss’ law.

General format

The most general form of setting domain boundary conditions for FieldSolver is to specify a boundary condition type (e.g., Dirichlet) together with a function specifying the value. Domain boundary condition types are parsed through a member function FieldSolver::parseDomainBc. This function will read string identifiers from the input script, and these identifiers are either in the format <string> <float> (simplified format) or in the format <string> (general format). For setting general types of Neumann or Dirichlet BCs on the domain sides, one will specify

FieldSolverGMG.bc.x.low  = dirichlet_custom
FieldSolverGMG.bc.x.high = dirichlet_neumann

Unfortunately, due to the many degrees of freedom in setting domain boundary conditions, the procedure is a bit convoluted. We first explain the general procedure.

FieldSolver will always set individual space-time functions on each domain side, and these functions are always in the form

std::function<Real(const RealVect a_position, const Real a_time)> bcFunction;

To set a domain boundary condition function on a side, one can use the following member function:

void FieldSolver::setDomainSideBcFunction(const int a_dir,
                                          const Side::LoHiSide a_side,
                                          const std::function<Real(const RealVect a_position, const Real a_time)>);

For a general way of setting the function value on the domain side, one will use the above function together with an identifier dirichlet_custom or neumann_custom in the input script. This identifier simply tells FieldSolver to use that function to either specify \(\Phi\) or \(\partial_n\Phi\) on the boundary. These functions are then directly processed by the numerical discretizations.

Note

On construction, FieldSolver will set all the domain boundary condition functions to a constant of one (because the functions need to be populated).

Simplified format

FieldSolver also supports a simplified method of setting the domain boundary conditions, in which case the user will specify Neumann or Dirichlet values (rather than functions) for each domain side. These values are usually, but not necessarily, constant values.

In this case one will use an identifier <string> <float> in the input script, like so:

FieldSolverGMG.bc.x.low  = neumann   0.0
FieldSolverGMG.bc.x.high = dirichlet 1.0

The floating point number has a slightly different interpretation for the two types of BCs. Moreover, when using the simplified format the function specified through setDomainSideBcFunction will be used as a multiplier rather than being parsed directly into the numerical discretization. Although this may seem more involved, this procedure is usually easier to use when setting constant Neumann/Dirichlet values on the domain boundaries. It also automatically provides a link between a specified voltage wave form and the boundary conditions (unlike the general format, where the user must supply that link themselves).

Dirichlet

When using simplified parsing of Dirichlet domain BCs, FieldSolver will generate and parse a different function into the discretizations. This function is not the same function as that which is parsed through setDomainSideBcFunction. In C++ pseudo-code, this function is in the format

Real dirichletFraction;

auto f = [&func, ...](const RealVect a_pos, const Real a_time) -> Real {
   return func(a_pos, a_time) * voltage(a_time) * dirichletFraction;
};

where voltage is the voltage wave form specified through FieldSolver::setVoltage, and dirichletFraction is a placeholder for the floating point number specified in the input script, i.e. the floating point number in the input option. For Dirichlet boundary conditions the solver will always multiply the provided input function by the voltage waveform. That is, the function func(a_pos, a_time) is the space-time function set through setDomainSideBcFunction. Recall that, by default, this function is set to one so that the default voltage that is parsed into the numerical discretization is simply the specified voltage multiplied by the specified fraction in the input script. For example, using

FieldSolverGMG.bc.y.low  = dirichlet 0.0
FieldSolverGMG.bc.y.high = dirichlet 1.0

will set the voltage on the lower y-plane to ground and the voltage on the upper y-plane to the live voltage. Specifically, on the upper y-plane this specification will generate a potential boundary condition function of the type

auto func = [](const RealVect a_pos, const Real a_time) {return 1.0};
dirichletFraction = 1.0;

auto bc = [func](const RealVect a_pos, const Real a_time) {
   return func(a_pos, a_time) * voltage(a_time) * dirichletFraction;
};

In order to set the voltage on the domain side to also be spatially dependent, one can either use dirichlet_custom as an input option, or dirichlet <float> and set a different multiplier on the domain edge (face). As an example. by specifying bc.y.high = dirichlet 1.234 in the input script AND setting the multiplier on the wall as follows:

auto wallFunc = [](const RealVect a_pos, const Real a_time) -> Real {
   return 1.0 - a_pos[1];
};

fieldSolver->setDomainSideBcFunction(1, Side::Hi, wallFunc);

we end up with a voltage of

\[V(\mathbf{x},t) = 1.234(1-y)V(t)\]

on the upper y-plane.

Neumann

When using simplified parsing of Neumann boundary conditions, the procedure is precisely like that for Dirichlet boundary conditions except that multiplication by the voltage wave form is not made. I.e. the boundary condition function that is passed into the numerical discretization is

Real neumannFraction;

auto func = [&func, ...](const RealVect a_pos, const Real a_time) -> Real {
   return func(a_pos, a_time) * neumannFraction;
};

Note that since func is initialized to one, the floating point number in the input option directly specifies the value of \(\partial_n\Phi\).

File-based boundary conditions

FieldSolver also supports loading spatially-varying domain boundary conditions from a data file, using the file keyword in the input script. The general format is

FieldSolverGMG.bc.x.low = file <dirichlet|neumann> <path> <arg4> <multiplier>

where <path> is the path to the data file, <multiplier> is a real-valued scale factor applied to the interpolated result, and <arg4> depends on the spatial dimension:

  • 2D: <arg4> is an integer specifying the number of uniformly-spaced interpolation points used to prepare the lookup table. The file must be an ASCII column file readable by DataParser::simpleFileReadASCII(). The boundary condition value is interpolated along the single tangential direction of the domain side.

    Example:

    FieldSolverGMG.bc.y.low = file dirichlet /path/to/data.txt 100 1.0
    
  • 3D: <arg4> is a string naming the per-vertex scalar property in a PLY or VTK triangle mesh file (see Data parsing). The mesh is loaded into a TriangleCollection; for each boundary point the closest triangle is found, the point is projected onto the triangle plane, and the vertex metadata is interpolated using barycentric coordinates.

    Example:

    FieldSolverGMG.bc.y.low = file dirichlet /path/to/mesh.ply scalarprop 1.0
    

The resulting boundary condition value applied in both cases follows the same convention as the simplified format:

  • Dirichlet: interpolated_value × voltage(t) × multiplier

  • Neumann: interpolated_value × multiplier

Note

The PLY/VTK mesh used for 3D file-based BCs does not need to coincide with the domain boundary face — it only needs to cover the spatial extent of the boundary, since the closest-triangle lookup is used. If a named per-vertex scalar is not found in the mesh file, a warning is issued and all vertex data defaults to zero.

Radial file-based boundary conditions

For problems with axisymmetric boundary data, FieldSolver supports a file_radial keyword. In this case, the boundary condition value is tabulated as a function of the in-plane radial distance from the axis normal to the face:

  • z-face: \(r = \sqrt{x^2 + y^2}\)

  • y-face: \(r = \sqrt{x^2 + z^2}\)

  • x-face: \(r = \sqrt{y^2 + z^2}\)

The format is:

FieldSolverGMG.bc.z.hi = file_radial <dirichlet|neumann> <path> <numPoints> <multiplier>

where

  • <path> is the path to a two-column ASCII file where the first column is the radial distance \(r\) and the second column is the BC value. The file is read with DataParser::simpleFileReadASCII().

  • <numPoints> is an integer specifying the number of uniformly-spaced interpolation points for the prepared lookup table.

  • <multiplier> is a real-valued scale factor.

The resulting BC value follows the same convention as the simplified format:

  • Dirichlet: interpolated_value × voltage(t) × multiplier

  • Neumann: interpolated_value × multiplier

Example — Gaussian potential profile on the upper z-face:

FieldSolverGMG.bc.z.hi = file_radial dirichlet /path/to/radial_profile.txt 200 1.0

where radial_profile.txt contains two columns: r and value(r).

Note

In 2D, file_radial uses \(r = |p_{\perp}|\) where \(p_\perp\) is the single tangential coordinate, making it equivalent to looking up by the absolute tangential distance.

EB boundary conditions

Electrodes

For the current FieldSolver the natural BC at the EB is Dirichlet with a specified voltage, whereas on dielectrics we enforce Eq. 8. The voltage on the electrodes are automatically retrieved from the specified voltages on the electrodes in the geometry being used (see ComputationalGeometry). The exception to this is that while ComputationalGeometry specifies that an electrode will be at some fraction of a specified voltage, FieldSolverGMG uses this fraction and the specified voltage wave form in setVoltage.

To understand how the voltage on the electrode is being set, we first remark that our implementation uses a completely general specification of the voltage on each electrode in both space and time. This voltage has the form

\[V_i = V_i\left(\mathbf{x}, t\right).\]

where \(V_i\) is the voltage on electrode \(i\). It is possible to interact with this function directly, going through all electrodes and setting the electrode to be spatially and temporally varying. The member function that does this is

/**
 * @brief Set embedded boundary Dirichlet function on a specific electrode.
 * @param[in] a_electrode electrode index. Follows the same order as ComputationalGeometry.
 * @param[in] a_function  Voltage on the electrode.
 */
virtual void

Here, the type ElectrostaticEbBc::BcFunction is just an alias of std::function<Real(const RealVect a_position, const Real a_time)>. The voltage on an electrode \(i\) could thus be set as

int electrode;

auto myElectrodeVoltage = [](const RealVect a_position, const Real a_time) -> Real{
    return 1.0;
};

fieldSolver->setElectrodeDirichletFunction(electrode, myElectrodeVoltage);

where the return value can be replaced by the user function. In principle, one can then also set spatially varying voltages along an electrode.

In the majority of cases the voltage on electrodes is either a live voltage or ground. Thus, although the above format is a general way of setting the voltage individually on each electrode (in both space and time) FieldSolver supports a simpler way of generating these voltage waveforms. When FieldSolver is instantiated, it will internally generate these functions through simplified expression such that the user only needs to set a single wave form that applies to all electrodes. The voltages that are set on the various electrodes are thus in the form:

int electrode;
Real voltageFraction;
std::function<Real(const Real a_time)> voltageWaveForm;

auto defaultElectrodeVoltage = [...](const RealVect a_position, const Real a_time) -> Real{
   return voltageFraction * voltageWaveForm(a_time);
};

fieldSolver->setElectrodeDirichletFunction(electrode, defaultElectrodeVoltage);

In summary, the default voltage which is set on an electrode is the voltage fraction specified on the electrodes (in ComputationalGeometry) multiplied by a voltage wave form (specified by FieldSolver::setVoltage, as discussed above).

Dielectrics

On dielectrics, we enforce the jump boundary condition directly, see Jump conditions.

Calling the solve function

The electrostatic solver in chombo-discharge has a lot of supporting functionality, but essentially relies on only one critical function: Solving for the potential. This is encapsulated by the pure member function

/**
 * @brief Solves Poisson equation onto a_phi using a_rho and a_sigma as right-hand sides.
 * @param[in]    a_rho Space charge density
 * @param[in]    a_sigma Surface charge density.
 * @return True if we found a solution and false otherwise.
 * @note a_sigma must be defined on the gas phase.
 * @param[in] a_phi Phi
 * @param[in] a_zerophi Zerophi
 */
virtual bool
solve(MFAMRCellData& a_phi, const MFAMRCellData& a_rho, const EBAMRIVData& a_sigma, const bool a_zerophi = false) = 0;

where a_phi is the resulting potential that was computed with the space charge density a_rho, and surface charge density a_sigma.

FieldSolverGMG

FieldSolverGMG implements a multigrid routine for solving Eq. 7.

The discretization used by FieldSolverGMG is described in Linear solvers. The underlying solver type is a Helmholtz solver, but FieldSolverGMG considers only the Laplacian term. For further details on the spatial discretization, see Linear solvers.

Solver configuration

FieldSolverGMG has a number of switches for determining how it operates. Some of these switches are intended for parsing boundary conditions, whereas others are settings for operating multigrid or for I/O. The current list of configuration options are indicated below

Listing 26 Input options for the FieldSolverGMG class. Runtime adjustable options are highlighted.
# ====================================================================================================
# FieldSolverGMG class options
# ====================================================================================================
FieldSolverGMG.verbosity             = -1                ## Class verbosity
FieldSolverGMG.jump_bc               = natural           ## Jump BC type ('natural' or 'saturation_charge')
FieldSolverGMG.bc.x.lo               = dirichlet 0.0     ## Bc type (see docs)
FieldSolverGMG.bc.x.hi               = dirichlet 0.0     ## Bc type (see docs)
FieldSolverGMG.bc.y.lo               = dirichlet 0.0     ## Bc type (see docs)
FieldSolverGMG.bc.y.hi               = dirichlet 0.0     ## Bc type (see docs)
FieldSolverGMG.bc.z.lo               = dirichlet 0.0     ## Bc type (see docs)
FieldSolverGMG.bc.z.hi               = dirichlet 0.0     ## Bc type (see docs)
FieldSolverGMG.plt_vars              = phi rho E Esol    ## Plot variables: 'phi', 'rho', 'E', 'res', 'perm', 'sigma', 'Esol'
FieldSolverGMG.use_regrid_slopes     = true              ## Use slopes when regridding or not
FieldSolverGMG.kappa_source          = true              ## Volume weighted space charge density or not (depends on algorithm)

FieldSolverGMG.solver                       = bicgstab gmres    ## Solver(s), tried in order. 'gmg', 'gmres', 'bicgstab'. List = fallback chain
FieldSolverGMG.krylov_eps                   = 1.E-10            ## Outer Krylov relative residual tolerance (gmres/bicgstab)
FieldSolverGMG.krylov_max_iter              = 50                ## Outer Krylov max iterations (gmres/bicgstab)
FieldSolverGMG.krylov_restart               = 30                ## GMRES restart length (gmres only)
FieldSolverGMG.krylov_vcycles               = 1                 ## V-cycles per Krylov preconditioner application
FieldSolverGMG.krylov_retry_interval        = 1                 ## Re-probe GMG every N solves while latched to the Krylov fallback (1 = always retry GMG first)
FieldSolverGMG.krylov_reprobe_iters         = 0                 ## Re-probe GMG early when the Krylov fallback converges in <= this many iterations (0 = disabled)
FieldSolverGMG.gmg_verbosity                = -1                ## GMG verbosity
FieldSolverGMG.gmg_use_default_settings     = false             ## Use default multigrid settings or not (see documentation)
FieldSolverGMG.gmg_cycle                    = vcycle            ## Cycle type. 'vcycle' or 'wcycle'
FieldSolverGMG.gmg_smoother                 = ras 4             ## Relaxation. 'jacobi', 'multi_color', 'red_black', 'chebyshev <order> <eig_ratio>', or 'ras <inner_sweeps>'
FieldSolverGMG.gmg_relax_factor             = 1.0               ## Adjustable SOR factor
FieldSolverGMG.gmg_pre_smooth               = 8                 ## Number of relaxations in downsweep
FieldSolverGMG.gmg_post_smooth              = 8                 ## Number of relaxations in upsweep
FieldSolverGMG.gmg_bott_smooth              = 0                 ## Number of at bottom level (before dropping to bottom solver)
FieldSolverGMG.gmg_precond_smooth           = 8                 ## Number of smoothing steps in the preconditioner for pure GMG
FieldSolverGMG.gmg_min_iter                 = 5                 ## Minimum number of iterations
FieldSolverGMG.gmg_max_iter                 = 50                ## Maximum number of iterations
FieldSolverGMG.gmg_exit_tol                 = 1.E-10            ## Residue tolerance
FieldSolverGMG.gmg_exit_hang                = 0.2               ## Solver hang
FieldSolverGMG.gmg_min_cells                = 8                 ## Bottom drop
FieldSolverGMG.gmg_drop_order               = 0                 ## Drop stencil order to 1 if domain is coarser than this.
FieldSolverGMG.gmg_bc_order                 = 2                 ## Boundary condition order for multigrid
FieldSolverGMG.gmg_bc_weight                = 2                 ## Boundary condition weights (for least squares)
FieldSolverGMG.gmg_jump_order               = 2                 ## Boundary condition order for jump conditions
FieldSolverGMG.gmg_jump_weight              = 2                 ## Boundary condition weight for jump conditions (for least squares)
FieldSolverGMG.gmg_reduce_order             = true              ## If true, always use order=1 EB stencils in coarsened cells
FieldSolverGMG.gmg_bottom_solver            = simple 16         ## Bottom solver type. 'simple', 'bicgstab', or 'gmres'
FieldSolverGMG.gmg_bottom_verbosity         = -1                ## Bottom solver verbosity.
FieldSolverGMG.gmg_reflux_free              = false             ## If true, use reflux-free AMR operator

Note that all options pertaining to IO or multigrid are run-time configurable (see Run-time configurations).

Setting boundary conditions

The flags that are in the format bc.coord.side (e.g., bc.x.low) parse the domain boundary condition type to the solver. See Domain boundary conditions for details.

The flag jump_bc indicates how the dielectric jump condition is enforced. See Saturation charge BC for additional details.

Note

Currently, we only solve the dielectric jump condition on gas-dielectric interfaces and dielectric-dielectric interfaces are not supported. If you want to use numerical mock-ups of dielectric-dielectric interfaces, you can change \(\epsilon_r\) inside a dielectric, but note that the dielectric boundary condition \(\partial_{n_1}\Phi + \partial_{n_2}\Phi = \sigma/\epsilon_0\) is not solved in this case.

Algorithmic adjustments

By default, the Helmholtz operator uses a diagonal weighting of the operator using the volume fraction as weight. This means that the quantity that is passed into AMRMultiGrid should be weighted by the volume fraction to avoid the small-cell problem of EB grids. The flag kappa_source indicates whether or not we should multiply the right-hand side by the volume fraction before passing it into the solver routine. If this flag is set to false, it is an indication that the user has taken responsibility to perform this weighting prior to calling FieldSolver::solve(...). If this flag is set to true, FieldSolverGMG will perform the multiplication before the multigrid solve.

Tuning multigrid performance

The multigrid solver (smoothers, bottom solvers, cycle type, exit criteria) and the outer Krylov (GMRES/BiCGStab) configuration are shared across all chombo-discharge solvers and are documented centrally – including the full list of gmg_* and krylov_* options – in Tuning multigrid performance.

Adjusting output

The user may plot the potential, the space charge, the electric field, and the residual as follows:

FieldSolverGMG.plt_vars  = phi rho E res     # Plot variables. Possible vars are 'phi', 'rho', 'E', 'res', 'perm', 'sigma', 'Esol'

The remaining variables are the permittivity (perm), the surface charge (sigma), and the electric field in the solid phase (Esol). A name that is not in this list aborts the run.

Saturation charge BC

As mentioned above, on dielectric interfaces the user can choose to specify which “form” of Eq. 8 to solve. If the user wants the natural form in which the surface charge is the free parameter, he can specify

FieldSolverGMG.which_jump = natural

To use the other format (in which one of the fluxes is specified), use

FieldSolverGMG.which_jump = saturation_charge

Note

The saturation_charge option will set the derivative of \(\partial_n\Phi\) to zero on the gas side. Support for setting \(\partial_n\Phi\) to a specified (e.g., non-zero) value on either side is missing, but is straightforward to implement.

FieldSolverAMG

FieldSolverAMG solves the same problem as FieldSolverGMG, but assembles it as one PETSc matrix over all AMR levels and both phases, and solves it with a PETSc Krylov solver preconditioned by algebraic multigrid (GAMG by default). It requires a build with USE_PETSC = TRUE (see Installation), and is used like any other FieldSolver, e.g. as FieldStepper<FieldSolverAMG>; Exec/Examples/Electrostatics/PETSc selects between the two solvers with an input option.

When to use it

Geometric multigrid needs coarsened versions of the geometry, and loses accuracy when features of the embedded boundary are smaller than the coarse grid cells. Algebraic multigrid builds its coarse levels from the matrix, so it does not depend on how the geometry coarsens, and is the choice for geometries where FieldSolverGMG converges slowly or not at all. Its setup is more expensive than that of FieldSolverGMG (the matrix and the AMG hierarchy are built once per regrid), and on simple geometries FieldSolverGMG can be faster.

Discretization

The discretization is that of FieldSolverGMG (see Linear solvers): a cell-centered finite-volume scheme, weighted by the volume fraction, with face fluxes interpolated to the face centroids on cut cells, least-squares stencils for the normal derivative on the embedded boundary, and the natural or saturation-charge condition on the interface between the gas and the dielectrics. The embedded-boundary stencils use the same neighbourhoods and least-squares fits as those of FieldSolverGMG, but are built from PETSc rows only (cells on the same level, coarse-fine ghost cells through their interpolation stencils, and cells on the next finer level in place of cells covered by it), and use one order and one weight (eb_order, eb_weight) for both electrodes and interfaces. With the same order and weight, the two solvers agree to the solver tolerance.

The rows of the matrix are volume-weighted: the kappa-weighted divergence of each cell is multiplied by \((\Delta x_l/\Delta x_0)^D\) on level \(l\), and the right-hand side carries the same weights. This does not change the solution, but without it the row scale grows by \(r^2\) per level (\(r\) the refinement ratio), and a flux through a refinement boundary enters the fine and the coarse row with weights that differ by the volume ratio. Algebraic multigrid, which assumes a nearly symmetric matrix, converges much more slowly on such a matrix; in Exec/Examples/Electrostatics/PETSc the weighting cut the number of GMRES iterations by a factor of about three. The matrix is still not symmetric: the coarse-fine interpolation stencils and the embedded-boundary stencils are one-sided.

Solver configuration

Listing 27 Input options for the FieldSolverAMG class.
# ====================================================================================================
# FieldSolverAMG class options
# ====================================================================================================
FieldSolverAMG.verbosity             = -1               ## Class verbosity
FieldSolverAMG.bc.x.lo               = dirichlet 0.0    ## Bc type (see docs)
FieldSolverAMG.bc.x.hi               = dirichlet 0.0    ## Bc type (see docs)
FieldSolverAMG.bc.y.lo               = dirichlet 0.0    ## Bc type (see docs)
FieldSolverAMG.bc.y.hi               = dirichlet 0.0    ## Bc type (see docs)
FieldSolverAMG.bc.z.lo               = dirichlet 0.0    ## Bc type (see docs)
FieldSolverAMG.bc.z.hi               = dirichlet 0.0    ## Bc type (see docs)
FieldSolverAMG.plt_vars              = phi rho E        ## Plot variables: 'phi', 'rho', 'E', 'res', 'perm', 'sigma', 'Esol'
FieldSolverAMG.use_regrid_slopes     = true             ## Use slopes when regridding or not

FieldSolverAMG.ksp_type                       = gmres        ## Outer Krylov solver: a PETSc KSP type, e.g. 'gmres', 'fgmres', 'bicgstab', 'cg'
FieldSolverAMG.ksp_gmres_restart              = 30           ## Restart length of GMRES and FGMRES
FieldSolverAMG.pc_type                        = gamg         ## PETSc preconditioner, e.g. 'gamg', 'hypre'
FieldSolverAMG.amg_smoother_ksp               = chebyshev    ## Multigrid level smoother: PETSc KSP type, e.g. 'chebyshev', 'richardson'
FieldSolverAMG.amg_smoother_pc                = sor          ## Multigrid level smoother: PETSc PC type, e.g. 'sor', 'jacobi'
FieldSolverAMG.amg_smoother_its               = 2            ## Multigrid level smoother: number of smoothing steps
FieldSolverAMG.gamg_threshold                 = 0.02         ## GAMG graph threshold for dropping weak connections (negative keeps all)
FieldSolverAMG.gamg_aggressive_coarsening     = 1            ## GAMG: number of levels coarsened aggressively (0 = none)
FieldSolverAMG.ksp_rtol                       = 1.E-10       ## Relative residual tolerance, in the KSP's norm (preconditioned for left-preconditioned KSPs)
FieldSolverAMG.ksp_atol                       = 1.E-50       ## Absolute residual tolerance
FieldSolverAMG.ksp_max_iter                   = 200          ## Maximum number of Krylov iterations
FieldSolverAMG.petsc_verbosity                = -1           ## PETSc solve verbosity: residual per iteration (1), true residual (2), solver view (3)
FieldSolverAMG.kappa_source                   = true         ## Volume weighted space charge density or not (depends on algorithm)
FieldSolverAMG.eb_order                       = 1            ## Highest order of the EB face stencils (electrodes and interfaces)
FieldSolverAMG.eb_weight                      = 2            ## Least-squares weighting of the EB face stencils
FieldSolverAMG.jump_bc                        = natural      ## Interface condition: 'natural' or 'saturation_charge'

The domain boundary conditions (bc.coord.side), jump_bc, kappa_source and plt_vars are as for FieldSolverGMG. The remaining options configure PETSc:

  • ksp_type is the outer Krylov solver, any PETSc KSP type (e.g. gmres, fgmres, bicgstab, cg), and ksp_gmres_restart its restart length for GMRES and FGMRES.

  • ksp_rtol, ksp_atol and ksp_max_iter are its exit criteria. They apply to the volume-weighted system, so fine-level residuals count less than coarse-level ones. Note also that GMRES measures the relative tolerance in the preconditioned norm, so the true residual can be larger than ksp_rtol suggests.

  • petsc_verbosity controls the output of the solve. At 1 and above the residual is printed at every Krylov iteration, in the norm the KSP tests convergence on and relative to its first iteration. At 2 and above the true residual \(b - Ax\), relative to \(b\), is printed too, at the cost of computing it every iteration. At 3 and above the solver and the preconditioner (e.g. the levels of the algebraic multigrid hierarchy) are printed to standard output after each solve.

  • pc_type is the PETSc preconditioner. With jump_bc = saturation_charge it is applied to each phase separately, see below.

  • amg_smoother_ksp, amg_smoother_pc and amg_smoother_its set the smoother on each level of a multigrid preconditioner. The default, Chebyshev with SOR, is more robust than PETSc’s default (Chebyshev with Jacobi) for the rows of small cut cells.

  • gamg_threshold and gamg_aggressive_coarsening control how GAMG builds its coarse levels; other preconditioners ignore them. GAMG groups each unknown with its strongly connected neighbours, and each group becomes one unknown on the next coarser level. Connections weaker than gamg_threshold, relative to the diagonal, are not followed when forming the groups (a negative value follows all of them). A threshold of 0.01–0.02 keeps groups from forming across the weak couplings of small cut cells and refinement boundaries, which speeds up convergence, at the cost of smaller groups and thus more memory in the hierarchy; larger values can make the setup very expensive. gamg_aggressive_coarsening is the number of levels, from the finest, that are coarsened aggressively, i.e. grouped over neighbours of neighbours. This makes the hierarchy much smaller but each coarse level cruder, so the solve takes more iterations.

  • eb_order and eb_weight are the order and the least-squares weight of the embedded-boundary stencils. eb_order must not exceed AmrMesh.mg_interp_radius.

With the saturation charge, the gas side of the interface has no flux, so no gas row of the matrix depends on a dielectric row. An algebraic multigrid hierarchy over the whole matrix forms coarse unknowns across the interface, and does not converge on such a matrix. FieldSolverAMG then preconditions with a PETSc field split with one field per phase, solved one after the other (gas, then dielectric), each with one application of pc_type and the amg_smoother_* and gamg_* settings. The fields can be configured with the PETSc options prefixes -fieldsolveramg_fieldsplit_gas_ and -fieldsolveramg_fieldsplit_solid_, e.g. -fieldsolveramg_fieldsplit_gas_pc_gamg_threshold; options for the preconditioner of the whole matrix, such as -fieldsolveramg_pc_gamg_threshold, do not apply to the fields. Giving -fieldsolveramg_pc_type to PETSc replaces the field split by that preconditioner on the whole matrix. With the natural jump condition the phases are coupled both ways, and pc_type is applied to the whole matrix.

With verbosity above 1, each solve ends with a summary in the same form as FieldSolverGMG’s Krylov solvers, e.g.

FieldSolverAMG - gmres converged (rel.res = 3.96903e-10, unweighted rel.res = 5.36091e-10, |r| = 0.0169176, |r_zero| = 4.26241e+07, iters = 13, reason = CONVERGED_RTOL)

where rel.res is the true residual \(|b - Ax|_2\) of the volume-weighted system relative to the zero-residual \(|b|_2\), and unweighted rel.res the same with the row weights removed from both. |r| and |r_zero| are the weighted norms. The residual that is plotted (res) is unweighted.

Any other PETSc option can be given with the prefix fieldsolveramg_ through the PETSC_OPTIONS environment variable, e.g.

PETSC_OPTIONS="-fieldsolveramg_pc_gamg_agg_nsmooths 1 -fieldsolveramg_ksp_view_mat binary:A.bin" mpirun -x PETSC_OPTIONS -np 4 ./main2d.*.ex example2d.inputs

PETSc options given this way take precedence over the input file. Options without a value, e.g. -fieldsolveramg_ksp_monitor, can also be given on the command line, but options with a value cannot, because ParmParse reads the command line too and aborts on them.

Limitations

  • Periodic domains are not supported.

  • Multi-valued cells are not supported, and abort.

  • With the saturation charge condition, the AMG solve can converge slowly on complex geometries.

  • As in FieldSolverGMG, a cut cell where no least-squares fit is accepted (see Dirichlet) has no flux through its EB face, and its potential is determined by its other faces only. With verbosity above 0, FieldSolverAMG prints the number of such cells, counted per phase, when it sets up the solver.

  • With the saturation charge condition, an interface cell without a stencil on the gas side gets a zero normal derivative on both sides, and hence no surface charge, in both solvers.

FieldSolverMG

FieldSolverMG solves Eq. 7 with geometric multigrid, as FieldSolverGMG does, and repeats the solve with algebraic multigrid, as FieldSolverAMG does, when geometric multigrid fails to converge. It is used like any other FieldSolver, e.g. as FieldStepper<FieldSolverMG>, and is the default field solver of the ItoKMC and DischargeInception time steppers, and of the application setup scripts in /Physics. The algebraic multigrid fallback requires a build with USE_PETSC = TRUE (see Installation). Without PETSc, FieldSolverMG solves with geometric multigrid only.

How it works

FieldSolverMG holds a FieldSolverGMG and, in PETSc builds, a FieldSolverAMG. The two solvers share the data of FieldSolverMG (the potential, the space and surface charge, the electric field, the residue and the permittivities), and they read their options from the FieldSolverMG block of the input file. The boundary conditions, the interface condition, the plot variables and the embedded-boundary stencils are therefore given once, and agree in the two solvers.

Each solve goes through the geometric multigrid solver chain first (gmg_solver, e.g. gmg bicgstab, see Tuning multigrid performance). If the chain does not converge, the potential is reset to the initial guess of the solve, and the solve is repeated with algebraic multigrid. The algebraic multigrid solver is only set up the first time it is needed after a regrid, so a simulation in which geometric multigrid always converges does not pay for it. Permittivities that were given with setSolverPermittivities, e.g. by a semi-implicit time stepper, are passed on to it when it is set up.

Once algebraic multigrid has rescued a solve, the following solves go straight to it, and geometric multigrid is tried again every amg_retry_interval solves. If geometric multigrid then converges, FieldSolverMG returns to it. The switches are printed to the pout files, e.g.

FieldSolverMG::solve -- geometric multigrid did not converge; falling back to algebraic multigrid
FieldSolverMG::solve -- geometric multigrid converged again

Geometric and algebraic multigrid assemble the operator differently, so a solve that falls back gives a slightly different discrete solution, within the solver tolerances.

Solver configuration

Listing 28 Input options for the FieldSolverMG class.
# ====================================================================================================
# FieldSolverMG class options
# ====================================================================================================
FieldSolverMG.verbosity             = -1               ## Class verbosity
FieldSolverMG.jump_bc               = natural          ## Jump BC type ('natural' or 'saturation_charge')
FieldSolverMG.bc.x.lo               = dirichlet 0.0    ## Bc type (see docs)
FieldSolverMG.bc.x.hi               = dirichlet 0.0    ## Bc type (see docs)
FieldSolverMG.bc.y.lo               = dirichlet 0.0    ## Bc type (see docs)
FieldSolverMG.bc.y.hi               = dirichlet 0.0    ## Bc type (see docs)
FieldSolverMG.bc.z.lo               = dirichlet 0.0    ## Bc type (see docs)
FieldSolverMG.bc.z.hi               = dirichlet 0.0    ## Bc type (see docs)
FieldSolverMG.bc_order              = 2                ## EB stencil order on electrodes and dielectric interfaces (GMG and AMG)
FieldSolverMG.bc_weight             = 2                ## EB stencil least-squares weight on electrodes and dielectric interfaces (GMG and AMG)
FieldSolverMG.plt_vars              = phi rho E        ## Plot variables: 'phi', 'rho', 'E', 'res', 'perm', 'sigma', 'Esol'
FieldSolverMG.use_regrid_slopes     = true             ## Use slopes when regridding or not
FieldSolverMG.kappa_source          = true             ## Volume weighted space charge density or not (depends on algorithm)

# Fallback to algebraic multigrid (PETSc builds only; ignored with a warning otherwise)
FieldSolverMG.amg_fallback           = true    ## Fall back to PETSc AMG when the GMG solver chain fails
FieldSolverMG.amg_retry_interval     = 10      ## While latched to AMG, re-try GMG every N solves (1 = always try GMG first)

# Geometric multigrid stage (always active)
FieldSolverMG.gmg_solver                    = bicgstab     ## Solver(s), tried in order. 'gmg', 'gmres', 'bicgstab'. List = fallback chain
FieldSolverMG.gmg_krylov_eps                = 1.E-10       ## Outer Krylov relative residual tolerance (gmres/bicgstab)
FieldSolverMG.gmg_krylov_max_iter           = 50           ## Outer Krylov max iterations (gmres/bicgstab)
FieldSolverMG.gmg_krylov_restart            = 30           ## GMRES restart length (gmres only)
FieldSolverMG.gmg_krylov_vcycles            = 1            ## V-cycles per Krylov preconditioner application
FieldSolverMG.gmg_krylov_retry_interval     = 10           ## Re-probe GMG every N solves while latched to the Krylov fallback (1 = always retry GMG first)
FieldSolverMG.gmg_krylov_reprobe_iters      = 0            ## Re-probe GMG early when the Krylov fallback converges in <= this many iterations (0 = disabled)
FieldSolverMG.gmg_verbosity                 = -1           ## GMG verbosity (also used by the Krylov solvers)
FieldSolverMG.gmg_cycle                     = vcycle       ## Cycle type. 'vcycle' or 'wcycle'
FieldSolverMG.gmg_smoother                  = ras 4        ## Relaxation. 'jacobi', 'multi_color', 'red_black', 'chebyshev <order> <eig_ratio>', or 'ras <inner_sweeps>'
FieldSolverMG.gmg_relax_factor              = 1.0          ## Adjustable SOR factor
FieldSolverMG.gmg_pre_smooth                = 4            ## Number of relaxations in downsweep (each is <inner_sweeps> sweeps for 'ras')
FieldSolverMG.gmg_post_smooth               = 4            ## Number of relaxations in upsweep (each is <inner_sweeps> sweeps for 'ras')
FieldSolverMG.gmg_bott_smooth               = 0            ## Number of relaxations on the bottom level before the bottom solver
FieldSolverMG.gmg_precond_smooth            = 4            ## Relaxations in the bottom Krylov solver's preconditioner (bicgstab/gmres bottom only)
FieldSolverMG.gmg_min_iter                  = 5            ## Minimum number of iterations
FieldSolverMG.gmg_max_iter                  = 50           ## Maximum number of iterations
FieldSolverMG.gmg_exit_tol                  = 1.E-10       ## Residue tolerance
FieldSolverMG.gmg_exit_hang                 = 0.2          ## Solver hang
FieldSolverMG.gmg_min_cells                 = 16           ## Bottom drop
FieldSolverMG.gmg_drop_order                = 0            ## Drop stencil order to 1 if domain is coarser than this.
FieldSolverMG.gmg_reduce_order              = true         ## If true, always use order=1 EB stencils in coarsened cells
FieldSolverMG.gmg_bottom_solver             = simple 16    ## Bottom solver type. 'simple <relaxations>', 'bicgstab', or 'gmres'
FieldSolverMG.gmg_bottom_verbosity          = -1           ## Bottom solver verbosity.
FieldSolverMG.gmg_reflux_free               = false        ## If true, use reflux-free AMR operator

# Algebraic multigrid stage (PETSc builds only; built on the first fallback)
FieldSolverMG.ksp_type                       = gmres        ## Outer Krylov solver: a PETSc KSP type, e.g. 'gmres', 'fgmres', 'bicgstab', 'cg'
FieldSolverMG.ksp_gmres_restart              = 30           ## Restart length of GMRES and FGMRES
FieldSolverMG.pc_type                        = gamg         ## PETSc preconditioner, e.g. 'gamg', 'hypre'
FieldSolverMG.amg_smoother_ksp               = chebyshev    ## Multigrid level smoother: PETSc KSP type, e.g. 'chebyshev', 'richardson'
FieldSolverMG.amg_smoother_pc                = sor          ## Multigrid level smoother: PETSc PC type, e.g. 'sor', 'jacobi'
FieldSolverMG.amg_smoother_its               = 2            ## Multigrid level smoother: number of smoothing steps
FieldSolverMG.gamg_threshold                 = 0.02         ## GAMG graph threshold for dropping weak connections (negative keeps all)
FieldSolverMG.gamg_aggressive_coarsening     = 1            ## GAMG: number of levels coarsened aggressively (0 = none)
FieldSolverMG.ksp_rtol                       = 1.E-10       ## Relative residual tolerance, in the KSP's norm (preconditioned for left-preconditioned KSPs)
FieldSolverMG.ksp_atol                       = 1.E-50       ## Absolute residual tolerance
FieldSolverMG.ksp_max_iter                   = 200          ## Maximum number of Krylov iterations
FieldSolverMG.petsc_verbosity                = -1           ## PETSc solve verbosity: residual per iteration (1), true residual (2), solver view (3)

The domain boundary conditions (bc.coord.side), jump_bc, kappa_source, plt_vars and use_regrid_slopes are as for FieldSolverGMG. The remaining options are:

  • bc_order and bc_weight are the order and the least-squares weight of the embedded-boundary stencils on electrodes and on dielectric interfaces, in both solvers. They replace gmg_bc_order, gmg_bc_weight, gmg_jump_order and gmg_jump_weight of FieldSolverGMG, and eb_order and eb_weight of FieldSolverAMG.

  • amg_fallback turns the algebraic multigrid fallback on or off. It is ignored, with a message in the pout files, in builds without PETSc.

  • amg_retry_interval is the number of solves between each time geometric multigrid is tried again, after algebraic multigrid rescued a solve. With 1, every solve tries geometric multigrid first.

  • The options that start with gmg_ configure geometric multigrid. They are the options of FieldSolverGMG, where solver and krylov_* are named gmg_solver and gmg_krylov_*. See Tuning multigrid performance. gmg_use_default_settings is not available, since it would replace the stencil and smoother settings.

  • The other options configure algebraic multigrid, and are those of FieldSolverAMG (see FieldSolverAMG).

The defaults are chosen for robustness rather than speed on simple geometries: second-order embedded-boundary stencils, the ras 4 smoother, a BiCGStab solver preconditioned by geometric multigrid, with algebraic multigrid as its fallback, and order-1 stencils on the coarsened multigrid levels (gmg_reduce_order).

Limitations

The fallback is skipped, with a message in the pout files when geometric multigrid fails, when algebraic multigrid does not support the problem:

  • when the domain is periodic, or

  • when bc_order exceeds the coarse-fine interpolation radius (AmrMesh.mg_interp_radius).

In PETSc builds, a grid with multi-valued cells aborts when the PETSc row map is set up, whichever field solver is used.

Frequency dependent permittivity

Frequency-dependent permittivities are fundamentally supported by the chombo-discharge elliptic discretization but none of the solvers implement it. Recall that the polarization (in frequency space) is

\[\mathbf{P}(\omega) = \epsilon_0\chi(\omega)\mathbf{E}(\omega),\]

where \(\chi(\omega)\) is the dielectric susceptibility.

There are two forms through which chombo-discharge can support frequency-dependent permittivities: through convolution or through auxiliary differential equations (ADEs).

Convolution approach

In the time domain, the displacement field is:

\[\mathbf{D}(t_k) = \epsilon_0\mathbf{E}(t_k) + \epsilon_0\int_0^{t_k} \chi(t)\mathbf{E}(t_k-t)\text{d}t.\]

There are various forms of discretizing the integral. E.g. with the trapezoidal rule then

\[\begin{split}\begin{split} \int_0^{t_k}\chi(t)\mathbf{E}(t-t)\text{d}t &= \sum_{n=0}^{k-1} \int_{t_n}^{t_{n+1}}\chi(t)\mathbf{E}(t_k-t)\text{d}t \\ &\approx \frac{1}{2}\sum_{n=0}^{k-1}\Delta t_n\left[\chi(t_n)\mathbf{E}(t_k-t_n) + \chi(t_{n+1})\mathbf{E}(t_k-t_{n+1})\right] \\ &= \frac{\Delta t_0}{2}\chi_0\mathbf{E}(t_k) + \frac{1}{2}\sum_{n=1}^{k-1}\Delta t_n\chi_n\mathbf{E}(t_k-t_n) + \frac{1}{2}\sum_{n=0}^{k-1}\Delta t_n\chi_{n+1}\mathbf{E}(t_k-t_{n+1}) \end{split}\end{split}\]

The Gauss law becomes

\[\begin{split}\begin{split} \nabla\cdot\left[\left(1+\frac{\chi_0\Delta t_0}{2}\right)\mathbf{E}(t_k)\right] &= \frac{\rho(t_k)}{\epsilon_0}\\ &- \nabla\cdot\left[\frac{1}{2}\sum_{n=1}^{k-1}\Delta t_n\chi_n\mathbf{E}(t_k-t_n) + \frac{1}{2}\sum_{n=0}^{k-1}\Delta t_n\chi_{n+1}\mathbf{E}(t_k-t_{n+1})\right]. \end{split}\end{split}\]

Note that the dispersion enters as an extra term on the right-hand side, emulating a space charge. Unfortunately, inclusion of dispersion means that we must store \(\mathbf{E}(t_n)\) for all previous time steps.

Auxiliary differential equation

With the ADE approach we seek a solution to \(\mathbf{P}(\omega) = \epsilon_0\chi(\omega)\mathbf{E}(\omega)\) in the form

\[\sum_k a_k(i\omega)^k\mathbf{P}(\omega) = \epsilon_0\mathbf{E}(\omega),\]

where \(\sum a_k(i\omega)^k\) is the Taylor series for \(1/\chi(\omega)\). This can be written as a partial differential equation

\[\sum_{k}a_k\partial_t^k\mathbf{P}(t) = \epsilon_0\mathbf{E}(t).\]

This equation can be discretized using finite differences, and centering the solution on \(t_k\) with backward differences yields an expression

\[\mathbf{P}^k = \epsilon_0C_0^k\mathbf{E}^k - \sum_{m>0} C_m^k\mathbf{P}^{k-m}.\]

where \(C_k\) are stencil coefficients to be worked out for each case. The displacement field \(\mathbf{D}^k = \epsilon_0 \mathbf{E}^k + \mathbf{P}^k\) is then

\[\mathbf{D} = \epsilon_0(1 + C_0^k)\mathbf{E} - \sum_{m>0} C_m^k\mathbf{P}^{k-m}.\]

The Gauss law yields

\[\nabla\cdot\left[\left(1 + C_0^k\right)\mathbf{E}^k\right] = \frac{\rho}{\epsilon_0} - \frac{1}{\epsilon_0}\nabla\cdot\sum_{m>0} C_m^k\mathbf{P}^{k-m}.\]

Unlike the convolution approach, this only requires storing terms required for the ADE description. This depends both on the order of the ADE, as well as its discretization. Normally, the ADE is a low-order PDE and a few terms are sufficient.

Limitations

Warning

There is currently a bug where having a dielectric interface align completely with a grid face will cause the cell to be identified as an electrode EB. This bug is due to the way Chombo handles cut-cells that align completely with a grid face. In this case the cell with volume fraction \(\kappa = 1\) will be identified as an irregular cell. For the opposite phase (i.e., viewing the grids from inside the boundary) the situation is opposite and thus the two “matching cells” can appear in different grid patches. A fix for this is underway. In the meantime, a sufficient workaround is simply to displace the dielectric slightly away from the interface (any non-zero displacement will do).

Example application(s)

Example applications that use the electrostatics capabilities are: