mom25d.looptree - the loop/tree basis: the MPIE right down to low frequency
(pcbqs's basis, ported)
The MPIE's matrix has two parts that drift apart as the frequency falls:
Z = jw Z_A + Z_Q / (jw), Z_Q = Q^T Gc Q
Q the charge each unknown puts on the triangles (an RWG edge +-l on its two
triangles, a via chain its end charges spread over the fans of triangles around
it), Gc the potential between unit charges on two triangles. On a
divergence-free current Z_Q is zero, but in the RWG basis that zero is a
cancellation: once jw Z_A is below the precision's rounding of Z_Q / (jw), about
(k h)^2 of it (h a cell's size), the currents of the loops are lost. On the via
transition that is below ~100 MHz for a complex64 LU (mixed precision fell back
to double there) and ~5 kHz for double.
The loop/tree basis keeps the two apart, as pcbqs's PEEC does (pcbqs.mqs._loops,
pcbqs.peec):
graph a node per triangle and one for the ground (and the PEC cover: zero
potential, where a via ends with no fan); a branch per RWG edge (T+ to
T-) and per via chain (its bottom end to its top, each end on one
triangle of its fan, or the ground). A via's charge is spread over its
fan: its branch carries, besides its own current, small currents across
the fan that move the charge to that one triangle (the fan paths), so
every branch puts exactly +1 and -1 on two nodes
tree a spanning forest, breadth first from the ground (short paths); its
branches carry the charge
loops each other branch with the tree's path back: no charge at all, so Z_Q
is not in their rows or columns
The unknowns are those branches' currents (Mmap: an RWG coefficient is a current
per length, and a via's fan paths), then loop and tree amplitudes (K: a loop is
its branch plus the tree's path, a tree branch itself). With the loops scaled by
s = 1/sqrt(jw) and the tree by sqrt(jw), K_s = Mmap K diag(s):
M = K_s^T Z_A K_s + [[0, 0], [0, A_T^T Gc A_T]]
= [[Z_A,LL + S_LL/(jw), jw Z_A,LT + S_LT],
[jw Z_A,TL + S_TL, (jw)^2 Z_A,TT + jw S_TT + A_T^T Gc A_T]]
(Z_A here the current's part with the lumped elements and the metal loss S; A_T
the tree's incidence, +-1). As w -> 0 it tends to [[Z_A,LL, 0], [0, A_T^T Gc
A_T]]: inductance and elastance, each well conditioned, and nothing cancels. Z_A
is filled with the tables' charge side zeroed (the compiled core's tables), Gc
from fan_q over every triangle and the near pairs' corrections (near_q); neither
has the other's part, so M is right to rounding at any frequency
(fast.FastOperator._lt_system).
lt = LoopTree(sim) # the graph, once a mesh
lt.to_ideal(Z); lt.cols(Z, core); lt.rows(Z, core)
# Z <- K^T Mmap^T Z Mmap K, in place
lt.charge_into(Z, Mq, area, core) # + A_T^T Gc A_T on the tree (after the
# scaling)
u = lt.from_ideal(lt.from_tree(x)) # basis currents from loop and tree
# amplitudes