kicad2ems.mom25d.sim

mom25d.sim - the general simulation object (stage 3)

    sim = Simulation(stack, shapes, ports=[...], vias=[...], lumped=[...],
                     dmax=...)
    res = sim.sweep(freqs)

shapes  : {interface: [rect (x0,y0,x1,y1) | shapely Polygon/MultiPolygon, ...]}
ports   : LinePort (wave port, de-embedded to a reference plane, any direction)
          GapPort  (lumped port across a strip, reference plane at the gap)
          ViaPort  (lumped port in a via, e.g. pad-to-ground)
vias    : Via(x, y, k_bot, k_top, radius)   k = 0 the bottom ground (an open
bottom: metal there), k = N a PEC cover lumped  : SeriesLumped (element across a
strip); Via(..., Z=...) puts an element inside a via metal   : Metal(sigma, t,
rough) -> surface impedance on strips, wall loss on vias (optional)

Unknowns: RWG edges on all metal layers, then one per via chain. Via-related
matrix blocks use the kernels from mom25d.via (validated against exact image
solutions); the via end charges are fan-distributed and enter through the same
G_q interaction as the strip charges.
class kicad2ems.mom25d.sim.DiffPort(pos, neg, zdiff=100.0, zcomm=25.0, name='P')[source]
Differential wave port on a pair of parallel feeds (positive / negative
line), e.g. an edge-coupled pair. Contributes two modal ports to the
S-matrix: '<name>d' (differential) and '<name>c' (common). Each mode is
fitted with its own propagation constant (odd/even modes of a symmetric
pair), so mode conversion and modal dispersion are captured.
  pos, neg : LinePort for each line (same direction, layer, sampling and
             reference plane)
  zdiff, zcomm : modal reference impedances (2 Z_odd and Z_even / 2 of the
             pair; see line_char_pair)
class kicad2ems.mom25d.sim.GapPort(layer, center, direction, width, z0=50.0, name='')[source]
Lumped port across a strip (delta gap). Reference plane = the gap.
class kicad2ems.mom25d.sim.Metal(sigma=58000000.0, t=3.5e-05, rough=0.0, finish=(), on=None)[source]
Conductor loss: Zs = (gamma/sigma) coth(gamma t), gamma = (1+j)/delta
(-> 1/(sigma t) at DC). rough (m RMS): its resistance times Hammerstad and
Jensen's factor 1 + 2/pi atan(1.4 (rough / delta)^2) at each frequency.
finish: a surface finish's metal layers, outermost first, [(sigma, t m),
...], on the interfaces of `on` ({interface: share}): there Zs times 1 +
share (F - 1), F the finished face's impedance over the bare one's (each
finish layer a line section Z_i = gamma_i / sigma_i loading the one beneath,
down to the copper), share the part of the strip's loss on its finished
faces (the outer face and the sides).
face_factor(f)[source]
The finished face's impedance over the bare copper face's at f.
zs(f, k=None)[source]
Zs at f; k: the interface (its finish, if any).
zs_edges(f, edge_layer)[source]
Zs per RWG edge (by its layer's interface): one value unless a finish
covers some interfaces.
class kicad2ems.mom25d.sim.ModePort(parent, mode)[source]
One mode of a DiffPort (internal): geometry of the positive line plus the
negative line.
class kicad2ems.mom25d.sim.SeriesLumped(layer, center, direction, width, Z, name='')[source]
Series element across a strip (cut line of the given width at
`center`).
class kicad2ems.mom25d.sim.Via(x, y, k_bot, k_top, radius=0.00015, Z=None, name='', ring=True)[source]
Plated via: axis (x, y), from interface k_bot to k_top, barrel radius. Z:
optional series element (callable f -> ohms) placed in the lowest chain
(e.g. a chip part to ground).
class kicad2ems.mom25d.sim.ViaPort(via, z0=50.0, name='', sign=1)[source]
Lumped port inside a via (EMF in its lowest chain, + toward the top;
sign=-1: + toward the bottom, a port whose reference plane is above it, so
the signal is + against its reference either way).
kicad2ems.mom25d.sim.balance(S, exact=None)[source]
(S made reciprocal, the ports' scales): a wave port's forward and
backward waves both carry the error of its characterised impedance (and of
whatever else scales its currents), so the S computed is D S D^-1 of the
true, symmetric one, D diagonal: transmission differs between directions by
d_i^2 / d_j^2 while reflections and the products S_ij S_ji are exact. The d
that fit |S_ij / S_ji| best are taken out, each pair weighted by |S_ij S_ji|
and every d held towards 1 with the weight BALANCE_FLOOR: ports that reach
each other only through weak terms (a filter's stop band, a pair's mode
conversion: noise) are left as they are; ports `exact` (lumped ones) are
held at 1. What is left of the asymmetry is averaged. rf_diffvia's pair on a
microstrip and a stripline: |Sdd21| 0.962 one way and 0.985 the other at
every frequency, 0.974 after.
kicad2ems.mom25d.sim.coupled_stripline_cohn(w, s, b, er)[source]
Exact Z_even, Z_odd of zero-thickness edge-coupled strips centred between
grounds spaced b.
kicad2ems.mom25d.sim.line_char_pair(stack, layer, w, gap, freqs, planes=None, length=0.016, dmax=0.0004, ncross=4, verbose=False, sides=None)[source]
Even/odd modes of a symmetric edge-coupled pair (strip width w, edge gap
`gap`) on `layer`, with optional reference metal (planes = {interface:
width}). Returns (gamma_e, Z_even, gamma_o, Z_odd); the DiffPort reference
impedances are Z_diff = 2 Z_odd and Z_comm = Z_even / 2. sides: as
line_char_xs.
kicad2ems.mom25d.sim.line_char_xs(stack, layer, w, freqs, planes=None, coplanar=None, via_pitch=0.001, via_r=0.00015, length=0.016, dmax=0.0004, ncross=4, verbose=False, sides=None)[source]
Zc and gamma of a strip of width w on `layer` with extra reference metal:
planes = {interface:
width} adds a centred wide strip on that interface (e.g. a meshed GND plane
above or below); coplanar = [(y0, y1), ...] adds same-layer ground strips
(grounded CPW), stitched to ground by a via row every via_pitch near their
inner edge. Centre-fed long line, travelling-wave fit. sides: the
Simulation's (thick copper's sides).
kicad2ems.mom25d.sim.rlc(R=0.0, L=0.0, C=None, parallel=False)[source]
Impedance function of a series (default) or parallel R-L-C element.