kicad2ems.pcbqs.circuit.supply

What a circuit draws from its supply, for the other tools: a rail's loads for
the power-integrity tool (pcbqs.pdn --load REF=AMPS, --load-spectrum REF=FILE)
and a converter's input current for the near-field tool (pcbqs.mqs --spectrum
FILE).

    rows = currents(model, result, period)  # engine.run_case calls it; a case's
                                            # 'supply'
    write(folder, rows)                     # <case>/supply-<footprint>.csv,
                                            # their names into the rows

A supply node is one a DC voltage source is on (its + side; the other on
ground). Every other part with a pin on it draws a current from it, but the
capacitors: they are the rail's own decoupling, which a model of the rail has as
parts. Where all the source feeds is one inductor or resistor in series to a
node its capacitors hold (an input filter; a boost's inductor feeds its switch,
which no capacitor holds, and is a load), the rail is the node behind it, as far
as such parts lead: its loads are drawn from there, and the row says which
footprints the way passes on the board (through) and their DC resistance (dcr),
so a model of the rail has them (pcbqs.pdn --through, --dcr). A part's current
is taken at its pin on the node, over the last period: its average (the rail's
DC load) and its harmonics, i(t) = avg + sum A_n cos(2 pi n t / period +
phase_n). Parts on one footprint (a regulator's switches) are one load, their
currents added.

    [dict(node='in', net='+5V', rail_net='+5V', source='V1',
          source_footprint=None, volts=5.0,
          capacitors=['C704', 'C705', 'C706'], through=[], dcr={}, loads=[
        dict(footprint='U702', parts=['QH'], avg_A=1.40, rms_A=1.67,
             f_Hz=[...], A=[...], deg=[...], file='supply-U702.csv')])]

(net: the board's net of the source's node, where a model of the rail starts;
rail_net: the board's net of the node the loads are on (behind a filter:
another). capacitors: the node's capacitors to ground, by footprint: a
near-field run's input capacitors. source_footprint: the supply's own footprint,
when the model has a board and does not put the supply off it: the rail's
source.)

The CSV: f_Hz, A (peak), deg, a line a harmonic. Harmonics above HARMONICS are
left out; the samples of a period (engine: 1024, or
analysis.final_samples_per_cycle) carry them without aliasing.
kicad2ems.pcbqs.circuit.supply.currents(model, result, period, harmonics=40)[source]
The supply rows of a resolved model's reported run (result: {signal:
samples}, uniformly sampled).
kicad2ems.pcbqs.circuit.supply.read_spectrum(path)[source]
A current spectrum file: (f Hz, complex peak amplitudes), i(t) = Re sum
A_n exp(2 pi i f_n t). Columns f_Hz, A (peak) and, optionally, deg; a header
line and lines that start with # are skipped. ValueError says what is wrong
with it.
kicad2ems.pcbqs.circuit.supply.waveform(f, a, samples=512)[source]
(whether the frequencies are harmonics of the lowest, peak-to-peak) of
v(t) = Re sum a_n exp(2 pi i f_n t): over the lowest's period when they are
its harmonics; otherwise the bound 2 sum |a_n|, which no alignment of the
phases exceeds.
kicad2ems.pcbqs.circuit.supply.write(folder, rows)[source]
Each load's harmonics as <folder>/supply-<footprint>.csv; the rows with
the files' names (their f_Hz, A and deg stay in the CSV alone).