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.
Where to begin¶
-
Elements and ownership
Learn which objects belong in a circuit, why elements have one owner, and when to use
.clone(). -
Components and instances
Define reusable component factories, validate pins and parameters, and generate many fresh instances in Python loops.
-
Circuits and subcircuits
Build explicitly or with contexts, understand reference allocation, and compose reusable hierarchical definitions.
-
Semantic directives
Represent analysis intent independently of simulator syntax and use raw directives only as a dialect-specific fallback.
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
elementssequence is the source of truth. - A
Componentis reusable and creates a freshInstanceper call. - An
Elementbelongs 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.