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'.