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.8.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.8-cp310-abi3-win_amd64.whl (5.0 MB view details)

Uploaded CPython 3.10+Windows x86-64

sedes-0.1.8-cp310-abi3-manylinux_2_28_x86_64.whl (5.1 MB view details)

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

sedes-0.1.8-cp310-abi3-macosx_11_0_arm64.whl (3.6 MB view details)

Uploaded CPython 3.10+macOS 11.0+ ARM64

sedes-0.1.8-cp310-abi3-macosx_10_12_x86_64.whl (4.1 MB view details)

Uploaded CPython 3.10+macOS 10.12+ x86-64

File details

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

File metadata

  • Download URL: sedes-0.1.8.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.8.tar.gz
Algorithm Hash digest
SHA256 4f024010c9a57e19a0f70b01488b5404f52c10816001724bdf5cf1d231e28121
MD5 69e38711851a2bb011e95bf6beb4bf6d
BLAKE2b-256 0efa61f2c9a099c188fca2c6c14b0be1ee6e29d17bab25f32998643073fbbd1d

See more details on using hashes here.

Provenance

The following attestation bundles were made for sedes-0.1.8.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.8-cp310-abi3-win_amd64.whl.

File metadata

  • Download URL: sedes-0.1.8-cp310-abi3-win_amd64.whl
  • Upload date:
  • Size: 5.0 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.8-cp310-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 f8d7cb4e075df976107b22cb30d1bd2b7f0adec0d7d46998b39cd7ec8a131890
MD5 dedae1627141cfb175c89e44bb12e018
BLAKE2b-256 7cf0654e161e2dffb89d06340de4712f7667a41cbb031919d384663660a762d3

See more details on using hashes here.

Provenance

The following attestation bundles were made for sedes-0.1.8-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.8-cp310-abi3-manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for sedes-0.1.8-cp310-abi3-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 801df866936d4943f2e1ff4a53d58aac6c28ca3ffc116236cce5a9d98d464318
MD5 d695c76d0c96f1b97dc25cd06b02d8f6
BLAKE2b-256 5ecad51a49ad126e10be6444bb592606f2dbc6cc888c331222d0e851305b8f50

See more details on using hashes here.

Provenance

The following attestation bundles were made for sedes-0.1.8-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.8-cp310-abi3-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for sedes-0.1.8-cp310-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 f0c3a68665354e5649c1f96c55f28dca8c30591f51c68f5b1665eec5150ee38d
MD5 f270ef6bd34b7215ad7a5fee656e343e
BLAKE2b-256 f4e2943a7484b5fa9db3547fcd0bec728394f8aa0ca01564e29c4f6d9d3927fc

See more details on using hashes here.

Provenance

The following attestation bundles were made for sedes-0.1.8-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.8-cp310-abi3-macosx_10_12_x86_64.whl.

File metadata

File hashes

Hashes for sedes-0.1.8-cp310-abi3-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 614e087b00a90d5f15342ec4e89cc21720d8b177ac6f8ee63f4cc3fa997cdf78
MD5 c8ad9ab61232dbcc1d5721eea9afb169
BLAKE2b-256 a5fd73740dc06f782eeaec44b892f55ccfafd1017957b5cedf69f28cb169ffe9

See more details on using hashes here.

Provenance

The following attestation bundles were made for sedes-0.1.8-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