Skip to content

Circuit Preview (Summary and Graphviz)

Use the preview helpers to validate connectivity and generate a quick Graphviz-based diagram of nets and components (no schematic rendering).

Connectivity summary

print(c.summary())

Outputs a compact mapping of ref.port -> net, highlights nets with degree 1 and unconnected ports.

Graphviz rendering

dot = c.to_dot()
# render_svg() will call out to the `dot` binary if available; otherwise you can run dot manually:
ok = c.render_svg("circuit_preview.svg")  # requires 'dot' in PATH

If Graphviz isn't installed, you still get a .dot file:

dot -Tsvg circuit_preview.dot -o preview.svg

Example (RC low-pass):

Circuit preview

Netlist helpers

print(c.netlist_string())
# or
c.print_netlist()

Monte Carlo — quick export & plots

# run a Monte Carlo varying components (example only)
from cat.analysis.montecarlo import monte_carlo, NormalPct
from cat.analysis.core import TRAN

# mapping would be Component -> Dist (here pseudo-code)
# mc = monte_carlo(circuit, mapping, n=100, analysis_factory=lambda: TRAN('1e-6','1e-3'))

# export sampled parameters and the manifest
# mc.save_samples_csv('mc_samples.csv')
# mc.save_manifest_csv('mc_manifest.csv')

# compute a metric per run (example: final Vout) and plot
# metrics = [my_metric(r) for r in mc.runs]
# from cat.analysis.viz.plot import plot_mc_metric_hist, plot_param_vs_metric
# fig_hist = plot_mc_metric_hist(metrics, title='Gain distribution')
# fig_scatter = plot_param_vs_metric(mc.samples, metrics, param='R1')

Example outputs (generated by examples/mc_demo_plots.py):

MC Metric KDE

R1 vs Metric

Parameter matrix