Skip to main content

Parallel ngspice SPICE simulation from Python — LTspice-friendly, with built-in MOSFET LUT and gm/Id sizing

Project description

sedes

Parallel ngspice SPICE simulation from Python. LTspice-friendly, with built-in MOSFET LUT generation and gm/Id sizing.

  • Cross-platform: prebuilt wheels for Linux, macOS, and Windows (x86_64, plus arm64 on macOS). Python 3.10+.
  • No system ngspice required: libngspice is bundled inside the wheel.
  • No GIL bottleneck: simulations run in parallel ngspice worker subprocesses, dispatched by an internal tokio runtime.
  • Typed surface: ships py.typed and a hand-written .pyi so Pyright, Pylance, and mypy give you full autocomplete out of the box.

Install

pip install sedes

That's it — no Rust toolchain, no SPICE install, no DLL hunt.

Quickstart — run a netlist, sweep a value

import numpy as np
import sedes

# Build a circuit programmatically …
ckt = (sedes.Circuit("RC filter")
    .V("v1", "in", "0", "ac 1")
    .R("r1", "in", "out", "1k")
    .C("c1", "out", "0", "100n")
    .ac("dec", 100, 1, 1e6))

# … or load one exported from LTspice (View → SPICE Netlist):
# ckt = sedes.Circuit.from_file("filter.cir")

pool = sedes.SimulationPool(workers=8)

# One run
result = ckt.run(pool)
print(result.frequency.shape, result.vector("v(out)").shape)

# Multi-value sweep — Cartesian product, run in parallel.
results = sedes.sweep(ckt, pool, {"r1": ["1k", "2.2k", "10k"]})
for R, r in zip(["1k", "2.2k", "10k"], results):
    mag = r.mag("v(out)")
    f_3db = r.frequency[np.argmin(np.abs(mag - 1/np.sqrt(2)))]
    print(f"R={R:>4}  →  f_-3dB ≈ {f_3db:.0f} Hz")

A runnable version of this lives at examples/rc_sweep.py.

What's in the package

Import Role
sedes.Circuit Programmatic SPICE netlist builder. Load with Circuit.from_file(...), mutate with .set_value(), .replace(), .remove(), attach analyses with .op() / .tran() / .dc() / .ac() / .noise().
sedes.parse_file, parse_string Standalone netlist parsers.
sedes.SimulationPool Worker-pool dispatcher. pool.run_simulation(netlist, ["run"]), pool.run_simulations_batch(jobs), pool.generate_lut(cfg).
sedes.sweep Cartesian-product parameter sweep over component values, returns typed result list.
sedes.LutConfig / sedes.Lut MOSFET characterisation (Id, gm, gds, capacitances, ft) and gm/Id transistor sizing.
sedes.OpResult / TranResult / DCResult / ACResult / NoiseResult / … Typed result wrappers with .plot() helpers.
sedes.PsfFile / sedes.NgpsfFile Cadence PSF / PSFXL waveform readers (pure Rust, no libpsf).

Coming from LTspice?

Read docs/ltspice_migration.md for the export workflow and the syntax differences that matter (the big one: in ngspice, M is mega, m is milli — LTspice is more forgiving).

For sweep recipes (1-axis, 2-axis corner grids, MOSFET parameter sweeps) see docs/sweeps.md.

Supported platforms

OS Architecture Python
Linux x86_64 (manylinux_2_28) 3.10–3.13
macOS x86_64, aarch64 3.10–3.13
Windows x86_64 3.10–3.13

Development

# Build once, populate the bundled libngspice into python/sedes/_libs:
bash ../.github/scripts/fetch_ngspice.sh macos python/sedes/_libs

# Build the extension and install it editable into a venv:
uv venv && uv pip install maturin numpy
uv run maturin develop --release
uv run python examples/rc_sweep.py

When you change the #[pyclass] / #[pyfunction] surface under src/python/ or src/psf/python.rs, also update python/sedes/sedes.pyi so IDE autocomplete remains accurate.

License

MIT — see 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

sedes-0.1.10.tar.gz (2.7 MB view details)

Uploaded Source

Built Distributions

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

sedes-0.1.10-cp310-abi3-win_amd64.whl (5.2 MB view details)

Uploaded CPython 3.10+Windows x86-64

sedes-0.1.10-cp310-abi3-manylinux_2_28_x86_64.whl (5.4 MB view details)

Uploaded CPython 3.10+manylinux: glibc 2.28+ x86-64

sedes-0.1.10-cp310-abi3-macosx_11_0_arm64.whl (3.9 MB view details)

Uploaded CPython 3.10+macOS 11.0+ ARM64

sedes-0.1.10-cp310-abi3-macosx_10_12_x86_64.whl (4.4 MB view details)

Uploaded CPython 3.10+macOS 10.12+ x86-64

File details

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

File metadata

  • Download URL: sedes-0.1.10.tar.gz
  • Upload date:
  • Size: 2.7 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for sedes-0.1.10.tar.gz
Algorithm Hash digest
SHA256 60326e24cc5fa5e9eff26a7f72ad106d0fc9b2a5e3f3c33217d1b3191131921b
MD5 144d67439d8abebe0a9762216cc83f33
BLAKE2b-256 39fe1be1d4b4953fdc906f448ad6c2c3e2c3987369814f82a7d694fca3fcf58b

See more details on using hashes here.

Provenance

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

Publisher: pypi_publish.yml on Tim-van-den-Akker/sedes

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

File details

Details for the file sedes-0.1.10-cp310-abi3-win_amd64.whl.

File metadata

  • Download URL: sedes-0.1.10-cp310-abi3-win_amd64.whl
  • Upload date:
  • Size: 5.2 MB
  • Tags: CPython 3.10+, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for sedes-0.1.10-cp310-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 cf1baf7510a0a894b7011836491e907912406c39a88fdc6f5cd078303381e095
MD5 65cda619c7aa689d23aadd7fd8857ef0
BLAKE2b-256 d6706fbbba587769a52edf6c3a21c58beacdaf6928088bedb3d1f0684a62d590

See more details on using hashes here.

Provenance

The following attestation bundles were made for sedes-0.1.10-cp310-abi3-win_amd64.whl:

Publisher: pypi_publish.yml on Tim-van-den-Akker/sedes

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

File details

Details for the file sedes-0.1.10-cp310-abi3-manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for sedes-0.1.10-cp310-abi3-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 8f12113f4a7c24f95346d2d64f307ef714a23b58808583fb71901a7a29f036c5
MD5 d33fdebc9a83e3548b9b27b34bdf8995
BLAKE2b-256 e4a979ffb5385de38f8e4cd03d5ce399f6f91e910775d6172d88f74d45e36cb1

See more details on using hashes here.

Provenance

The following attestation bundles were made for sedes-0.1.10-cp310-abi3-manylinux_2_28_x86_64.whl:

Publisher: pypi_publish.yml on Tim-van-den-Akker/sedes

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

File details

Details for the file sedes-0.1.10-cp310-abi3-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for sedes-0.1.10-cp310-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 71784f15f173d8a001774dc4989f3f41b46979b1c67b61be0aa6d30c5b9cbdec
MD5 43094a6885980820d60f19452d9977b4
BLAKE2b-256 b7e89304972adaff2edd17c3346c137bcfaa9d034d98bb133890a47bbb74eede

See more details on using hashes here.

Provenance

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

Publisher: pypi_publish.yml on Tim-van-den-Akker/sedes

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

File details

Details for the file sedes-0.1.10-cp310-abi3-macosx_10_12_x86_64.whl.

File metadata

File hashes

Hashes for sedes-0.1.10-cp310-abi3-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 7b35de353386e04ab1554c53bba208868ca59d2de1abcdefe3f90a5ad321cb54
MD5 6a0b61b09287781450087ec76dafd238
BLAKE2b-256 7f97b2fbe4f84f0a967c964dbb937bd05283409ed538b8815c5e2b18b88bbbe2

See more details on using hashes here.

Provenance

The following attestation bundles were made for sedes-0.1.10-cp310-abi3-macosx_10_12_x86_64.whl:

Publisher: pypi_publish.yml on Tim-van-den-Akker/sedes

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