The equations of tree_d_3d.electrodes , declared on the code that implements them and checked by the tests.
Conductors held at prescribed potentials, by the single-layer boundary integral.
boundary integral − 2 k e ∫ Γ σ ( y ) ln ∣ x − y ∣ d s y − 2 k e ∑ j q j ln ∣ x − r j ∣ = V k , x ∈ Γ k -2k_e\int_{\Gamma}\sigma(\mathbf y)\ln|\mathbf x - \mathbf y|\,ds_y \;-\; 2k_e\sum_j q_j\ln|\mathbf x - \mathbf r_j| = V_k, \qquad \mathbf x \in \Gamma_k − 2 k e ∫ Γ σ ( y ) ln ∣ x − y ∣ d s y − 2 k e j ∑ q j ln ∣ x − r j ∣ = V k , x ∈ Γ k collocation S Q = V / k e − ϕ f r e e r a w , ϕ f r e e r a w ( m i ) = − ∑ j q j ln ∣ m i − r j ∣ 2 \mathsf S\,\mathbf Q = \mathbf V / k_e - \boldsymbol\phi_\mathrm{free}^\mathrm{raw}, \qquad \phi_\mathrm{free}^\mathrm{raw}(\mathbf m_i) = -\sum_j q_j \ln|\mathbf m_i - \mathbf r_j|^2 S Q = V / k e − ϕ free raw , ϕ free raw ( m i ) = − j ∑ q j ln ∣ m i − r j ∣ 2 self term S k k = − 2 L k ∫ − L k / 2 L k / 2 ln ∣ t ∣ d t = 2 ( 1 − ln L k 2 ) S_{kk} = -\frac{2}{L_k}\int_{-L_k/2}^{L_k/2}\ln|t|\,dt = 2\left(1 - \ln\frac{L_k}{2}\right) S k k = − L k 2 ∫ − L k /2 L k /2 ln ∣ t ∣ d t = 2 ( 1 − ln 2 L k ) panels S i k = { ϕ s e g ( m i ; k ) ∣ m i − m k ∣ < n n e a r L k − ∑ g = 1 G w g ln ∣ m i − y k , g ∣ 2 otherwise S_{ik} = \begin{cases} \phi_\mathrm{seg}(\mathbf m_i;\, k) & |\mathbf m_i - \mathbf m_k| < n_\mathrm{near} L_k \\ -\sum_{g=1}^{G} w_g \ln|\mathbf m_i - \mathbf y_{k,g}|^2 & \text{otherwise} \end{cases} S ik = { ϕ seg ( m i ; k ) − ∑ g = 1 G w g ln ∣ m i − y k , g ∣ 2 ∣ m i − m k ∣ < n near L k otherwise far points y k , g = a k + ξ g ( b k − a k ) , ξ g = x g + 1 2 , w g = ω g 2 , error O ( ( L / r ) 2 G ) \mathbf y_{k,g} = \mathbf a_k + \xi_g (\mathbf b_k - \mathbf a_k), \qquad \xi_g = \frac{x_g + 1}{2}, \quad w_g = \frac{\omega_g}{2}, \qquad \text{error } O\big((L/r)^{2G}\big) y k , g = a k + ξ g ( b k − a k ) , ξ g = 2 x g + 1 , w g = 2 ω g , error O ( ( L / r ) 2 G ) field ϕ ( x ) = k e [ ∑ k n e a r Q k ϕ s e g ( x ; k ) + ∑ k f a r ∑ g Q k w g ϕ p t ( x − y k , g ) − ∑ j q j ln ∣ x − r j ∣ 2 ] \phi(\mathbf x) = k_e\Big[\sum_{k\ \mathrm{near}} Q_k\, \phi_\mathrm{seg}(\mathbf x; k) + \sum_{k\ \mathrm{far}} \sum_g Q_k w_g\, \phi_\mathrm{pt}(\mathbf x - \mathbf y_{k,g}) - \sum_j q_j \ln|\mathbf x - \mathbf r_j|^2\Big] ϕ ( x ) = k e [ k near ∑ Q k ϕ seg ( x ; k ) + k far ∑ g ∑ Q k w g ϕ pt ( x − y k , g ) − j ∑ q j ln ∣ x − r j ∣ 2 ] images ϕ p t ( x − y ) → ∑ ι ∈ { 1 , M } s ι G P ( x − ι y ) , s M = ± 1 (Neumann, Dirichlet) , ϕ → ϕ + V f a c e \phi_\mathrm{pt}(\mathbf x - \mathbf y) \to \sum_{\iota \in \{1, \mathsf M\}} s_\iota\, G_P(\mathbf x - \iota\,\mathbf y), \qquad s_{\mathsf M} = \pm 1 \text{ (Neumann, Dirichlet)}, \qquad \phi \to \phi + V_\mathrm{face} ϕ pt ( x − y ) → ι ∈ { 1 , M } ∑ s ι G P ( x − ι y ) , s M = ± 1 (Neumann, Dirichlet) , ϕ → ϕ + V face Order potential: 2, force: 2 Assumes a first-kind single-layer equation; straight panels of uniform charge Q k Q_k Q k (piecewise-constant density), collocated at their midpoints m k \mathbf m_k m k G G G = far_points = 2 Gauss-Legendre nodes x g x_g x g , weights ω g \omega_g ω g , per far panel; panels within n n e a r n_\mathrm{near} n near = near_field = 4 of their lengths enter exactly (segment_field)S \mathsf S S is not symmetric: up to DIRECT_LIMIT panels dense and LU-factorised once, O ( P 3 ) O(P^3) O ( P 3 ) , and O ( P 2 ) O(P^2) O ( P 2 ) per solve; above it GMRES with a block-Jacobi preconditioner (runs of PRECONDITIONER_BLOCK consecutive panels) and multipole-tree products, O ( P ) O(P) O ( P ) per iteration, the iterations growing slowly with P P P no conductor at infinity and no constraint on the total charge: the reference length of the logarithm is the unit of length, and a lone conductor of logarithmic capacity 1 (a circle of radius 1) makes S \mathsf S S singular keep panels shorter than the gaps between surfaces; the order is in the panel length with a period P P P along y y y the point kernel is the row sum G P G_P G P (periodic_log_kernel) and the near panel copies, shifted by ± P \pm P ± P , enter exactly; a face M \mathsf M M mirrors every charge about it, and the conductors' potentials are measured from a Dirichlet face's V f a c e V_\mathrm{face} V face Built from Potential (K,) and field (2, K) of a row of unit line charges, period period along y.
potential G P ( d ) = ∑ m = − ∞ ∞ − ln ∣ d − m P y ^ ∣ 2 = − ln [ 2 ( cosh 2 π d x P − cos 2 π d y P ) ] + 2 ln 2 π P G_P(\mathbf d) = \sum_{m=-\infty}^{\infty} -\ln|\mathbf d - m P \hat{\mathbf y}|^2 = -\ln\Big[2\Big(\cosh\frac{2\pi d_x}{P} - \cos\frac{2\pi d_y}{P}\Big)\Big] + 2\ln\frac{2\pi}{P} G P ( d ) = m = − ∞ ∑ ∞ − ln ∣ d − m P y ^ ∣ 2 = − ln [ 2 ( cosh P 2 π d x − cos P 2 π d y ) ] + 2 ln P 2 π field x − ∂ x G P = 2 π P sinh ( 2 π d x / P ) cosh ( 2 π d x / P ) − cos ( 2 π d y / P ) -\partial_x G_P = \frac{2\pi}{P}\,\frac{\sinh(2\pi d_x/P)}{\cosh(2\pi d_x/P) - \cos(2\pi d_y/P)} − ∂ x G P = P 2 π cosh ( 2 π d x / P ) − cos ( 2 π d y / P ) sinh ( 2 π d x / P ) field y − ∂ y G P = 2 π P sin ( 2 π d y / P ) cosh ( 2 π d x / P ) − cos ( 2 π d y / P ) -\partial_y G_P = \frac{2\pi}{P}\,\frac{\sin(2\pi d_y/P)}{\cosh(2\pi d_x/P) - \cos(2\pi d_y/P)} − ∂ y G P = P 2 π cosh ( 2 π d x / P ) − cos ( 2 π d y / P ) sin ( 2 π d y / P ) stable cosh a − cos b = 2 sinh 2 a 2 + 2 sin 2 b 2 \cosh a - \cos b = 2\sinh^2\frac a2 + 2\sin^2\frac b2 cosh a − cos b = 2 sinh 2 2 a + 2 sin 2 2 b Assumes a row of unit line charges a period P P P apart along y y y , in the log kernel, without k e k_e k e ; the divergent sum is renormalised so that G P + ln ∣ d ∣ 2 → 0 G_P + \ln|\mathbf d|^2 \to 0 G P + ln ∣ d ∣ 2 → 0 as d → 0 \mathbf d \to 0 d → 0 far from the row (∣ d x ∣ ≫ P |d_x| \gg P ∣ d x ∣ ≫ P ) G P → − 2 π ∣ d x ∣ / P + 2 ln ( 2 π / P ) G_P \to -2\pi|d_x|/P + 2\ln(2\pi/P) G P → − 2 π ∣ d x ∣/ P + 2 ln ( 2 π / P ) : the potential of a charged sheet, 2 π / P 2\pi/P 2 π / P per unit charge on either side cosh a − cos b \cosh a - \cos b cosh a − cos b is evaluated as 2 sinh 2 ( a / 2 ) + 2 sin 2 ( b / 2 ) 2\sinh^2(a/2) + 2\sin^2(b/2) 2 sinh 2 ( a /2 ) + 2 sin 2 ( b /2 ) (no cancellation near a charge) and by its exponential asymptote above ∣ a ∣ = 30 |a| = 30 ∣ a ∣ = 30 Potential (K,) and field (2, K) of uniformly charged straight segments.
potential ϕ s e g = − 2 L ∫ 0 L ln ( u − s ) 2 + v 2 d s = − 2 L [ u ln r a − ( u − L ) ln r b − L + ∣ v ∣ ϑ ] \phi_\mathrm{seg} = -\frac{2}{L}\int_0^L \ln\sqrt{(u - s)^2 + v^2}\, ds = -\frac{2}{L}\Big[u\ln r_a - (u - L)\ln r_b - L + |v|\vartheta\Big] ϕ seg = − L 2 ∫ 0 L ln ( u − s ) 2 + v 2 d s = − L 2 [ u ln r a − ( u − L ) ln r b − L + ∣ v ∣ ϑ ] field along E s e g ⋅ t ^ = 2 L ln r a r b \mathbf E_\mathrm{seg}\cdot\hat{\mathbf t} = \frac{2}{L}\ln\frac{r_a}{r_b} E seg ⋅ t ^ = L 2 ln r b r a field across E s e g ⋅ n ^ = 2 L sign ( v ) ϑ , ϑ = atan2 ( u , ∣ v ∣ ) − atan2 ( u − L , ∣ v ∣ ) \mathbf E_\mathrm{seg}\cdot\hat{\mathbf n} = \frac{2}{L}\operatorname{sign}(v)\,\vartheta, \qquad \vartheta = \operatorname{atan2}(u, |v|) - \operatorname{atan2}(u - L, |v|) E seg ⋅ n ^ = L 2 sign ( v ) ϑ , ϑ = atan2 ( u , ∣ v ∣ ) − atan2 ( u − L , ∣ v ∣ ) Assumes unit total charge spread evenly along a straight segment of length L L L , in the log kernel, without k e k_e k e u u u , v v v the target's coordinates along and across the segment from its start; r a r_a r a , r b r_b r b the distances to its ends; n ^ = ( − t y , t x ) \hat{\mathbf n} = (-t_y, t_x) n ^ = ( − t y , t x ) on the segment the normal field (the jump of the surface charge) is taken as zero; at an end the potential is finite and the field diverges logarithmically Potential and field sampled on a regular grid, interpolated bilinearly.
bilinear f ( x , y ) = ( 1 − f x ) ( 1 − f y ) f i , j + f x ( 1 − f y ) f i + 1 , j + ( 1 − f x ) f y f i , j + 1 + f x f y f i + 1 , j + 1 f(x, y) = (1 - f_x)(1 - f_y)\, f_{i,j} + f_x (1 - f_y)\, f_{i+1,j} + (1 - f_x) f_y\, f_{i,j+1} + f_x f_y\, f_{i+1,j+1} f ( x , y ) = ( 1 − f x ) ( 1 − f y ) f i , j + f x ( 1 − f y ) f i + 1 , j + ( 1 − f x ) f y f i , j + 1 + f x f y f i + 1 , j + 1 cell f x = x − x 0 Δ x − i ∈ [ 0 , 1 ] , i = min ( ⌊ x − x 0 Δ x ⌋ , n x − 2 ) f_x = \frac{x - x_0}{\Delta x} - i \in [0, 1], \qquad i = \min\!\left(\left\lfloor \frac{x - x_0}{\Delta x} \right\rfloor, n_x - 2\right) f x = Δ x x − x 0 − i ∈ [ 0 , 1 ] , i = min ( ⌊ Δ x x − x 0 ⌋ , n x − 2 ) Order potential: 2, field: 2 Assumes a regular grid; potential and field interpolated separately, so E = − ∇ ϕ \mathbf E = -\nabla\phi E = − ∇ ϕ holds only to the interpolation error points outside the grid take the value at the nearest edge