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.0.tar.gz (415.5 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.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (621.9 kB view details)

Uploaded CPython 3.12manylinux: glibc 2.17+ x86-64

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

Uploaded CPython 3.12macOS 11.0+ ARM64

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

Uploaded CPython 3.12macOS 10.9+ x86-64

pulsim-0.1.0-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.0-cp311-cp311-macosx_11_0_arm64.whl (472.0 kB view details)

Uploaded CPython 3.11macOS 11.0+ ARM64

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

Uploaded CPython 3.11macOS 10.9+ x86-64

pulsim-0.1.0-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.0-cp310-cp310-macosx_11_0_arm64.whl (470.5 kB view details)

Uploaded CPython 3.10macOS 11.0+ ARM64

pulsim-0.1.0-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.0.tar.gz.

File metadata

  • Download URL: pulsim-0.1.0.tar.gz
  • Upload date:
  • Size: 415.5 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.0.tar.gz
Algorithm Hash digest
SHA256 a1001aee4c8224a7dfe96c87fd2d157b69017c925225bb6822060b0c238ca16d
MD5 c997c86ca07c30c1c1e568f76af3c3d8
BLAKE2b-256 9ffc4ef60435f063b786d7c212bd8e93518aa7de07535a65a3f867adfdcec9da

See more details on using hashes here.

Provenance

The following attestation bundles were made for pulsim-0.1.0.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.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for pulsim-0.1.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 21cd4f8b699e2a75d9a95f1d2dc90b53dd869ac50cb91fe670281437e080cef1
MD5 bb1af300ac95f919b98c610504cae671
BLAKE2b-256 cd80e9cb88b04fbaf8d1575e32b26407590b5581e1b4cab9056700d9b64c05ec

See more details on using hashes here.

Provenance

The following attestation bundles were made for pulsim-0.1.0-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.0-cp312-cp312-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for pulsim-0.1.0-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 4b48f342191ecff4740aa23b4ab46fcca224281f5b6099a20336b468bba3ac4a
MD5 55ee5b39ed451cd89a75a7caf25f71c7
BLAKE2b-256 1fb147a488aafaea30a56ffeb752942f7744ef401ad7c7cf007d4ed4907f3da5

See more details on using hashes here.

Provenance

The following attestation bundles were made for pulsim-0.1.0-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.0-cp312-cp312-macosx_10_9_x86_64.whl.

File metadata

File hashes

Hashes for pulsim-0.1.0-cp312-cp312-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 5b57240cf1358ce8e9c6b03450cbee02a76ffa94b602f5be2dc3bfc6170ca718
MD5 42a35e6967f554222807c1a1c3d37916
BLAKE2b-256 c520b92a5723d2eaaa2571315d84ebe867b564e5b8130208aa4e9014ce719dc7

See more details on using hashes here.

Provenance

The following attestation bundles were made for pulsim-0.1.0-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.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for pulsim-0.1.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 d25a389b41064263828ec5cbcfba42300e84b807817951358c67da81ae61a510
MD5 a631db7c4649dd5e8c1b3bd604de058b
BLAKE2b-256 b5e0ae940801f4639f721958ef64e9d637298e1402c34be5bcd7a12a448c4fef

See more details on using hashes here.

Provenance

The following attestation bundles were made for pulsim-0.1.0-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.0-cp311-cp311-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for pulsim-0.1.0-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 86b0aa97f955d43722d750cd11d151a5da9f509924540482dfe7e95415c96511
MD5 7264f72578fda936f83e92871c82c0ed
BLAKE2b-256 01e25b29692e59bc077c3867eaa65f4ef46fa7ba31356fd31f475e177016370c

See more details on using hashes here.

Provenance

The following attestation bundles were made for pulsim-0.1.0-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.0-cp311-cp311-macosx_10_9_x86_64.whl.

File metadata

File hashes

Hashes for pulsim-0.1.0-cp311-cp311-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 a2cd513218a7167f388512f546402a9dd3a804145d404ed11fab64c34e49b8fc
MD5 b452ac706d0dcd5d5394690ccf9016bf
BLAKE2b-256 7b774538d45ec02bf891fe1fdbd9132bf9fe7ced8d989dbda52d696f17cc3fb4

See more details on using hashes here.

Provenance

The following attestation bundles were made for pulsim-0.1.0-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.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for pulsim-0.1.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 34f0dc9495fcc1975421c0d6697ed950f05c047076a6cc6f58bc94bf444feff9
MD5 5f0d76c73f9259470f1339beae3e7111
BLAKE2b-256 63cd02e74b47646ec83ab1346117d70d76ca30051295d864a0b51d62dee17bf2

See more details on using hashes here.

Provenance

The following attestation bundles were made for pulsim-0.1.0-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.0-cp310-cp310-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for pulsim-0.1.0-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 aaf92e8e646096bae2b4709fa79aff3c2c5129361df15307ad9fd81edab95f13
MD5 754c0122a27f83e4e0f0da006df2ca4f
BLAKE2b-256 312f7038c9172e22fa7110c15aa5c00a449a618a2963589b9caa4faedbd8c2a4

See more details on using hashes here.

Provenance

The following attestation bundles were made for pulsim-0.1.0-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.0-cp310-cp310-macosx_10_9_x86_64.whl.

File metadata

File hashes

Hashes for pulsim-0.1.0-cp310-cp310-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 e13cd297856c6e999832edb8d1a0c8e92cffbacf8b41abb96404ac0497e66039
MD5 9611744d900bcd80275e05674d354f6d
BLAKE2b-256 522bb7f0750fa68d92c8c0c8563f7fb63a921596b153878eeb174a9d1a90d48c

See more details on using hashes here.

Provenance

The following attestation bundles were made for pulsim-0.1.0-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