# Charge based boundary element fast multipole method

The charge-based formulation of the boundary element method (BEM) is a dimensionality reduction numerical technique that is used to model quasistatic electromagnetic phenomena in highly complex conducting media (targeting, e.g., the human brain) with a very large (up to approximately 1 billion) number of unknowns. The charge-based BEM solves an integral equation of the potential theory written in terms of the induced surface charge density. This formulation is naturally combined with fast multipole method (FMM) acceleration, and the entire method is known as charge-based BEM-FMM. The combination of BEM and FMM is a common technique in different areas of computational electromagnetics and, in the context of bioelectromagnetism, it provides improvements over the finite element method.

## Historical development

Along with more common electric potential-based BEM, the quasistatic charge-based BEM, derived in terms of the single-layer (charge) density, for a single-compartment medium has been known in the potential theory since the beginning of the 20th century. For multi-compartment conducting media, the surface charge density formulation first appeared in discretized form (for faceted interfaces) in the 1964 paper by Gelernter and Swihart. A subsequent continuous form, including time-dependent and dielectric effects, appeared in the 1967 paper by Barnard, Duck, and Lynn. The charge-based BEM has also been formulated for conducting, dielectric, and magnetic media, and used in different applications.
In 2009, Greengard et al. successfully applied the charge-based BEM with fast multipole acceleration to molecular electrostatics of dielectrics. A similar approach to realistic modeling of the human brain with multiple conducting compartments was first described by Makarov et al. in 2018. Along with this, the BEM-based multilevel fast multipole method has been widely used in radar and antenna studies at microwave frequencies as well as in acoustics.

## Physical background - surface charges in biological media

The charge-based BEM is based on the concept of an impressed (or primary) electric field $\mathbf {E} ^{i}$ and a secondary electric field $\mathbf {E} ^{s}$. The impressed field is usually known a priori or is trivial to find. For the human brain, the impressed electric field can be classified as one of the following:
* A conservative field $\mathbf {E} ^{i}$ derived from an impressed density of EEG or MEG current sources in a homogeneous infinite medium with the conductivity $\sigma$ at the source location;
* An instantaneous solenoidal field $\mathbf {E} ^{i}$ of an induction coil obtained from Faraday's law of induction in a homogeneous infinite medium (air), when transcranial magnetic stimulation (TMS) problems are concerned;
* A surface field $\mathbf {E} ^{i}$derived from an impressed surface current density $\mathbf {J} ^{i}=\sigma \mathbf {E} ^{i}$ of current electrodes injecting electric current at a boundary of a compartment with conductivity $\sigma$ when transcranial direct-current stimulation (tDCS) or deep brain stimulation (DBS) are concerned;
* A conservative field $\mathbf {E} ^{i}$ of charges deposited on voltage electrodes for tDCS or DBS. This specific problem requires a coupled treatment since these charges will depend on the environment;
* In application to multiscale modeling, a field $\mathbf {E} ^{i}$ obtained from any other macroscopic numerical solution in a small (mesoscale or microscale) spatial domain within the brain. For example, a constant field can be used.Examples of impressed electric field for brain stimulation (TMS/DBS/tDCS/ICMS) and neurophysiological recordings (EEG/MEG). WM is white matter, GM - grey matter, and CSF - cerebrospinal fluid.
When the impressed field is "turned on", free charges located within a conducting volume D immediately begin to redistribute and accumulate at the boundaries (interfaces) of regions of different conductivity in D. A surface charge density $\rho (\mathbf {r} )$ appears on the conductivity interfaces. This charge density induces a secondary conservative electric field $\mathbf {E} ^{s}$ following Coulomb's law.
One example is a human under a direct current powerline with the known field $\mathbf {E} ^{i}$ directed down. The superior surface of the human's conducting body will be charged negatively while its inferior portion is charged positively. These surface charges create a secondary electric field that effectively cancels or blocks the primary field everywhere in the body so that no current will flow within the body under DC steady state conditions.
Another example is a human head with electrodes attached. At any conductivity interface with a normal vector $\mathbf {n}$ pointing from an "inside" (-) compartment of conductivity $\sigma ^{-}$to an "outside" (+) compartment of conductivity $\sigma ^{+}$, Kirchhoff's current law requires continuity of the normal component of the electric current density. This leads to the interfacial boundary condition in the form
* $\sigma ^{+}\mathbf {E} ^{+}\cdot \mathbf {n} =\sigma ^{-}\mathbf {E} ^{-}\cdot \mathbf {n}$
for every facet at a triangulated interface. As long as $\sigma ^{\pm }$ are different from each other, the two normal components of the electric field, $\mathbf {E} ^{\pm }\cdot \mathbf {n}$, must also be different. Such a jump across the interface is only possible when a sheet of surface charge exists at that interface. Thus, if an electric current or voltage is applied, the surface charge density follows.
The goal of the numerical analysis is to find the unknown surface charge distribution and thus the total electric field $\mathbf {E} =\mathbf {E} ^{i}+\mathbf {E} ^{s}$ (and the total electric potential if required) anywhere in space.

## System of equations for surface charges

Below, a derivation is given based on Gauss's law and Coulomb's law. All conductivity interfaces, denoted by S, are discretized into planar triangular facets $t_{m}$ with centers $\mathbf {r} _{m}$. Assume that an m-th facet with the normal vector $\mathbf {n} _{m}$ and area $A_{m}$ carries a uniform surface charge density $\rho _{m}$. If a volumetric tetrahedral mesh were present, the charged facets would belong to tetrahedra with different conductivity values. We first compute the electric field $\mathbf {E} _{m}^{+}$ at the point $\mathbf {r} _{m}+\delta \mathbf {n} _{m}$, for $\delta \rightarrow 0^{+}$ i.e., just outside facet 𝑚 at its center. This field contains three contributions:
* The continuous impressed electric field $\mathbf {E} ^{i}$ itself;
* An electric field of the m-th charged facet itself. Very close to the facet, it can be approximated as the electric field of an infinite sheet of uniform surface charge $\rho _{m}$. By Gauss's Law, it is given by $+\rho _{m}/2\varepsilon _{0}\cdot \mathbf {n} _{m}$ where $\varepsilon _{0}$ is a background electrical permittivity;
* An electric field generated by all other facets $t_{n}$, which we approximate as point charges of charge $A_{n}\rho _{n}$ at each center $\mathbf {r} _{n}$.
A similar treatment holds for the electric field $\mathbf {E} _{m}^{-}$ just inside facet 𝑚, but the electric field of the flat sheet of charge changes its sign. Using Coulomb's law to calculate the contribution of facets different from $t_{m}$, we find
* $\mathbf {E} _{m}^{\pm }=\pm {\frac {\rho _{m}}{2\varepsilon _{0}}}\mathbf {n} _{m}+\sum _{n=1;n\neq m}^{M}{\frac {\rho _{n}}{4\pi \varepsilon _{0}}}{\frac {\mathbf {r} _{m}-\mathbf {r} _{n}}{|\mathbf {r} _{m}-\mathbf {r} _{n}|^{3}}}+\mathbf {E} ^{i}(\mathbf {r} _{m}),\ m=1,2,\dots ,M$
From this equation, we see that the normal component of the electric field indeed undergoes a jump through the charged interface. This is equivalent to a jump relation of the potential theory. As a second step, the two expressions for $\mathbf {E} _{m}^{\pm }$ are substituted into the interfacial boundary condition $\sigma ^{-}\mathbf {E} _{m}^{-}\cdot \mathbf {n} _{m}=\sigma ^{+}\mathbf {E} _{m}^{+}\cdot \mathbf {n} _{m}$, applied to every facet 𝑚. This operation leads to a system of linear equations for unknown charge densities $\rho _{m}$ which solves the problem:
* $\rho _{m}=K_{m}\mathbf {n} _{m}\cdot \underbrace {\sum _{n=1;n\neq m}^{M}{\frac {\rho _{n}}{2\pi }}{\frac {\mathbf {r} _{m}-\mathbf {r} _{n}}{|\mathbf {r} _{m}-\mathbf {r} _{n}|^{3}}}} +{2}\varepsilon _{0}K_{m}\mathbf {n} _{m}\cdot \mathbf {E} ^{i}(\mathbf {r} _{m}),\ m=1,2,\dots ,M$
where $K_{m}={\frac {\sigma ^{-}-\sigma ^{+}}{\sigma ^{-}+\sigma ^{+}}}$ is the electric conductivity contrast at the m-th facet. The normalization constant $\varepsilon _{0}$ will cancel out after the solution is substituted in the expression for $\mathbf {E} ^{s}$ and becomes redundant.

## Application of fast multipole method

For modern characterizations of brain topologies with ever-increasing levels of complexity, the above system of equations for $\rho _{m}$ is very large; it is therefore solved iteratively. An initial guess for $\rho _{m}$ is the last term on its right-hand side while the sum is ignored. Next, the sum is computed and the initial guess is refined, etc. This solution employs the simple Jacobi iterative method. The more rigorous generalized minimum residual method (GMRES) yields a much faster convergence of the BEM-FMM. In either case, the major work is in computing the underbraced sum in the system of equations above for every ${m}$ at every iteration; this operation corresponds to a repetitive matrix-vector multiplication. However, one can recognize this sum as an electric field (times ${\frac {1}{2\pi \epsilon _{0}}}$) of ${M}$ charges to be computed at ${M}$ observation points. Such a computation is exactly the task of the fast multipole method, which performs fast matrix-by-vector multiplication in $O(M\log {M})$ or even $O(M)$ operations instead of $O(M^{2})$. The FMM3D library realized in both Python and MATLAB can be used for this purpose. It is therefore unnecessary to form or store the dense system matrix typical for the standard BEM.

## Continuous charge-based BEM. Near-field correction

The system of equations formulated above is derived with the collocation method and is less accurate. The corresponding integral equation is obtained from the local jump relations of the potential theory and the local interfacial boundary condition of normal electric current continuity. It is a Fredholm integral equation of the second kind
* $\rho (\mathbf {r} )=K(\mathbf {r} )\mathbf {n} (\mathbf {r} )\cdot \int _{S}{\frac {\rho (\mathbf {r^{\prime }} )}{2\pi }}{\frac {\mathbf {r} -\mathbf {r^{\prime }} }{|\mathbf {r} -\mathbf {r^{\prime }} |^{3}}}ds(\mathbf {r^{\prime }} )+2\varepsilon _{0}K(\mathbf {r} )\mathbf {E} ^{i}(\mathbf {r} )\cdot \mathbf {n} (\mathbf {r} ),\mathbf {r} {\text{ on }}S$
Its derivation does not involve Green's identities (integrations by parts) and is applicable to non-nested geometries. When the Galerkin method is applied and the same zeroth-order basis functions (with a constant charge density for each facet) are still used on triangulated interfaces, we obtain exactly the same discretization as before if we replace the double integrals over surfaces $S_{m}$ and $S_{n}$ of triangles $t_{m}$ and $t_{n}$, respectively, by
$\int _{S_{m}}\int _{S_{n}}{\frac {\mathbf {r} -\mathbf {r^{\prime }} }{|\mathbf {r} -\mathbf {r^{\prime }} |^{3}}}ds(\mathbf {r^{\prime }} )ds(\mathbf {r} )\approx {A_{m}}{A_{n}}{\frac {\mathbf {r} _{m}-\mathbf {r} _{n}}{|\mathbf {r} _{m}-\mathbf {r} _{n}|^{3}}},$
where ${A_{n}}$ is the surface area of the triangle ${t_{n}}$. This approximation is only valid when $|\mathbf {r} _{m}-\mathbf {r} _{n}|$ is much larger than a typical facet size i.e., in the "far field". Otherwise, semi-analytical formulae and Gaussian quadratures for triangles should be used. Typically, 4 to 32 such neighbor integrals per facet should be precomputed, stored, and then used at every iteration. This is an important correction to the plain fast multipole method in the "near field" which should also be used in the simple discrete formulation derived above. Such a correction makes it possible to obtain an unconstrained numerical (but not anatomical) resolution in the brain.

## Applications and limitations

Applications of the charge-based BEM-FMM include modeling brain stimulation with near real-time accurate TMS computations as well as neurophysiological recordings. They also include modeling challenging mesoscale head topologies such as thin brain membranes (dura mater, arachnoid mater, and pia mater). This is particularly important for accurate transcranial direct-current stimulation and electroconvulsive therapy dosage predictions. The BEM-FMM allows for straightforward adaptive mesh refinement including multiple extracerebral brain compartments. Another application is modeling electric field perturbations within densely packed neuronal/axonal arbor. Such perturbations change the biophysical activating function. A charge-based BEM formulation is being developed for promising bi-domain biophysical modeling of axonal processes.
In its present form, the charge-based BEM-FMM is applicable to multi-compartment piecewise homogeneous media only; it cannot handle macroscopically anisotropic tissues. Additionally, the maximum number of facets (degrees of freedom) is limited to approximately $10^{9}$ for typical academic computer hardware resources used as of 2023.