-
Notifications
You must be signed in to change notification settings - Fork 40
Add Ngspice recipe #102
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Add Ngspice recipe #102
Changes from 6 commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
fe5b2f1
add ngspice recipe
pepijndevos 94f493d
add ngspice metadata
pepijndevos f6b4f33
add flags
pepijndevos f2f9e39
add inspice recipe
pepijndevos cde3932
auto fixes from pre-commit.com hooks
pre-commit-ci[bot] b5802b9
update inspice package
pepijndevos e5c06f4
Apply suggestions from code review
pepijndevos 186f3b8
address review
pepijndevos File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
package: | ||
name: diskcache | ||
version: 5.6.3 | ||
top-level: | ||
- diskcache | ||
source: | ||
url: https://files.pythonhosted.org/packages/py3/d/diskcache/diskcache-5.6.3-py3-none-any.whl | ||
sha256: 5e31b2d5fbad117cc363ebaf6b689474db18a1f6438bc82358b024abd4c2ca19 | ||
about: | ||
home: http://www.grantjenks.com/docs/diskcache/ | ||
PyPI: https://pypi.org/project/diskcache | ||
summary: Disk Cache -- Disk and file backed persistent cache. | ||
license: Apache 2.0 | ||
extra: | ||
recipe-maintainers: | ||
- PUT_YOUR_GITHUB_USERNAME_HERE | ||
pepijndevos marked this conversation as resolved.
Show resolved
Hide resolved
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package: | ||
name: inspice | ||
version: 1.6.3.3 | ||
top-level: | ||
- InSpice | ||
source: | ||
url: https://files.pythonhosted.org/packages/65/dc/10a19fea20319d33898aed32d944afef59f6f94c03b2eb6c645ec64ae171/inspice-1.6.3.3-py3-none-any.whl | ||
sha256: ae550f6ec792e57bda083f116bd39e2535c6b742de33ca73268ad2792043a45a | ||
requirements: | ||
run: | ||
- numpy | ||
- matplotlib | ||
- pyyaml | ||
- cffi | ||
- diskcache | ||
- h5py | ||
- ply | ||
- ngspice | ||
about: | ||
home: https://github.com/Innovoltive/InSpice | ||
PyPI: https://pypi.org/project/inspice | ||
summary: Python interface to Ngspice and Xyce circuit simulators (forked from PySpice) | ||
license: GPL-3.0-or-later | ||
extra: | ||
recipe-maintainers: | ||
- pepijndevos |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
from pytest_pyodide import run_in_pyodide | ||
|
||
|
||
@run_in_pyodide(packages=["inspice"]) | ||
def test_mytestname(selenium): | ||
pepijndevos marked this conversation as resolved.
Show resolved
Hide resolved
|
||
from InSpice.Spice.NgSpice.Shared import NgSpiceShared | ||
|
||
ngspice = NgSpiceShared() | ||
circuit = """ | ||
.title Voltage Multiplier | ||
|
||
.SUBCKT 1N4148 1 2 | ||
* | ||
R1 1 2 5.827E+9 | ||
D1 1 2 1N4148 | ||
* | ||
.MODEL 1N4148 D | ||
+ IS = 4.352E-9 | ||
+ N = 1.906 | ||
+ BV = 110 | ||
+ IBV = 0.0001 | ||
+ RS = 0.6458 | ||
+ CJO = 7.048E-13 | ||
+ VJ = 0.869 | ||
+ M = 0.03 | ||
+ FC = 0.5 | ||
+ TT = 3.48E-9 | ||
.ENDS | ||
|
||
Vinput in 0 DC 0V AC 1V SIN(0V 10V 50Hz 0s 0Hz) | ||
C0 in 1 1mF | ||
X0 1 0 1N4148 | ||
C1 0 2 1mF | ||
X1 2 1 1N4148 | ||
C2 1 3 1mF | ||
X2 3 2 1N4148 | ||
C3 2 4 1mF | ||
X3 4 3 1N4148 | ||
C4 3 5 1mF | ||
X4 5 4 1N4148 | ||
R1 5 6 1MegOhm | ||
.options TEMP = 25°C | ||
.options TNOM = 25°C | ||
.options filetype = binary | ||
.options NOINIT | ||
.ic | ||
.tran 0.0001s 0.4s 0s | ||
.end | ||
""" | ||
ngspice.load_circuit(circuit) | ||
ngspice.run() | ||
plot = ngspice.plot(simulation=None, plot_name=ngspice.last_plot) | ||
assert "V(6)" in plot |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
package: | ||
name: ngspice | ||
version: "44.2" | ||
tag: | ||
- library | ||
- shared_library | ||
source: | ||
url: https://github.com/danchitnis/ngspice-sf-mirror/archive/refs/tags/ngspice-44.2.zip | ||
sha256: 3ae94703938247a22148f60a1307d52719d42a9134b5aef6252594000f513902 | ||
patches: | ||
- patches/0001-keep-alive-API-functions.patch | ||
- patches/0001-no-hicum2.patch | ||
|
||
build: | ||
type: shared_library | ||
script: | | ||
bash ./autogen.sh | ||
|
||
configure_args=( | ||
--prefix=${WASM_LIBRARY_DIR} | ||
--disable-xspice | ||
--disable-debug | ||
--disable-dependency-tracking | ||
--enable-cider | ||
--with-readline=no | ||
--disable-openmp | ||
--with-ngshared | ||
--host=wasm32-unknown-emscripten | ||
) | ||
|
||
mkdir release-lib && cd release-lib | ||
emconfigure ../configure "${configure_args[@]}" CFLAGS="${SIDE_MODULE_CFLAGS}" | ||
emmake make -j ${PYODIDE_JOBS:-3} LDFLAGS="${SIDE_MODULE_LDFLAGS}" | ||
emmake make install | ||
cp ${WASM_LIBRARY_DIR}/lib/libngspice.so ${DISTDIR} | ||
|
||
about: | ||
home: http://ngspice.sourceforge.net | ||
license: BSD-3-Clause | ||
summary: The open source spice simulator for electric and electronic circuits | ||
extra: | ||
recipe-maintainers: | ||
- pepijndevos |
26 changes: 26 additions & 0 deletions
26
packages/ngspice/patches/0001-keep-alive-API-functions.patch
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
From 3c02c562b98c95f120425828fef28d17657160e8 Mon Sep 17 00:00:00 2001 | ||
From: Pepijn de Vos <[email protected]> | ||
Date: Tue, 6 May 2025 12:53:35 +0200 | ||
Subject: [PATCH] keep alive API functions | ||
|
||
pepijndevos marked this conversation as resolved.
Show resolved
Hide resolved
|
||
--- | ||
src/include/ngspice/sharedspice.h | 3 +++ | ||
1 file changed, 3 insertions(+) | ||
|
||
diff --git a/src/include/ngspice/sharedspice.h b/src/include/ngspice/sharedspice.h | ||
index d38558d78..c67dd8250 100644 | ||
--- a/src/include/ngspice/sharedspice.h | ||
+++ b/src/include/ngspice/sharedspice.h | ||
@@ -144,6 +144,9 @@ extern "C" { | ||
#else | ||
#define IMPEXP __declspec(dllimport) | ||
#endif | ||
+#elif defined(__EMSCRIPTEN__) | ||
+ #include <emscripten.h> | ||
+ #define IMPEXP EMSCRIPTEN_KEEPALIVE | ||
#else | ||
/* use with gcc flag -fvisibility=hidden */ | ||
#if __GNUC__ >= 4 | ||
-- | ||
2.49.0 | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
From 90f8b79426ed5487e8ea6b4d23b6716e3d54db69 Mon Sep 17 00:00:00 2001 | ||
From: Pepijn de Vos <[email protected]> | ||
Date: Tue, 6 May 2025 19:51:44 +0200 | ||
Subject: [PATCH] no hicum2 | ||
|
||
pepijndevos marked this conversation as resolved.
Show resolved
Hide resolved
|
||
--- | ||
src/Makefile.am | 1 - | ||
src/spicelib/devices/Makefile.am | 2 -- | ||
src/spicelib/devices/dev.c | 1 - | ||
3 files changed, 4 deletions(-) | ||
|
||
diff --git a/src/Makefile.am b/src/Makefile.am | ||
index aa2a49183..2199cd562 100644 | ||
--- a/src/Makefile.am | ||
+++ b/src/Makefile.am | ||
@@ -73,7 +73,6 @@ DYNAMIC_DEVICELIBS = \ | ||
spicelib/devices/isrc/libisrc.la \ | ||
spicelib/devices/hfet1/libhfet.la \ | ||
spicelib/devices/hfet2/libhfet2.la \ | ||
- spicelib/devices/hicum2/libhicum2.la \ | ||
spicelib/devices/hisim2/libhisim2.la \ | ||
spicelib/devices/hisimhv1/libhisimhv1.la \ | ||
spicelib/devices/hisimhv2/libhisimhv2.la \ | ||
diff --git a/src/spicelib/devices/Makefile.am b/src/spicelib/devices/Makefile.am | ||
index a97f7c26c..7bc8a23e8 100644 | ||
--- a/src/spicelib/devices/Makefile.am | ||
+++ b/src/spicelib/devices/Makefile.am | ||
@@ -27,7 +27,6 @@ SUBDIRS = \ | ||
isrc \ | ||
hfet1 \ | ||
hfet2 \ | ||
- hicum2 \ | ||
hisim2 \ | ||
hisimhv1 \ | ||
hisimhv2 \ | ||
@@ -88,7 +87,6 @@ DIST_SUBDIRS = \ | ||
isrc \ | ||
hfet1 \ | ||
hfet2 \ | ||
- hicum2 \ | ||
hisim2 \ | ||
hisimhv1 \ | ||
hisimhv2 \ | ||
diff --git a/src/spicelib/devices/dev.c b/src/spicelib/devices/dev.c | ||
index 2a32c3889..5a18eb68b 100644 | ||
--- a/src/spicelib/devices/dev.c | ||
+++ b/src/spicelib/devices/dev.c | ||
@@ -175,7 +175,6 @@ static SPICEdev *(*static_devices[])(void) = { | ||
get_dio_info, | ||
get_hfeta_info, | ||
get_hfet2_info, | ||
- get_hicum_info, | ||
get_hsm2_info, | ||
get_hsmhv_info, | ||
get_hsmhv2_info, | ||
-- | ||
2.49.0 | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
package: | ||
name: ply | ||
version: "3.11" | ||
top-level: | ||
- ply | ||
source: | ||
url: https://files.pythonhosted.org/packages/a3/58/35da89ee790598a0700ea49b2a66594140f44dec458c07e8e3d4979137fc/ply-3.11-py2.py3-none-any.whl | ||
sha256: 096f9b8350b65ebd2fd1346b12452efe5b9607f7482813ffca50c22722a807ce | ||
about: | ||
home: http://www.dabeaz.com/ply/ | ||
PyPI: https://pypi.org/project/ply | ||
summary: Python Lex & Yacc | ||
license: BSD | ||
extra: | ||
recipe-maintainers: | ||
- PUT_YOUR_GITHUB_USERNAME_HERE | ||
pepijndevos marked this conversation as resolved.
Show resolved
Hide resolved
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.