Skip to content

Core concepts

Nimphel separates circuit meaning from simulator syntax. The core package contains a small intermediate representation that can be constructed directly, produced by a reader, modified with ordinary Python, and consumed by a writer.

Component ──creates──▶ Instance
                         │
                         ▼
Subcircuit ◀──────── Circuit
     │                   │
     └──── owns Elements ┘

Where to begin

  • Elements and ownership


    Learn which objects belong in a circuit, why elements have one owner, and when to use .clone().

    Elements and ownership

  • Components and instances


    Define reusable component factories, validate pins and parameters, and generate many fresh instances in Python loops.

    Components and instances

  • Circuits and subcircuits


    Build explicitly or with contexts, understand reference allocation, and compose reusable hierarchical definitions.

    Circuits and subcircuits

  • Semantic directives


    Represent analysis intent independently of simulator syntax and use raw directives only as a dialect-specific fallback.

    Semantic directives

Typical workflow

from nimphel import Circuit, Component, ComponentKind
from nimphel.writers import SpectreWriter

resistor = Component(
    target="resistor",
    pins=("p", "n"),
    kind=ComponentKind.RESISTOR,
    defaults={"r": "1k"},
)

with Circuit(name="divider") as circuit:
    resistor(("vin", "vout"))
    resistor(("vout", 0), r="2k")

circuit.get("R1").params["r"] = "10k"
circuit.validate_integrity()

print(SpectreWriter().dumps(circuit))

The manipulation guide develops the same workflow using a circuit loaded from a netlist.

Design principles

  • The ordered elements sequence is the source of truth.
  • A Component is reusable and creates a fresh Instance per call.
  • An Element belongs to at most one container.
  • References are allocated and managed by their containing scope.
  • Semantic models store intent; simulator syntax stays at the I/O boundary.
  • Unsupported syntax is explicit through RawDirective.
  • Validation failures are raised rather than silently repaired.

See the core reference for concise signatures and return values.