> ## Documentation Index
> Fetch the complete documentation index at: https://docs.hardwave.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Standard Library

> Reference for Hardwave's 30 built-in signal types and 28 primitive components

Import `hardwave.stdlib` to register all standard-library types and components with the global registries. You do not need to import submodules individually.

```python theme={null}
import hardwave
import hardwave.stdlib

from hardwave.types import TypeRegistry
from hardwave.components import ComponentRegistry

# List all registered types
for t in TypeRegistry.instance().list_types():
    print(f"{t.name:25s} {t.unit}")

# List all component categories
print(ComponentRegistry.instance().list_categories())
```

## Signal types (30)

### Electrical

| Name            | Unit   | Description                       |
| --------------- | ------ | --------------------------------- |
| `DCVoltage`     | V      | DC electrical potential           |
| `ACVoltage`     | V\_rms | AC RMS voltage                    |
| `Current`       | A      | Electrical current                |
| `Resistance`    | Ω      | Electrical resistance             |
| `Capacitance`   | F      | Capacitance                       |
| `Inductance`    | H      | Inductance                        |
| `Power`         | W      | Electrical power                  |
| `Frequency`     | Hz     | Signal frequency                  |
| `AnalogSignal`  | V      | Generic analog 0-5V               |
| `PWMSignal`     | -      | dict `{frequency_hz, duty_cycle}` |
| `DigitalSignal` | -      | 0 or 1                            |
| `I2CBus`        | -      | dict `{sda, scl, address, data}`  |
| `SPIBus`        | -      | dict `{mosi, miso, sclk, cs}`     |
| `UARTStream`    | -      | dict `{baud_rate, data}`          |

### Mechanical

| Name              | Unit  |
| ----------------- | ----- |
| `Torque`          | N·m   |
| `AngularVelocity` | rad/s |
| `AngularPosition` | rad   |
| `LinearForce`     | N     |
| `LinearVelocity`  | m/s   |
| `LinearPosition`  | m     |
| `Pressure`        | Pa    |
| `MechanicalPower` | W     |

### Thermal

| Name                | Unit |
| ------------------- | ---- |
| `Temperature`       | °C   |
| `HeatFlux`          | W/m² |
| `ThermalResistance` | °C/W |

### Control and data

| Name            | Unit        |
| --------------- | ----------- |
| `ControlSignal` | - (0.0-1.0) |
| `BooleanSignal` | -           |
| `Timestamp`     | s           |
| `ByteArray`     | -           |
| `JSONPayload`   | -           |

## Components (28)

### Electrical / Passive

| Component       | Key Ports                                               | Solver              |
| --------------- | ------------------------------------------------------- | ------------------- |
| `Resistor`      | voltage → current, power                                | Formula (Ohm's Law) |
| `Capacitor`     | current → voltage, stored\_energy                       | ODE (dV/dt = I/C)   |
| `Inductor`      | voltage → current, stored\_energy                       | ODE (dI/dt = V/L)   |
| `Diode`         | anode\_voltage, cathode\_voltage → current, power\_loss | Formula (Shockley)  |
| `VoltageSource` | set\_voltage → voltage\_out                             | Formula             |
| `CurrentSource` | set\_current → current\_out                             | Formula             |
| `Ground`        | - → voltage (0V)                                        | Formula             |

Import from `hardwave.stdlib.components.passive`.

### Electrical / Active

| Component          | Key Ports                                      | Solver                        |
| ------------------ | ---------------------------------------------- | ----------------------------- |
| `NPNTransistor`    | base\_current, vce → collector\_current, power | Formula (piecewise)           |
| `NMOSFET`          | gate\_voltage, vds → drain\_current, power     | Formula (square-law)          |
| `OpAmp`            | v\_plus, v\_minus, supply → v\_out             | Formula (ideal, rail-clamped) |
| `VoltageRegulator` | v\_in, load\_current → v\_out, power\_loss     | Formula                       |

Import from `hardwave.stdlib.components.active`.

### Electromechanical

| Component        | Key Ports                                                                              | Solver                                   |
| ---------------- | -------------------------------------------------------------------------------------- | ---------------------------------------- |
| `DCMotor`        | voltage, load\_torque → angular\_velocity, current, winding\_temp, health, fault\_code | ODE (coupled E-M-T; thermal fault rules) |
| `StepperMotor`   | step\_pulses, load\_torque → angular\_position, current                                | Discrete                                 |
| `ServoMotor`     | pwm\_signal, load\_torque → angular\_position, current                                 | Discrete                                 |
| `BrushlessMotor` | phase\_voltages, load\_torque → angular\_velocity, phase\_currents                     | ODE                                      |
| `LinearActuator` | pwm\_signal, load\_force → linear\_position, current                                   | ODE                                      |

Import from `hardwave.stdlib.components.motors`.

### Sensors

| Component           | Key Ports                                           | Solver                    |
| ------------------- | --------------------------------------------------- | ------------------------- |
| `TemperatureSensor` | ambient\_temperature → analog\_out                  | Formula + Gaussian noise  |
| `IMU`               | linear\_acceleration, angular\_velocity → i2c\_out  | Formula                   |
| `Encoder`           | angular\_position → pulse\_count, angular\_velocity | Formula                   |
| `UltrasonicSensor`  | target\_distance → pulse\_out                       | Formula + noise + latency |
| `Camera`            | scene\_description → image\_frame                   | Placeholder (V2)          |

Import from `hardwave.stdlib.components.sensors`.

### Microcontrollers

| Component     | Key Ports                                              | Solver                           |
| ------------- | ------------------------------------------------------ | -------------------------------- |
| `Arduino`     | gpio\_inputs → gpio\_outputs, uart                     | Firmware callable (signal-level) |
| `ESP32`       | gpio\_inputs, wifi\_rx → gpio\_outputs, wifi\_tx, uart | Firmware callable                |
| `RaspberryPi` | gpio\_inputs → gpio\_outputs, uart, i2c, spi           | Firmware callable                |

Import from `hardwave.stdlib.components.mcu`.

<Info>
  MCU firmware is modelled at the signal level: what values appear on pins at each time step. Pass a Python callable as the `firmware` parameter to drive GPIO outputs. Actual code execution is a V2 feature.
</Info>

### Power

| Component        | Key Ports                                                                                      | Solver                                                    |
| ---------------- | ---------------------------------------------------------------------------------------------- | --------------------------------------------------------- |
| `LiPoCell`       | charge\_current, discharge\_current → terminal\_voltage, soc, temperature, health, fault\_code | ODE (SOC/thermal; over-discharge & thermal damage faults) |
| `BatteryPack`    | charge\_current, discharge\_current → terminal\_voltage, capacity\_ah                          | Composite                                                 |
| `BuckConverter`  | v\_in, duty\_cycle, load\_current → v\_out, efficiency                                         | Formula                                                   |
| `BoostConverter` | v\_in, duty\_cycle, load\_current → v\_out, efficiency                                         | Formula                                                   |

Import from `hardwave.stdlib.components.power`.

<Info>
  `DCMotor` and `LiPoCell` include runtime fault detection. See [Component Faults and Health](/guides/component-faults) for fault codes, rated-limit parameters, and degraded output behaviour.
</Info>

## Using stdlib components

```python theme={null}
from hardwave.simulation import SimulationGraph, SimulationEngine
from hardwave.stdlib.components.passive import VoltageSource, Resistor

graph = SimulationGraph()
graph.add_component(VoltageSource("vs", param_values={"voltage": 9.0}))
graph.add_component(Resistor("r1", param_values={"resistance": 1_000.0}))
graph.connect("vs", "voltage_out", "r1", "voltage")

result = SimulationEngine(graph).run(inputs={})
print(result.get_output("r1", "current"))
```

For high-fidelity models beyond the open-source library, see [Premium Components](/premium).
