kicad2ems.pcbqs.pdn.decoupling¶
pcbqs.pdn --choose-decaps: capacitors chosen for a rail's decap sites so the
impedance each load sees stays under its target over the band, with the fewest
parts (or the least cost).
python -m kicad2ems.pcbqs.pdn board.kicad_pcb --rail +1V15 --volts 1.15 \
--load U21=1 --choose-decaps --out pdn
python -m kicad2ems.pcbqs.pdn.decoupling --library [--json] [--volts 3.3]
# the parts it chooses from, and their capacitance at that bias
The sites are the rail's decap footprints (two-pad C* parts from its tree to
ground: rail.Rail.sites), fitted and unfitted (DNP), or those --decap-sites
names. A site's footprint fixes its package, and the PDN model its mount (its
pads' copper to the planes and the via pair: stack.RailPDN). Kept as fitted,
never changed: the parts --decap-keep names, a part with a vendor's file
(--cap-file), one whose package the library has no MLCC of (an electrolytic, a
polymer can).
The bare PDN (the planes, their ties, the series parts) between the loads and
the sites comes from the impedance sweep's own factorisation a frequency
(RailPDN.sweep(between=), or one of its own), the regulator and the kept parts
attached by Woodbury's identity as RailPDN.sweep does: Z (nf, k, k) over the
loads and the sites, at their plane nodes. A part of impedance z at site c (its
capacitance at the rail's DC bias, its ESR and ESL, the site's mount) changes
it by a rank-one term,
Z' = Z - Z[:, c] Z[c, :] / (z + Z[c, c])
(taking it off again: Z + Z[:, c] Z[c, :] / (z - Z[c, c]))
so every set of parts is closed in this form, with no new solve; a load sees
its diagonal entry plus its own pads' connection to the planes. A trial reads
only the loads' rows and the diagonal (Z is symmetric), so trying a part costs
O(nf n_loads) and taking one off for a trial O(nf n_loads k). The search is
deterministic:
1. greedy: from no part and from the fitted ones (the better of the two
kept; --decap-start empty or built: one), the part and site that lower the
excess most (per cost, --decap-mode cost), until every load is under its
target or no part lowers the excess by EARN of what is left;
2. then, until nothing changes: a part dropped where the rest still meet the
target; two parts replaced by one; a part moved to another site or value
where that raises the margin (so that a later drop may be possible), or
(cost) costs less.
The excess is the sum, over the loads and the band's frequencies, of
log(|Z| / target) where |Z| is over it, by log-frequency step. The target is
out of reach where a load's own connection to the planes (its pads and vias,
which no capacitor changes) is over it, or the floor is: an ideal part at
every site (its mount and its package's ESL, no capacitance and no ESR: what
any capacitor there tends to above its resonance; one at its resonance can dip
under it, but not over a band). Those frequencies are left out of the excess
and named in the result.
The library (library()): MLCC values 1 nF - 100 uF (E3) in each package's range
(PACKAGES); ESR from a typical curve, ESR_1U (C / 1 uF)^-0.4 (0.03 ohm at 100
nF, 5 mOhm at 10 uF); ESL by package (stack.ESL_PKG); X7R below 1 uF, X5R from
it; a relative cost by package and by how near the package's largest value it
is (cost()). --decap-library FILE replaces it: a CSV with a header of name,
package, C (and any of ESR, ESL, dielectric, volts, cost; values as '100n',
'4.7u' or numbers).
DC bias (share()): an MLCC keeps 1 / (1 + (V / Vh)^2) of its value at V volts,
Vh = V0 (Cmax / C)^(1/4) (Cmax: its package's largest value, the thinnest
layers: V0 = 2.4 V, so a part at its package's largest value keeps 35 % at 3.3
V, one a decade below 63 %, two decades 84 %), or a quarter of its rated
voltage where that is higher; C0G / NP0 keep all of it. These are typical
figures, not a vendor's: --derate-table FILE (a CSV of package, C, volts,
share; C empty for every value of the package) replaces them, interpolated in
volts. pcbqs.pdn --derate-bias takes the same curve for the fitted decaps.
- class kicad2ems.pcbqs.pdn.decoupling.Cap(name: str, package: str, C: float, ESR: float, ESL: float, dielectric: str = 'X7R', volts: float = 0.0, cost: float = 1.0, fitted: bool = False)[source]¶
A capacitor the search can place: its nominal value, ESR, ESL.
- class kicad2ems.pcbqs.pdn.decoupling.Choice(at: dict, Z: ndarray)[source]¶
A search state: the parts at the sites, the PDN with them attached.
- class kicad2ems.pcbqs.pdn.decoupling.Closure(pdn, f, loads, sites, fixed, bare=None, log=<built-in function print>)[source]¶
The bare PDN of a RailPDN between its loads and the sites, with the fixed parts (the regulator, the kept parts) attached: Z (nf, k, k) over [loads..., sites...] at their plane nodes; `own` (nf, n_loads), each load's own pads' connection, which reading Z at a load adds.
- attached(chosen)[source]¶
Z with the parts {site index: (nf,) impedance} attached (Woodbury: one small solve a frequency).
- class kicad2ems.pcbqs.pdn.decoupling.Search(cl, options, targets, band, mode='fewest', ideal=None, log=<built-in function print>)[source]¶
The deterministic search (the module docstring) over a Closure's band.
- excess(r)[source]¶
Sum over the band and the loads of log(r) over 1, log-f weighted: (...,) of r (..., nfb, nl).
- light(Z)[source]¶
(ZL, dg) of a full Z: the loads' rows (nfb, nl, k) and the diagonal (nfb, k), all a trial reads (Z is symmetric: a site's column at the loads is their rows').
- static off(ZL, dg, rows, c, zp)[source]¶
(ZL, dg, rows) with the part zp (nfb,) at column c taken off; rows: {column: its row of Z (nfb, k)}, c's and those of the parts to be taken off next (each updated, c's dropped). O(nfb nl k), where removed() is O(nfb k^2).
- trials(ZL, dg, sites, excess=True)[source]¶
For each site in `sites` and each of its options: (excess, worst) of the state (ZL, dg: light()) with that part added, arrays (len(sites), n_opt); excess False: (None, worst), all a feasibility test needs (excess 0 is worst <= 1). On |Z|^2 in the batch's own layout.
- kicad2ems.pcbqs.pdn.decoupling.choose(pdn, f, loads, targets, volts, sites=None, keep=(), lib=None, table=None, mode='fewest', start='both', fmax=None, bare=None, log=<built-in function print>)[source]¶
Capacitors for the sites of a RailPDN (built with sites=rail.sites()): the result as pdn.json's 'decoupling' (the module docstring). loads: the observed loads; targets {load: ohms or None}; sites: references (default: every decap and site the model has); keep: references kept as fitted; bare: RailPDN.sweep(f, between=every part)'s B, so that nothing is factorised again but the check's CHECKS frequencies.
- kicad2ems.pcbqs.pdn.decoupling.cost(pkg, C)[source]¶
A part's relative cost: its package's, more the nearer its value is to the package's largest (a 0402 100 nF ~1.1, a 0402 10 uF 4).
- kicad2ems.pcbqs.pdn.decoupling.dielectric_of(text)[source]¶
(dielectric, rated volts) a part's value or fields say ('10u X5R 6V3': ('X5R', 6.3)), '' and 0 where they do not.
- kicad2ems.pcbqs.pdn.decoupling.esr(C)[source]¶
A typical MLCC's ESR at its self-resonance, ohm (an assumption).
- kicad2ems.pcbqs.pdn.decoupling.figure(dec, out)[source]¶
decoupling.png: |Z| at each load as fitted (dashed) and with the parts chosen (solid), the targets, the band's top.
- kicad2ems.pcbqs.pdn.decoupling.fmt_c(C)[source]¶
'100n', '2.2u', '47p': a capacitance as a BOM writes it.
- kicad2ems.pcbqs.pdn.decoupling.library(packages=None, values=None)[source]¶
[Cap]: the built-in MLCCs, in `packages` (default all of PACKAGES), of `values` (F; default every E3 value in each package's range).
- kicad2ems.pcbqs.pdn.decoupling.parse_values(text)[source]¶
[F] of a comma-separated list of values ('100n,1u,10u').
share() of a fitted part p (a rail.Part) of value C: its package from its footprint, its dielectric and rating from its value and fields.
- kicad2ems.pcbqs.pdn.decoupling.read_derating(path)[source]¶
{(package, C or None): (volts array, share array)} of a CSV with a header package, C, volts, share (C empty: every value of the package).
- kicad2ems.pcbqs.pdn.decoupling.read_library(path)[source]¶
[Cap] of a CSV with a header: name, package, C and any of ESR, ESL, dielectric, volts, cost (missing: the built-in rules for its package).
The share of its value an MLCC keeps at a DC bias of `volts`: the table's (read_derating; its package and value, else its package) where it has one, else the module's curve.