Getting started Your first circuit

Your first circuit

This is examples/Diode/rectifier.hvr from the repository — a full-bridge rectifier, small enough to read end to end. It converts a 50 Hz AC source to DC through four diodes and an output filter.

The three lines at the top

Every entry file starts with directives, not code — see .save / .tran / .solver for the full list. Here: .save picks which nodes end up in the output CSV, .tran sets the transient run window (start, end, step, and an optional max-step ceiling), and .solver picks the integration method (bdf2 — see available solvers).

A reusable module

AC_Source is an analog module with generic parameters (amplitude, freq) and a declared port list (out_p, out_n). Inside it, plain C++-flavored expressions (sin(...), the built-in time) compute a signal that's driven onto the wires with voltage_source<>(v_sig)[...]. See Wires & components.

The top-level circuit

Every file needs exactly one module main<>(). It declares its wires, instantiates v_ac from the module above, instantiates four diodes imported from the standard library (diode.Diode<Is, n, Vt>), and closes the loop with a load resistor and a smoothing capacitor. gnd is the one wire name that's always in scope.

Run it

This compiles rectifier.hvr to a native binary (see The CLI), runs it, and writes simulation_output.csv with the nodes named in .saveac_in1, ac_in2, dc_out — one column per node, one row per saved time step.