kicad2ems.pcbqs.thermal.transient

The board's temperature over time: C x' = q(t) - A x on grid.py's system (x the
rise over the ambient of every unknown, C the heat capacity of each, J/K),
each heat's share following a profile.

    prof = profile('pulse:2,8@1')       # on 2 s, off 8 s, from 1 s on
    prof(t), prof.before, prof.breaks(t_end)
    out = run(A, C, heats, profiles, t_end, read)   # dict(times_s, ...)

A profile multiplies one heat (a part's loss, the copper's) over time:

    step[:A,B][@T]        A before T (default 0), B from T (default 1)
    off[@T]               on until T, off from it (cooling)
    pulse:ON,OFF[,LOW,HIGH][@T]
                          HIGH (1) for ON s, LOW (0) for OFF s, repeating from
                          T; LOW before T
    <file>                rows of t_s, value (a .csv or .txt: commas, spaces or
                          tabs; # comments); linear between the rows, the first
                          row's value before it and the last's after

A file's values are the share itself, or watts where the caller says (the
thermal tool's --profile for a part: its loss over time). `before` is the value
at t < 0: what a run started from the steady state starts from.

The stepping is TR-BDF2 (Bank et al. 1985; Hosea and Shampine 1996): a
trapezoidal stage to t + gamma h, gamma = 2 - sqrt(2), then BDF2 to t + h. It is
second order and L-stable, so a step far longer than the copper's own time
constants damps them instead of ringing (the trapezoidal rule alone would), and
both stages take the one matrix (2 + sqrt 2) C / h + A, factored once for each
step length. Each step's local error is estimated from the stages' slopes
(Hosea and Shampine's, C^-1 (q - A x) at the three points: matrix-vector
products alone) against ATOL + RTOL x the largest rise: a step over it is taken
again at half the length, one well inside it lets the next double. The lengths
are a ladder of powers of two, so the factors are few and every pulse of a
train reuses them; those kept are held within a memory budget (cache_bytes), the
longest unused given up first, and an interval's last step, which ends on its
break, is solved by conjugate gradients preconditioned with the factor of the
rung below it. No step crosses a profile's break: within an interval each
profile is smooth, and the first step after a break is the last interval's
first.

A grid of more than DIRECT_MAX unknowns is run reduced (reduce): a factor per
step length of the Jetson carrier's 179,000 unknowns is 0.8 GB and 6 s, and a
pulse train wants a dozen (they had held 16 GB). The heats gathered by profile,
the start and the self-heating's direction are the inputs of a rational block
Krylov basis (moments at the steady state, whose factor the steady solve has,
and at two shifts set by the shortest stretch between breaks: two more
factors), the grid projected on it by congruence (PRIMA: passive, the steady
state exact) and diagonalised, and that model stepped as the grid would be, its
temperatures lifted back at each step. On the test boards it is within 1 mK of
the grid stepped itself at every break.

The self-heating of the copper (electrothermal.py): a heat may carry a slope,
dq/dx (W/K at each unknown: the copper's I^2 R at its resistance's temperature
coefficient), which its profile's square scales with it (a current profile);
the matrix is then A - level * diag(slope), the level held over each interval
at its middle value (exact for steps and pulses; a file's ramp moves it within
an interval, left out) and rounded to LEVELS so few matrices are factored.
class kicad2ems.pcbqs.thermal.transient.Profile(text, at, values, kind, period=None, watts=False)[source]
A heat's share against time (the module's docstring).
breaks(t_end)[source]
The times in (0, t_end) where it jumps or bends.
kicad2ems.pcbqs.thermal.transient.cache_bytes()[source]
The factors' memory budget: CACHE_MAX, or CACHE_SHARE of what is
available if less (at least one factor is always kept).
kicad2ems.pcbqs.thermal.transient.profile(text, watts=False)[source]
A Profile from its text (the module's docstring); watts: a file's
values are watts, not a share. ValueError says what is wrong.
kicad2ems.pcbqs.thermal.transient.reduce(A, C, heats, start=None, slope=None, factor0=None, shifts=(0.0,), moments=None)[source]
A reduced model of C x' = q(t) - (A - lev S) x (rational block Krylov,
PRIMA's congruence: Odabasioglu, Celik and Pileggi 1998) for a system too
large for a factor per step length: the inputs are the heats gathered by
their profile (those that move together are one), the start and the
self-heating's own direction; for each shift s, the moments (A + s C)^-1
(C (A + s C)^-1)^j of them, `moments` deep, made orthonormal. With V that
basis, V^T A V, V^T C V (positive definite: the congruence keeps it
passive and stable) and V^T S V, diagonalised (A_r w = lambda C_r w), so
the model is run's own form: A = diag(lambda), C = 1. It matches the
response's moments at each shift: at 0 the steady state exactly (any
profile's long-time limit), at the others the faster changes.

factor0: A's factor (the steady solve's), reused for the shift 0. Returns
dict(A, C, heats, start, slope (an m x m matrix, or None), T (n, m): the
temperatures of the model's coordinates, x = T z), size).
kicad2ems.pcbqs.thermal.transient.run(A, C, heats, t_end, read, start=None, slope=None, slope_heat=None, log=<built-in function print>, tol=None, lift=None)[source]
The temperature from x(0) = start (None: the ambient everywhere) to
t_end, s.

A: the (n, n) sparse system (W/K); C: (n,) J/K (0: no capacity, a part's own
node); heats: [(name, q (n,) W, Profile, square)] (square: the profile
scales it by its square, a current's); read(x, t) -> {name: value} what is
reported at each step (its parts' temperatures, the hottest copper); slope:
(n,) W/K, the self-heating of heat `slope_heat` (its name), scaled by that
heat's level, or an (n, n) matrix of it (a reduced model's); tol: K, each
step's local error (default ATOL + RTOL x the largest rise so far); lift(x)
-> the temperatures x stands for (a reduced model's coordinates: reduce),
for the error, the bound and read. Returns dict(times_s, values={name:
[..]} (read's, from t = 0), steps, rejected, factors, seconds).
kicad2ems.pcbqs.thermal.transient.time_constants(A, C, k=4, slope=None)[source]
The board's k longest time constants, s: the largest mu of C v = mu A v
(A symmetric positive definite; unknowns with no capacity are none of
them).