kicad2ems.core.lines.xsection

A 2D quasi-static field solver for line cross-sections: the per-unit-length
Maxwell capacitance of N conductors over planes, in any stack of dielectrics,
with and without the dielectric (C, C_air), and from them L, Z0, eeff and the
even / odd modes of a pair. It covers what the closed-form formulas cannot:
coplanar ground under solder mask or between two planes, coupled lines with
copper thickness, mask that follows the trace, coupling beyond the nearest
neighbour, mixed dielectrics.

The method: Laplace's equation div(er grad phi) = 0 on a mesh of rectangles,
bilinear finite elements, the box around the copper grounded. The cells start on
the key lines (copper edges, layers, planes) and are halved in x or z only where
they are larger than a size that grows away from the copper's corners, so a
corner's fine cells stay near it and long thin cells fill the layers (mom25d's
mesher in 2D: cells growing from the features, edges kept fine). A node on a
coarser neighbour's side is tied to that side's ends, and the matrix reduced to
the nodes left, T^T K T (as quads.py reduces mom25d's). The charge on a
conductor is the net flux out of its nodes, so C is symmetric. Dielectric loss
is the perturbation G / w = eps0 Phi^T K_tand Phi of the lossless solution. The
tensor grid the solver began on is what potential() and finish.loss_share solve
on.

    xs = CrossSection(dielectrics=[Dielectric(0.0, 0.2, 4.3, 0.02)],
                      planes=[0.0])
    xs.conductor(-0.175, 0.175, 0.2, 0.235)  # a 0.35 mm strip, 35 um copper
    r = xs.solve()
    z0, eeff = r.single()                    # one conductor
    f = field(xs)                            # the field, to look at:
                                             # f.sample(...), on the mesh
    C, Ca = r.C, r.Ca                        # F/m, N x N
                                             # (coupled.mtl_s takes them)

    microstrip(0.35, 0.2, 4.3, t=0.035).solve().single()
        # the common cross-sections, built
    coupled_microstrip(0.15, 0.15, 0.2, 4.3).solve().pair()
        # (Ze, Zo, eeff_even, eeff_odd)

Units: mm for the geometry, SI for the results (C, L, G per metre).
Quasi-static: no dispersion and no conductor loss. Copper outside the box, and
plane thickness, are not modelled (a plane is a sheet at the height given, its
surface facing the lines).
class kicad2ems.core.lines.xsection.Conductor(x0: float, x1: float, z0: float, z1: float, ground: bool = False)[source]
A rectangle of copper (mm): a signal conductor, or ground (coplanar
ground, held at 0 V; x0 or x1 may be infinite: to the side of the box).
class kicad2ems.core.lines.xsection.CrossSection(dielectrics: list = <factory>, planes: list = <factory>, conductors: list = <factory>)[source]
Planes (heights of full-width ground sheets), dielectrics (later ones
paint over earlier ones; air elsewhere) and conductors. Signal conductors
are numbered in the order they were added.
conductor(x0, x1, z0, z1=None, ground=False)[source]
Add a rectangle of copper (z1 None: a zero-thickness strip at z0).
to_dict()[source]
The cross-section as plain numbers, for a JSON file (from_dict reads
it); an infinite end is None.
class kicad2ems.core.lines.xsection.Dielectric(z0: float, z1: float, er: float, tand: float = 0.0, x0: float = -inf, x1: float = inf)[source]
er and tan d between heights z0 and z1 (mm), from x0 to x1 (a layer by
default: the whole width).
class kicad2ems.core.lines.xsection.Field(cell, v, er)[source]
A solved potential on the mesh: cell (n, 4: x0, x1, z0, z1, mm), v (n, 4:
the volts at its corners (x0, z0), (x1, z0), (x1, z1), (x0, z1)), er per
cell. Copper has no cells.
energy()[source]
The stored energy (J/m): 1/2 C V^2 of these volts, on this one
mesh.
sample(x0, x1, z0, z1, nx, nz)[source]
(x, z, phi, ex, ez, er) at the centres of nx x nz pixels of a window,
each array (nx, nz): the potential (V), the field (V/mm, -grad phi
inside the cell: its normal part steps at a dielectric, as it does), er.
NaN in copper and beyond the box.
class kicad2ems.core.lines.xsection.Result(C: ndarray, Ca: ndarray, G_w: ndarray, nodes: int = 0)[source]
C, Ca (F/m, N x N Maxwell matrices with and without the dielectric), G_w
(S/m per rad/s: G = w G_w).
property L[source]
Inductance matrix (H/m): mu0 eps0 Ca^-1.
pair()[source]
(Ze, Zo, eeff_even, eeff_odd) of a symmetric pair (conductors 0 and
1), as coupled.coupled gives them; the differential impedance is 2 Zo,
the common-mode Ze / 2.
single(i=0)[source]
(Z0, eeff) of conductor i alone, the others held at ground.
tand_eff(i=0)[source]
Effective loss tangent of conductor i's line: G / (w C).
kicad2ems.core.lines.xsection.coupled_microstrip(w, s, h, er, t=0.0, **kw)[source]
A symmetric edge-coupled microstrip pair: strips w, gap s (Result.pair()
gives the modes).
kicad2ems.core.lines.xsection.coupled_stripline(w, s, h1, h2, er, t=0.0, **kw)[source]
A symmetric edge-coupled stripline pair between planes (h1 below the
strips, h2 above them).
kicad2ems.core.lines.xsection.field(xs, volts=None, air=False, grow=None)[source]
The Field of a CrossSection on its mesh, the signal conductors at `volts`
(default 1 V on the first, 0 on the others; [1, -1]: a pair's odd mode),
every ground at 0; air: without the dielectric; grow: the mesh's grading, if
not MESH_GROW. One solve (no extrapolation): for looking at the field;
solve() is what gives the numbers.
kicad2ems.core.lines.xsection.microstrip(w, h, er, t=0.0, tand=0.0, mask=0.0, er_mask=3.5, s=None, wg=None, gap=0.0)[source]
Microstrip w wide on a substrate h thick over a plane (one strip; widths
and gap below for more). mask: solder mask thickness over the substrate and
the copper (following the strip); s: coplanar ground s from each side
(grounded CPW), wg wide (None: to the box). Pass w as a list (and gap as a
list or one value) for coupled strips.
kicad2ems.core.lines.xsection.mode(c, ca)[source]
(Z0, eeff) of a line's mode from its capacitance per metre c, and ca
without the dielectric.
kicad2ems.core.lines.xsection.potential(xs, volts=None, air=False)[source]
(x, z, phi, er): the grid lines (mm), the potential on its nodes (len(x),
len(z)) with the signal conductors at `volts` (default 1 V on the first, 0
on the others; [1, -1]: a pair's odd mode) and every ground at 0, and er per
cell; air: without the dielectric. One solve on the grid (no extrapolation):
for looking at the field.
kicad2ems.core.lines.xsection.snap(v, rel=None)[source]
v on a log scale of steps 1 + rel (SIMILAR by default), at the middle of
its step: values within rel / 2 of a step's middle become it. 0 and
infinities are kept, the sign too.
kicad2ems.core.lines.xsection.solve(xs)[source]
The Result of a CrossSection: on the mesh, and on the mesh with its
grading and corner cells twice as coarse, extrapolated (MESH_MIX: within 0.3
% of a converged solve on a real board's cuts, where the mesh alone is up to
0.7 % low; without the coarser solve, REFINE = False, 30 % faster).
kicad2ems.core.lines.xsection.stripline(w, h1, h2, er, t=0.0, tand=0.0, s=None, wg=None, gap=0.0)[source]
A strip h1 above one plane, its top h2 below the other (centred when h1 =
h2 + ...: offset otherwise), in one dielectric; s, wg, w as a list and gap
as for microstrip.
kicad2ems.core.lines.xsection.window(xs)[source]
(x0, x1, z0, z1): what is worth looking at, of a cross-section whose box
may be many times larger: the signal conductors and a few heights of the
nearest copper to either side, up to the planes that close the box.