kicad2ems.mom25d.looptree

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
class kicad2ems.mom25d.looptree.LoopTree(sim)[source]
The loop/tree basis of a Simulation's unknowns (its Ne RWG edges, then
its via chains; no PEC-plane holes). Branch j is unknown j; after the
transform unknown j is branch j's loop (cotree) or itself (tree).
charge_into(Z, Mq, area, f0=0)[source]
Z[tree, tree] += A_T^T Gc A_T: the potentials of the tree branches'
charges (+1 on bu, -1 on bv, none on the ground), Gc = Mq / (area area)
(Mq: the G_q moments between the triangles, Nt x Nt; or, its columns
triangles f0 .. f0 + its width, those ends' part alone: the matrix by
blocks of triangles); the compiled core's.
charge_operator(sim)[source]
Q (Nt x N, sparse): the charge each basis unknown puts on the
triangles (an RWG edge +-l, a chain its fans' shares) - for checks: Q
Mmap K is zero on the loops.
cols(X)[source]
X <- X K in place (the compiled core's).
from_ideal(x)[source]
Mmap x: basis currents (RWG coefficients, via currents) of branch
currents.
from_tree(x)[source]
K x (N or N x m): the branch currents of loop and tree amplitudes.
rhs(E)[source]
Mmap^T E (N x m).
rows(X)[source]
X <- K^T X in place (N x m, C order): a loop's row is its branch's
plus the tree path's, from the prefix P[node] = P[parent] + sign
X[branch up] (the sum over the node's path to its root); the compiled
core's.
scales(w)[source]
s: 1/sqrt(jw) on the loops, sqrt(jw) on the tree.
to_ideal(Z, scale_rows=None)[source]
Z <- Mmap^T Z Mmap in place (N x N): unit branch currents. Mmap =
diag(dl) (I + F): the coefficients' scale, then the fan paths (only the
via chains' rows and columns). scale_rows(fn): _row_blocks, to scale on
several threads.
to_ideal_half(H)[source]
to_ideal on a half.Half of the symmetric Z, in place: the scale,
then the fan paths (Half.loop_transform: T = I + F on the fan edges'
rows and the via chains' columns, which alone change).
transform_half(H)[source]
H <- K^T H K in place, H a half.Half of the symmetric Z (to_ideal's
unit branch currents), never whole: 8 N^2 complex128 at the peak, not
16. With K = I + P (P: the tree paths, tree rows x loop columns), M_tt
= Z_tt, M_tc = Z_tc + Z_tt P and M_cc = Z_cc + Z_ct P + P^T M_tc: the
loops' block's Z_ct P first (step 1), then the tree rows' M_tc (2),
then P^T M_tc (3), each its rows' prefix over the tree's nodes
(tree_cols's) and each pass reading one region (tree-tree, tree-loop)
while it writes another (tree-loop, loop-loop): the compiled core's
lt_half_step, rows in parallel.