Skip to main content
A SimulationGraph is a directed acyclic graph of component instances connected by typed ports. Hardwave validates wiring at construction time so type errors surface before any simulation runs.

Adding components

Each instance has a unique instance_id string used in connections and result queries.

Connecting ports

Each connect() call creates a directed edge from an output port to an input port.

Fan-out and fan-in

  • Fan-out: connect one output to many inputs (always allowed).
  • Fan-in: connect many outputs to one input only when the target port is declared with aggregating_input_port().

Connection rules

Hardwave enforces these rules at wiring time:

Aggregating Input Ports

Declare multi-connection ports and custom aggregation

Validation

Always validate before running:
validate() checks that every required input port is either:
  • Connected to an upstream output
  • Has a default value
  • Will be satisfied by an external input passed to run()
It also runs cycle detection (Kahn’s algorithm). Cycles raise GraphValidationError before simulation starts. Aggregating ports with min_connections raise INSUFFICIENT_CONNECTIONS when too few wires are present.
If you add extra components to a graph, every required port on every component must be satisfied at validation time, even if nothing is wired to that component’s outputs.

External inputs

Some ports are driven from outside the graph (ambient temperature, user commands, test fixtures):
Pass the same external inputs to validate() so validation matches the run configuration.

Editing graphs

During engine.run(), Hardwave calls graph.topological_order() to determine a safe evaluation sequence. For each component it collects input values from upstream outputs (aggregating multi-connection ports when declared), external inputs, or port defaults, calls the solver, and stores outputs for downstream components.

Next steps

Steady-State Simulation

Solve the graph once and read scalar outputs

Saving Graphs

Serialize, reload, and save snapshots to the cloud dashboard