Name | py4spice JSON |
Version |
0.0.1
JSON |
| download |
home_page | |
Summary | Python for Spice |
upload_time | 2023-03-30 23:26:02 |
maintainer | |
docs_url | None |
author | |
requires_python | >=3.11 |
license | MIT License |
keywords |
ngspice
spice
simulation
|
VCS |
|
bugtrack_url |
|
requirements |
No requirements were recorded.
|
Travis-CI |
No Travis.
|
coveralls test coverage |
No coveralls.
|
# Python for Spice
Lightweight Python interface to Ngspice
# Movtivation
[Ngspice](https://ngspice.sourceforge.io/) is an open source circuit simulator with a command line interface (CLI). It's natural to use Python to interact with the CLI, making it easier to use Ngspice for advanced design analysis.
There exists a simulator called [PySpice](https://github.com/PySpice-org/PySpice) which embeds Ngspice through its API. ***Python for Spice***, on the other hand, is a lightweight module that facilitates Ngspice interaction. Simple classes and functions transparently create Ngspice netlists and commands. You can launch multiple analyses and convert the results to [Pandas](https://pandas.pydata.org/) and [Numpy](https://numpy.org/), enabling downstream computation or plotting with [Matplotlib](https://matplotlib.org/).
A modest knowledge of Ngspice and Python is assumed.
# Usage
***Python for Spice*** requires an Ngspice design, either in the form of a netlist or a [KiCad](https://www.kicad.org/) (version 7.0 or higher) schematic.
Ngspice can be used in many different ways. However, ***Python for Spice*** will interface to Ngspice only through the CLI in non-interactive mode. It creates a *control section* that will execute simulations in batch mode. Results from the simulation will be converted to [Pandas](https://pandas.pydata.org/) DataFrames.
# Typical Program Flow
A main Python program controls the flow. An example can be found [here](https://github.com/astorguy/bc546_amp).
1. import py4spice
1. Specify paths to KiCad and Ngspice executables, and project directory
1. Define signals of interest (node voltage, currents, etc.) with `Vectors` objects
1. Use a `KicadCmd` object to extract and condition a netlist from a schematic
1. Define one or more analyses (op, dc, tr, ac) with `Analyses` objects
1. A `Control` object defines the control section. The analyses and other control functions are part of it.
1. A `Simulation` Object is created and executed.
1. The tabular results from the simulation are converted to Pandas DataFrames
1. A `Plot` object can be used to encapsulate Matplotlib to view the results.
# Installation
1. install package:
`python -m pip install --upgrade py4spice`
2. Download this [example](https://github.com/astorguy/bc546_amp) (a bipolar amplifier) to try out the `py4spice` package.
Raw data
{
"_id": null,
"home_page": "",
"name": "py4spice",
"maintainer": "",
"docs_url": null,
"requires_python": ">=3.11",
"maintainer_email": "",
"keywords": "ngspice,spice,simulation",
"author": "",
"author_email": "Mark Chadwick <mark.chadwick@techsharpen.com>",
"download_url": "https://files.pythonhosted.org/packages/ca/a5/393e1f2076ea899832add8f23f30550b03d22350d61d898ce88c5467f434/py4spice-0.0.1.tar.gz",
"platform": null,
"description": "# Python for Spice\r\nLightweight Python interface to Ngspice\r\n\r\n# Movtivation\r\n[Ngspice](https://ngspice.sourceforge.io/) is an open source circuit simulator with a command line interface (CLI). It's natural to use Python to interact with the CLI, making it easier to use Ngspice for advanced design analysis.\r\n\r\nThere exists a simulator called [PySpice](https://github.com/PySpice-org/PySpice) which embeds Ngspice through its API. ***Python for Spice***, on the other hand, is a lightweight module that facilitates Ngspice interaction. Simple classes and functions transparently create Ngspice netlists and commands. You can launch multiple analyses and convert the results to [Pandas](https://pandas.pydata.org/) and [Numpy](https://numpy.org/), enabling downstream computation or plotting with [Matplotlib](https://matplotlib.org/).\r\n\r\nA modest knowledge of Ngspice and Python is assumed.\r\n\r\n# Usage\r\n***Python for Spice*** requires an Ngspice design, either in the form of a netlist or a [KiCad](https://www.kicad.org/) (version 7.0 or higher) schematic.\r\n\r\nNgspice can be used in many different ways. However, ***Python for Spice*** will interface to Ngspice only through the CLI in non-interactive mode. It creates a *control section* that will execute simulations in batch mode. Results from the simulation will be converted to [Pandas](https://pandas.pydata.org/) DataFrames.\r\n\r\n\r\n# Typical Program Flow\r\nA main Python program controls the flow. An example can be found [here](https://github.com/astorguy/bc546_amp).\r\n\r\n1. import py4spice\r\n\r\n1. Specify paths to KiCad and Ngspice executables, and project directory\r\n\r\n1. Define signals of interest (node voltage, currents, etc.) with `Vectors` objects\r\n\r\n1. Use a `KicadCmd` object to extract and condition a netlist from a schematic\r\n\r\n1. Define one or more analyses (op, dc, tr, ac) with `Analyses` objects\r\n\r\n1. A `Control` object defines the control section. The analyses and other control functions are part of it.\r\n\r\n1. A `Simulation` Object is created and executed.\r\n\r\n1. The tabular results from the simulation are converted to Pandas DataFrames\r\n\r\n1. A `Plot` object can be used to encapsulate Matplotlib to view the results.\r\n\r\n# Installation\r\n\r\n1. install package:\r\n\r\n`python -m pip install --upgrade py4spice`\r\n\r\n2. Download this [example](https://github.com/astorguy/bc546_amp) (a bipolar amplifier) to try out the `py4spice` package.\r\n",
"bugtrack_url": null,
"license": "MIT License",
"summary": "Python for Spice",
"version": "0.0.1",
"split_keywords": [
"ngspice",
"spice",
"simulation"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "374ecd47e678d07f00c1d6d93734b809b0b163a4c352479f43bf3c68a11e7978",
"md5": "9ced8fe278fc7d602065f7132d6ffa8a",
"sha256": "ef61e90919b0245b0c645e57064ae6a2347f6efc910f3e0fb1c86e5a851a67fc"
},
"downloads": -1,
"filename": "py4spice-0.0.1-py3-none-any.whl",
"has_sig": false,
"md5_digest": "9ced8fe278fc7d602065f7132d6ffa8a",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.11",
"size": 11355,
"upload_time": "2023-03-30T23:26:01",
"upload_time_iso_8601": "2023-03-30T23:26:01.076598Z",
"url": "https://files.pythonhosted.org/packages/37/4e/cd47e678d07f00c1d6d93734b809b0b163a4c352479f43bf3c68a11e7978/py4spice-0.0.1-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "caa5393e1f2076ea899832add8f23f30550b03d22350d61d898ce88c5467f434",
"md5": "6e46bc3b135576fc7b4061a87a6570a0",
"sha256": "2177e08a18db7b247c56405d6bc99a2080d6b4da3e2fe807a50ea868c084ef24"
},
"downloads": -1,
"filename": "py4spice-0.0.1.tar.gz",
"has_sig": false,
"md5_digest": "6e46bc3b135576fc7b4061a87a6570a0",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.11",
"size": 12947,
"upload_time": "2023-03-30T23:26:02",
"upload_time_iso_8601": "2023-03-30T23:26:02.711829Z",
"url": "https://files.pythonhosted.org/packages/ca/a5/393e1f2076ea899832add8f23f30550b03d22350d61d898ce88c5467f434/py4spice-0.0.1.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2023-03-30 23:26:02",
"github": false,
"gitlab": false,
"bitbucket": false,
"lcname": "py4spice"
}