kicad2ems.pcbqs.circuit.model

The circuit model: its format, the values that are expressions, the sweep.

    model = load(path)                  # read and validate
    # ModelError naming what is wrong and where
    validate(model)
    for point in cases(model):          # the sweep's points: {path: value}
        # numbers everywhere: parameters and expressions worked out
        concrete = resolve(model, point)
    # a number of the model by its path
    get(model, 'drives.pwm.duty'), put(model, 'R1.value', 4.7)

format 2. A value may be a number, engineering notation ('22u', '4.7k', '100n')
or an expression over the model's parameters ('1/(2*pi*fsw*sqrt(L*C))'): + - * /
**, parentheses, pi, sqrt, abs, min, max, exp, log.

    {"format": 2, "name": "...", "description": "...",
     "parameters": {"fsw": 200e3},
     "parts": [{"ref": "L1", "type": "inductor", "nodes": ["in", "sw"],
                "value": "22u", "DCR_ohm": 0.03}, ...],
     "couplings": [{"inductors": ["L1", "L2"], "k": 0.98}],
     "drives": {"pwm": {"frequency_Hz": "fsw", "duty": 0.5, "phase_deg": 0,
                        "dead_time_s": 0}},
     "probes": {"vout": {"voltage": ["out", "0"]}, "il": {"current": "L1"}},
     "measures": {"vout_avg": {"avg": "vout"}},
     "targets": [{"adjust": "drives.pwm.duty", "range": [0.05, 0.95],
                  "measure": "vout_avg", "value": 24}],
     "sweep": {"R1.power_W": [6, 12, 24]},
     "analysis": {"cycles": 200}}

Parts, by type (nodes: two names; '0' or 'GND' is ground; the first is where a
part's current is taken as entering it, so its voltage times its current is the
power it absorbs):
    resistor   value
    capacitor  value, ESR_ohm, ESL_H, leakage_ohm, bias_factor
    inductor   value, DCR_ohm, ESL_H; or, with SRF_Hz / Cp_F / core_R_ohm, a
               winding with its self-capacitance and core loss; AC_R_ohm
               ([[f_Hz, R_ohm], ...]) and core_loss ({k, alpha, beta, turns,
               Ae_m2, Ve_m3}: Steinmetz, iGSE) add its AC resistance's and its
               core's loss after the run (windings.py)
    diode      nodes anode, cathode; model: Vf_V at If_A (0.7 V at 1 A), n,
               R_ohm, Cj_F, TT_s
    switch     nodes drain, source; drive (a drive's name), invert (its
               complement); model: as power_spice's switches (type switch |
               ideal | mosfet | vdmos | subcircuit, Ron_ohm, ...)
    source     nodes +, -; dc_V, or wave: {type: pulse | sine | pwl, ...}; or
               dc_A (a current source); R_ohm, L_H in series
    load       resistance_ohm, or power_W (constant power), or current_A
               (constant current); below min_V it is a resistor, so it starts
Any part: temperature_C (25 unless given) moves its resistances (and a diode's
Vf) from their values at 25 C, as temperature.py has it; board.temperature_C the
board copper's. pcbqs.circuit --warm sets them from the thermal model. A path
names a number: 'parameters.fsw', 'drives.pwm.duty', '<ref>.<field>' or
'parts.<ref>.<field>', '<ref>.model.<field>', 'couplings.0.k' (or
'couplings.L1+L2.k': the coupling of those two), 'analysis.cycles'.
exception kicad2ems.pcbqs.circuit.model.ModelError[source]
A model that cannot be run: says what and where.
kicad2ems.pcbqs.circuit.model.case_name(point)[source]
A folder name for a sweep point: 'R1-power-W=12_fsw=200k' ('run' with no
sweep); a parameter by its name, anything else by its path.
kicad2ems.pcbqs.circuit.model.cases(model)[source]
The sweep's points, every combination in the order given: [{path: value}]
([{}] with no sweep).
kicad2ems.pcbqs.circuit.model.number(value, names=None, where='value')[source]
A value as a float: a number, engineering notation, or an expression over
`names`.
kicad2ems.pcbqs.circuit.model.resolve(model, point=None)[source]
A copy of the model at one sweep point with numbers everywhere: the
point's values set, the parameters worked out (they may refer to each
other), then every value of the parts, couplings, drives, targets and
analysis. The probes and measures are left as written.
kicad2ems.pcbqs.circuit.model.signal_names(model)[source]
The signals a measure may use: the probes' names, every part's <ref>.V
and <ref>.I, and every node's voltage node.<name>; a winding's
<ref>.winding_I (its inductance's current, without its self-capacitance's)
and a capacitor's <ref>.cap_V (its capacitance's voltage, without its ESR's
and ESL's drops).
kicad2ems.pcbqs.circuit.model.templates()[source]
The example circuits shipped with pcbqs: {name: description}, in a
teaching order.
kicad2ems.pcbqs.circuit.model.validate(model)[source]
Check a model's shape: every part has a known type, two nodes and what
its type needs; every drive, probe, measure, target, coupling and sweep path
refers to something that exists. Values are checked when resolved (resolve),
since a sweep may set them. Returns the model.