circuit
An electrical circuit simulated by ngspice 47 (the open-source SPICE; built from its pinned source tarball by install.sh): what reaches a load over time.
The circuit is a small JSON netlist (named nodes; resistors, capacitors, inductors, diodes from a small library or with stated model parameters, timed switches, voltage and current sources as DC, sine, pulse, piecewise-linear or a sampled waveform from a CSV file of an earlier run; raw SPICE lines as an escape).
Analyses operating point, transient (duration and step), AC sweep.
Measures, named by the caller (measures.<name>): a node's voltage, a part's current or power (every part is sensed by a 0 V source in series), as mean, RMS, peak, min, max, final, value at a time, time to reach a level, integral (energy); AC: peak, peak frequency, -3 dB bandwidth, Q. A criterion on one measure gives the verdict.
Transients carry an energy balance (net source energy against dissipated plus stored).
Files waveforms.csv (every node voltage and part current; envelope-decimated when long), plot.png, deck.cir (the SPICE deck as run).
- Field
- Waves, optics and circuits
- Version
- 0.1.0
- Runs as
- Compiled (Rust)
- Typical run
- 5 s
Compiled from source: run sh packs/install.sh once before admitting it.
A real run
- v at one time constant
- 0.6321 V
- time to 0.9 V
- 2.303 ms
- energy lost in R
- 0.5 µJ
- simulator
- ngspice-47
Known answers it must pass
r0001divider operating point: 10 V over 1 kΩ + 3 kΩ gives 7.5 V, 2.5 mA, 18.75 mW in the 3 kΩ, -25 mW in the source (Ohm's law; to 10⁻⁹)passed
measures.v_mid= 7.5, within 1.000000 × 10⁻⁹ relativereading not recorded on this pagemeasures.i_r1= 0.0025, within 1.000000 × 10⁻⁹ relativereading not recorded on this pagemeasures.p_r2= 0.01875, within 1.000000 × 10⁻⁹ relativereading not recorded on this pagemeasures.p_v1= -0.025, within 1.000000 × 10⁻⁹ relativereading not recorded on this pager0002RC step, 1 kΩ, 1 µF, 1 V from empty: v(τ) = 1 - 1/e, time to 0.9 V = τ ln 10, source energy C V² (1 - e⁻⁵) over 5 τ (closed forms; 10⁻⁵, 10⁻⁵, 10⁻⁴), energy balance to 10⁻⁵, criterion metpassed
measures.v_tau= 0.632121, within 1.000000 × 10⁻⁵ relativereading not recorded on this pagemeasures.t_90= 0.002303, within 1.000000 × 10⁻⁵ relativereading not recorded on this pagemeasures.e_source= -9.932621 × 10⁻⁷, within 0.01 %reading not recorded on this pageenergy_balance_error≤ 10⁻⁵1.25408 × 10⁻⁷lockedinside the rangeok= truetruelockedexact matchr0003series RLC, 10 Ω, 10 mH, 1 µF, AC sweep of the current: resonance 1/(2 π √(LC)) = 1591.549 Hz (10⁻⁵), peak 1/R (10⁻⁵), Q = √(L/C)/R = 10 and -3 dB bandwidth R/(2 π L) (5 × 10⁻⁴: the -3 dB points are interpolated between sweep points 0.23 % apart)passed
measures.f0= 1591.549431, within 1.000000 × 10⁻⁵ relativereading not recorded on this pagemeasures.ipk= 0.1, within 1.000000 × 10⁻⁵ relativereading not recorded on this pagemeasures.q= 10, within 0.05 %reading not recorded on this pagemeasures.bw= 159.154943, within 0.05 %reading not recorded on this pager0004half-wave rectifier, 1000 V peak, ideal diode, 10 kΩ: mean output Vp/π (closed form; 5 × 10⁻⁴: the ideal-enough diode drops about 0.03 V at 0.1 A)passed
measures.vmean= 318.309886, within 0.05 %reading not recorded on this pageenergy_balance_error≤ 10⁻⁶4.08579 × 10⁻¹⁵lockedinside the ranger0005full-wave bridge, 1000 V peak, four ideal diodes, 10 kΩ: mean output 2 Vp/π (closed form; 5 × 10⁻⁴, two diode drops)passed
measures.vmean= 636.619772, within 0.05 %reading not recorded on this pager0006half-wave rectifier with a smoothing capacitor, 100 V peak at 50 Hz, 100 µF, 10 kΩ: ripple against the standard approximation Vp/(f R C) = 2.0 V (6 %: the approximation lets the capacitor discharge for a whole period at constant current; it recharges for about 3 % of it and decays exponentially, so it runs about 4 % high), energy balance to 10⁻⁴passed
measures.ripple= 2, within 6 %reading not recorded on this pageenergy_balance_error≤ 0.00011.40112 × 10⁻⁶lockedinside the ranger0007piezoelectric source into a full-bridge rectifier at half its open-circuit voltage: 0.1 mA sine at 100 Hz beside 1 nF, ideal diodes, into a 79.6 V store: power f Ip²/(w² Cp) = 2.533 mW (Shu and Lien 2006, Smart Mater. Struct. 15 1499, eq. for the standard interface; 2 × 10⁻³: two diode drops against 80 V)passed
measures.p_store= 0.002533, within 0.2 %reading not recorded on this pageenergy_balance_error≤ 10⁻⁵4.10749 × 10⁻¹⁰lockedinside the ranger0008PWL ramp 0 to 1 V in 1 ms across 1 µF draws C dV/dt = 1 mA (10⁻⁶); a 1 µF capacitor charged to 1 V (ic) switched at 1 ms onto 1 kΩ is at 1/e at 2 ms (10⁻⁵); energy balance 10⁻⁵passed
measures.i_ramp= 0.001, within 1.000000 × 10⁻⁶ relativereading not recorded on this pagemeasures.v_b_2ms= 0.367879, within 1.000000 × 10⁻⁵ relativereading not recorded on this pageenergy_balance_error≤ 10⁻⁵1.46135 × 10⁻⁷lockedinside the range
Each line is one reading the kernel checked. The bright band is the tolerance; the needle is the value the instrument actually returned when it was admitted. A needle near the centre line used little of its tolerance.
Inputs
| Name | Unit | Default | Meaning |
|---|---|---|---|
circuit | The netlist: {ground?: "0", parts: [...]}. Nodes are named (letters, digits, _; "0" or "gnd" is ground; SPICE ignores case). Parts, each with a unique name: {type: resistor|capacitor|inductor, between: [n₁, n₂], value (ohm, F, H), ic? (V or A, starting value)}; {type: diode, anode, cathode, part: ideal|BAS70 or model: {IS, N, RS, CJO, VJ, M, BV, IBV, TT, EG, XTI, ISR, NR...} with source: where the figures come from, leak_ohm?: a resistor across it}; {type: switch, between, closed: [[t_on, t_off], ...] or wave (closed while > 0.5), r_on? 10⁻³, r_off? 10¹²}; {type: voltage_source, plus, minus, wave, ac?}; {type: current_source, from, to, wave, ac?} (pushes current into node 'to'); {type: spice, lines: [raw SPICE]} (escape hatch: parts and models only). Waves: {dc: x}, {sine: {amplitude, frequency_Hz, offset?, phase_deg?, delay_s?}}, {pulse: {low, high, width_s, period_s?, delay_s?, rise_s?, fall_s?}}, {pwl: [[t, x], ...], repeat?}, {csv: {time: column, value: column, scale?, time_from_zero?, repeat?}} (file: wave_file). Every number may be a string naming a params entry or an expression over them. Plain numbers only: 10⁻⁶, never 1u (SPICE suffixes are not read; M would be milli). | ||
circuit_file | The netlist as a JSON file instead of circuit. | ||
wave_file | A CSV file for a source with wave {csv: {time, value}} (e.g. an earlier run's history.csv). | ||
params | {} | Named numbers (or expressions over earlier ones) that the netlist, the analysis and the criterion may use: {"Vs": 3.0, "Ip": "2 · Vs / 10⁶"}. Sweep them with bench sweep --grid=params.Vs=... | |
analysis | Default {type: op}. {type: op} | {type: tran, duration_s, step_s (print step and default largest step), max_step_s?, start?: auto|op|zero (zero: everything starts empty unless it has ic; auto: zero when any part has ic, else from the operating point), save_from_s?} | {type: ac, from_Hz, to_Hz, points_per_decade? 100} | ||
measures | Default none (an operating point still lists every node voltage and part current in op). [{name, of: v(node) | v(a,b) | i(part) | p(part), stat, ...}]. Transient stats: mean, rms, max, min, peak (largest |x|), peak_to_peak, final, initial, change (end of the window minus its start), at (time_s), time_to (level, direction rise|fall|either, after_s), integral (J for p()); window from_s/to_s or last_s. AC (magnitude): peak, peak_frequency, bandwidth, q, at (frequency_Hz), phase_at. Op: value. i(part) is the current into the part's first terminal (between[0], anode, plus, from); p(part) the power it absorbs (sources delivering: negative). | ||
criterion | A test on one measure for the verdict: {measure, at_least? | at_most? | within?: [lo, hi], text?: "reaches 1.8 V within 60 s"}. A level never reached (null) fails. | ||
options | {} | Simulator options: reltol (10⁻³), abstol (10⁻¹² A), vntol (10⁻⁶ V), gmin (10⁻¹² S: lower it, e.g. 10⁻¹⁵, when pA leakage matters), chgtol, itl4, method (trap|gear). | |
temperature_C | Circuit temperature (SPICE temp; models are given at 27°C). Diode leakage grows fast with it. | ||
energy_balance | true | Transient energy balance (needs every vector saved: off when keep is measured). | |
keep | all | Which vectors the simulator saves: all, or only what measures and plot need (long runs). | |
plot | Quantities to plot (default: those the measures use), e.g. ["v(out)", "i(RL)"]. | ||
title | The plot's title. | ||
csv_max_rows | 20000 | Rows of waveforms.csv before it is envelope-decimated. | |
timeout_s | s | 3000 | Wall time allowed to ngspice. |
Readings
| Name | Unit | Meaning |
|---|---|---|
measures | ||
measure_units | ||
figures | ||
ok | ||
criterion | ||
criterion_value | ||
energy_balance | ||
energy_balance_error | ||
op | ||
points | ||
duration_s | s | |
parts | ||
warnings | ||
waveforms.csv | ||
plot.png | ||
deck.cir |
Try the call
Change a value and the command updates. Nothing runs here; paste it into your terminal or give it to your agent.