Skip to main content

High-performance circuit simulator for power electronics

Project description

Pulsim

Power electronics simulation, simplified.

High-performance circuit simulator focused on power electronics.

Features

  • High-performance C++20 kernel with sparse matrix solvers
  • Modified Nodal Analysis (MNA) for circuit formulation
  • Multiple integration methods (Backward Euler, Trapezoidal, BDF2, GEAR2)
  • Newton-Raphson nonlinear solver with damping and adaptive timestep
  • JSON netlist format with schematic position storage
  • CLI tool for batch simulation
  • Python bindings for scripting and GUI integration
  • GUI integration API with pause/resume/stop, progress callbacks, and validation

Quick Start

Build

# Configure
cmake -B build -DCMAKE_BUILD_TYPE=Release

# Build
cmake --build build -j

# Run tests
ctest --test-dir build --output-on-failure

Usage

# Run a simulation
./build/cli/pulsim run examples/rc_circuit.json -o result.csv

# Validate a netlist
./build/cli/pulsim validate examples/voltage_divider.json

# Get circuit info
./build/cli/pulsim info examples/rlc_circuit.json

Netlist Format

Pulsim uses a JSON-based netlist format:

{
    "components": [
        {"type": "voltage_source", "name": "V1", "npos": "in", "nneg": "0", "waveform": 5.0},
        {"type": "resistor", "name": "R1", "n1": "in", "n2": "out", "value": "1k"},
        {"type": "capacitor", "name": "C1", "n1": "out", "n2": "0", "value": "1u"}
    ]
}

Supported Components

Component Type Parameters
Resistor resistor, R value (ohms)
Capacitor capacitor, C value (F), ic (initial voltage)
Inductor inductor, L value (H), ic (initial current)
Voltage Source voltage_source, V waveform
Current Source current_source, I waveform
Diode diode, D is, n, ideal
Switch switch, S ron, roff, vth, ctrl_pos, ctrl_neg
MOSFET mosfet, nmos, pmos, M vth, kp, lambda, w, l, rds_on, body_diode
Transformer transformer, T turns_ratio, lm (magnetizing inductance)

Waveform Types

  • DC: 5.0 or {"type": "dc", "value": 5.0}
  • Pulse: {"type": "pulse", "v1": 0, "v2": 5, "period": 1e-3, ...}
  • Sine: {"type": "sin", "amplitude": 2.5, "frequency": 1000, ...}
  • PWL: {"type": "pwl", "points": [[0, 0], [1e-3, 5], [2e-3, 0]]}

SI Prefixes

Values support SI prefixes: f, p, n, u, m, k, meg, g, t

Examples: "1k" = 1000, "100n" = 100e-9, "4.7u" = 4.7e-6

CLI Options

pulsim run <netlist> [options]
  -o, --output    Output file (CSV)
  --tstop         Stop time (default: 1e-3)
  --dt            Time step (default: 1e-6)
  --tstart        Start time (default: 0)
  --abstol        Absolute tolerance (default: 1e-12)
  --reltol        Relative tolerance (default: 1e-3)
  -v, --verbose   Verbose output
  -q, --quiet     Quiet mode

pulsim validate <netlist>
  Validates netlist syntax and circuit topology

pulsim info <netlist>
  Shows circuit information

Project Structure

pulsim-core/
├── core/               # C++ kernel library
│   ├── include/        # Public headers
│   ├── src/            # Implementation
│   └── tests/          # Unit tests
├── cli/                # Command-line interface
├── examples/           # Example circuits
└── openspec/           # Specifications

Python Bindings

Pulsim includes Python bindings for scripting and GUI integration.

Installation

# Build with Python bindings
cmake -B build -DCMAKE_BUILD_TYPE=Release
cmake --build build -j

# Install (or add build/python to PYTHONPATH)
pip install build/python

Basic Usage

import pulsim

# Create a circuit
circuit = pulsim.Circuit()
circuit.add_voltage_source("V1", "in", "0", 5.0)
circuit.add_resistor("R1", "in", "out", 1000.0)
circuit.add_capacitor("C1", "out", "0", 1e-6)

# Validate the circuit
result = pulsim.validate_circuit(circuit)
if not result.is_valid:
    for error in result.errors():
        print(f"Error: {error.message}")

# Run simulation
opts = pulsim.SimulationOptions()
opts.tstop = 0.01  # 10ms
opts.dt = 1e-7     # 100ns timestep

sim = pulsim.Simulator(circuit, opts)
result = sim.run_transient()

print(f"Simulated {result.num_points()} points in {result.total_time_seconds:.2f}s")

GUI Integration

Pulsim provides a complete API for GUI integration:

import pulsim
import threading

# Create a simulation controller for pause/resume/stop
controller = pulsim.SimulationController()

# Progress callback for progress bars
def update_progress(progress):
    print(f"Progress: {progress.progress_percent:.1f}%")
    if progress.convergence_warning:
        print("Warning: Convergence issues detected")

# Run simulation with progress tracking
sim = pulsim.Simulator(circuit, opts)
result = sim.run_transient_with_progress(
    control=controller,
    progress_callback=update_progress,
    min_interval_ms=100  # Update every 100ms
)

# From another thread (GUI button handlers):
controller.request_pause()   # Pause simulation
controller.request_resume()  # Resume simulation
controller.request_stop()    # Stop simulation

Component Metadata for Palettes

# Build component palette from metadata
registry = pulsim.ComponentRegistry.instance()

for category in registry.all_categories():
    print(f"[{category}]")
    for comp_type in registry.types_in_category(category):
        meta = registry.get(comp_type)
        print(f"  - {meta.display_name}")
        for param in meta.parameters:
            print(f"      {param.display_name} [{param.unit}]")

Schematic Position Storage

# Store component positions for layout persistence
circuit.set_position("R1", pulsim.SchematicPosition(x=100, y=50, orientation=90))

# Export circuit with positions
json_str = pulsim.circuit_to_json(circuit, include_positions=True)

# Import circuit (positions preserved)
loaded = pulsim.parse_netlist_string(json_str)
pos = loaded.get_position("R1")  # Returns the saved position

See examples/gui_integration_example.py for more examples.

Roadmap

  • MVP-0: Basic kernel (R, L, C, sources, transient)
  • MVP-1: Power electronics (switches, events, losses)
  • MVP-2: Advanced devices (MOSFETs, transformers)
  • MVP-2b: GUI integration API (validation, progress, metadata)
  • MVP-3: Performance (SUNDIALS, parallel)

License

MIT License

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pulsim-0.1.10.tar.gz (656.9 kB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

pulsim-0.1.10-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (622.0 kB view details)

Uploaded CPython 3.12manylinux: glibc 2.17+ x86-64

pulsim-0.1.10-cp312-cp312-macosx_11_0_arm64.whl (475.1 kB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

pulsim-0.1.10-cp312-cp312-macosx_10_9_x86_64.whl (502.0 kB view details)

Uploaded CPython 3.12macOS 10.9+ x86-64

pulsim-0.1.10-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (622.9 kB view details)

Uploaded CPython 3.11manylinux: glibc 2.17+ x86-64

pulsim-0.1.10-cp311-cp311-macosx_11_0_arm64.whl (472.0 kB view details)

Uploaded CPython 3.11macOS 11.0+ ARM64

pulsim-0.1.10-cp311-cp311-macosx_10_9_x86_64.whl (494.5 kB view details)

Uploaded CPython 3.11macOS 10.9+ x86-64

pulsim-0.1.10-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (621.1 kB view details)

Uploaded CPython 3.10manylinux: glibc 2.17+ x86-64

pulsim-0.1.10-cp310-cp310-macosx_11_0_arm64.whl (470.5 kB view details)

Uploaded CPython 3.10macOS 11.0+ ARM64

pulsim-0.1.10-cp310-cp310-macosx_10_9_x86_64.whl (493.2 kB view details)

Uploaded CPython 3.10macOS 10.9+ x86-64

File details

Details for the file pulsim-0.1.10.tar.gz.

File metadata

  • Download URL: pulsim-0.1.10.tar.gz
  • Upload date:
  • Size: 656.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for pulsim-0.1.10.tar.gz
Algorithm Hash digest
SHA256 93b172f28e0a3a94a8d746077eaf52d3da5e6f3a0571dc83f22d66c9df302316
MD5 6a2976f39fe7a76d19bacf8fd620c324
BLAKE2b-256 2ca1300e79be21661b262de51dd738941a4455bb6b778131f01c31fbabb8789f

See more details on using hashes here.

Provenance

The following attestation bundles were made for pulsim-0.1.10.tar.gz:

Publisher: publish.yml on lgili/Pulsim

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pulsim-0.1.10-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for pulsim-0.1.10-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 94a6eb855ba397c1aa172709b944792dead378fc8dbf134cf829516c164eadce
MD5 207662626e3a39ed4a543aa730863d05
BLAKE2b-256 605e0586bfc7b1a1181a9658a56959861631482234d8432b312d0dc6d14b7e3d

See more details on using hashes here.

Provenance

The following attestation bundles were made for pulsim-0.1.10-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl:

Publisher: publish.yml on lgili/Pulsim

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pulsim-0.1.10-cp312-cp312-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for pulsim-0.1.10-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 0eaae73886c21d5ede9224ecf043bdb8e5cc76c36a93ed428982f601ec4662dc
MD5 248c305262fa46392a55a80ff1359ba7
BLAKE2b-256 ca0713f77bbf940c55b611b9cada176373444c29f23c912a1bb76e0b5a825266

See more details on using hashes here.

Provenance

The following attestation bundles were made for pulsim-0.1.10-cp312-cp312-macosx_11_0_arm64.whl:

Publisher: publish.yml on lgili/Pulsim

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pulsim-0.1.10-cp312-cp312-macosx_10_9_x86_64.whl.

File metadata

File hashes

Hashes for pulsim-0.1.10-cp312-cp312-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 79acd722a64a86b969d0cfd35742b0e7476014adc726f35ea50ca8b6336aba2f
MD5 67a901f2cbad6be130ff8de8b2b01bb1
BLAKE2b-256 924d0397990a23af4e051896ffb5e17a4b1cd57c54ecd29097b6f9df9f498c86

See more details on using hashes here.

Provenance

The following attestation bundles were made for pulsim-0.1.10-cp312-cp312-macosx_10_9_x86_64.whl:

Publisher: publish.yml on lgili/Pulsim

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pulsim-0.1.10-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for pulsim-0.1.10-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 78da3b9328e6c2c189f26e4550916097aad7c315d82df4fa65a8b4b9a18c9807
MD5 fca2aa0ce358db43293ef518bda01cfe
BLAKE2b-256 72f8a8f5d9ac29a9aa7ccd1edcf9a980c8d878c99ea7387d95b6f6dcb464c58c

See more details on using hashes here.

Provenance

The following attestation bundles were made for pulsim-0.1.10-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl:

Publisher: publish.yml on lgili/Pulsim

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pulsim-0.1.10-cp311-cp311-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for pulsim-0.1.10-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 36cd08c8a08d83ec9979863664a45ea54b5bc8268be28f8cc2cae1105218af00
MD5 caf9a22a26b421d8144f5580880ff184
BLAKE2b-256 b577aced1c5ceed99baf415b43ecabe5b97de0be9b0c6a9d9fbdf3efe1befb02

See more details on using hashes here.

Provenance

The following attestation bundles were made for pulsim-0.1.10-cp311-cp311-macosx_11_0_arm64.whl:

Publisher: publish.yml on lgili/Pulsim

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pulsim-0.1.10-cp311-cp311-macosx_10_9_x86_64.whl.

File metadata

File hashes

Hashes for pulsim-0.1.10-cp311-cp311-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 26cb8e99b507727993641230e52f64ef5fd3c131774af6f6835609d5094528c6
MD5 fca43153b92a58771c5b3afeaac7f2e5
BLAKE2b-256 ce4392de8b467fc1d7c10c185b31a2d6accae456efab7c45b6a001e3c81bdca5

See more details on using hashes here.

Provenance

The following attestation bundles were made for pulsim-0.1.10-cp311-cp311-macosx_10_9_x86_64.whl:

Publisher: publish.yml on lgili/Pulsim

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pulsim-0.1.10-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for pulsim-0.1.10-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 2515757fad55e310c588f6bf348e395255c8f4cc3a596f8314f8ec3e5ea9e2a2
MD5 8530e46d0e467a3448ff9e34c5e06793
BLAKE2b-256 e31fdd0cbfdb66dfba2bc21ec8212fd17d3b75e4ab218c7d202dce4045b9af54

See more details on using hashes here.

Provenance

The following attestation bundles were made for pulsim-0.1.10-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl:

Publisher: publish.yml on lgili/Pulsim

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pulsim-0.1.10-cp310-cp310-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for pulsim-0.1.10-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 64aedfc9e250e6eae3aaa766185d4bae74fa97eae8a1f69e06791ff93f20f382
MD5 9510776cbcd19f85e98ac6da875af36b
BLAKE2b-256 8c21b5c7d4e9e3e34591baac740a047241962cee0b89a5dbb4517601c7a6d1ae

See more details on using hashes here.

Provenance

The following attestation bundles were made for pulsim-0.1.10-cp310-cp310-macosx_11_0_arm64.whl:

Publisher: publish.yml on lgili/Pulsim

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pulsim-0.1.10-cp310-cp310-macosx_10_9_x86_64.whl.

File metadata

File hashes

Hashes for pulsim-0.1.10-cp310-cp310-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 1acc44bb3f3c8d7e6e6fe775f7fb6c94292c9a7d8ccc558672ec5a1481297332
MD5 ec38b7ec02471764493301b90304dc4a
BLAKE2b-256 68f65c4866a0e43dc146edff49dba6a420be9906f2f0f10bbe2c12d5c34f9ac9

See more details on using hashes here.

Provenance

The following attestation bundles were made for pulsim-0.1.10-cp310-cp310-macosx_10_9_x86_64.whl:

Publisher: publish.yml on lgili/Pulsim

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page