openjellybean 0.6.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,22 @@
1
+ # Python
2
+ __pycache__/
3
+ *.py[cod]
4
+ .venv/
5
+ venv/
6
+
7
+ # SPICE simulator output
8
+ *.raw
9
+ *.log
10
+ *.dat
11
+ *.fft
12
+ *.net
13
+
14
+ # Editors and OS
15
+ .vscode/
16
+ .idea/
17
+ *.swp
18
+ .DS_Store
19
+ Thumbs.db
20
+
21
+ # Local Claude Code settings
22
+ .claude/settings.local.json
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 openjellybean contributors
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,180 @@
1
+ Metadata-Version: 2.5
2
+ Name: openjellybean
3
+ Version: 0.6.0
4
+ Summary: Generic, original 'jelly bean' SPICE models, packaged for use as a dependency
5
+ Project-URL: Homepage, https://github.com/xdylanm/openjellybean
6
+ Project-URL: Repository, https://github.com/xdylanm/openjellybean
7
+ Author: xdylanm
8
+ License-Expression: MIT
9
+ License-File: LICENSE
10
+ Keywords: ltspice,models,netlist,ngspice,spice
11
+ Classifier: Development Status :: 3 - Alpha
12
+ Classifier: Intended Audience :: Science/Research
13
+ Classifier: Operating System :: OS Independent
14
+ Classifier: Programming Language :: Python :: 3
15
+ Classifier: Programming Language :: Python :: 3.13
16
+ Classifier: Topic :: Scientific/Engineering :: Electronic Design Automation (EDA)
17
+ Requires-Python: >=3.13
18
+ Description-Content-Type: text/markdown
19
+
20
+ # openjellybean — MIT-licensed jelly-bean SPICE models
21
+
22
+ One include file, `jellybean.lib`, with original models that behave like the
23
+ everyday parts. Every model was written from scratch and its parameters fitted
24
+ in ngspice to **typical** values from public datasheets — no manufacturer model
25
+ file was copied or adapted — so the whole set is under the MIT license.
26
+
27
+ Names end in `_OJ` so they never collide with vendor models.
28
+
29
+ ```spice
30
+ .include jellybean.lib
31
+ Q1 c b e BC547B_OJ ; BJT: C B E (SPICE order, not TO-92 pin order)
32
+ M1 d g s 2N7000_OJ ; VDMOS: D G S (body diode built in)
33
+ J1 d g s 2N5457_OJ ; JFET: D G S (SPICE order, not TO-92 pin order)
34
+ D1 a k 1N4148_OJ ; diode: A K
35
+ X1 a k BZX79C5V1_OJ ; zener: A K
36
+ X2 a k ZENER_OJ params: VZ=8.2 IZT=5m RZ=10 NK=1 ; any voltage
37
+ XU1 inp inn vcc vee out TL07X_OJ ; op-amp: +IN -IN V+ V- OUT
38
+ XU2 o1 n1 p1 vee p2 n2 o2 vcc TL072_OJ ; complete dual: pins 1-8 in order
39
+ XU3 o1 n1 p1 vcc p2 n2 o2 o3 n3 p3 vee p4 n4 o4 TL074_OJ ; complete quad: pins 1-14 in order
40
+ XU4 o1 n1 p1 gnd p2 n2 o2 vcc LM358_DUAL_OJ ; complete dual: pins 1-8 in order
41
+ XU5 o1 n1 p1 vcc p2 n2 o2 o3 n3 p3 gnd p4 n4 o4 LM324_QUAD_OJ ; complete quad: pins 1-14 in order
42
+ D2 a k LED_RED_OJ ; LED: A K (also LED_GREEN_OJ, LED_BLUE_OJ)
43
+ XR1 a w b POT_OJ params: R=10k POS=0.25 ; pot: A WIPER B; POS 0 = at A, 1 = at B
44
+ ```
45
+
46
+ ## Contents and verified behaviour (ngspice 47, 27 °C)
47
+
48
+ | Model | Stand-in for | Target (datasheet typ.) | Model |
49
+ |---|---|---|---|
50
+ | `BC547B_OJ` NPN | BC547B | hFE 290 @ 2 mA; 150 @ 10 µA | 282; 162 |
51
+ | | | VBE 0.66 V @ 2 mA | 0.658 V |
52
+ | | | VCE(sat) 90 / 200 mV @ 10 / 100 mA | 69 / 231 mV |
53
+ | | | fT 300 MHz @ 10 mA | 304 MHz |
54
+ | `BC557B_OJ` PNP | BC557B | hFE 290 @ 2 mA | 289 |
55
+ | | | VBE(on) 0.62 V @ 2 mA | 0.658 V |
56
+ | | | VCE(sat) 75 / 250 mV @ 10 / 100 mA | 64 / 247 mV |
57
+ | | | fT 150 MHz | 150 MHz |
58
+ | `2N3904_OJ` NPN | 2N3904, MMBT3904 | hFE 100–300 @ 10 mA (min 70 @ 1 mA, 30 @ 100 mA), VCE = 1 V | 157 (164 @ 1 mA, 75 @ 100 mA) |
59
+ | | | VCE(sat) ≤ 200 / 300 mV @ 10/1, 50/5 mA | 54 / 119 mV |
60
+ | | | fT ≥ 300 MHz (20 V, 10 mA, 100 MHz); Cobo ≤ 4 pF; Cibo ≤ 8 pF | 361 MHz; 2.4 pF; 5.0 pF |
61
+ | `2N3906_OJ` PNP | 2N3906, MMBT3906 | hFE 100–300 @ 10 mA (min 30 @ 100 mA), VCE = 1 V | 158 (79 @ 100 mA) |
62
+ | | | VCE(sat) ≤ 250 / 400 mV @ 10/1, 50/5 mA | 61 / 150 mV |
63
+ | | | fT ≥ 250 MHz (20 V, 10 mA, 100 MHz); Cobo ≤ 4.5 pF; Cibo ≤ 10 pF | 289 MHz; 3.1 pF; 6.7 pF |
64
+ | `2N7000_OJ` NMOS | 2N7000, 2N7002, BS170 | VGS(th) 2.1 V @ 1 mA | 2.02 V |
65
+ | | | RDS(on) 1.2 Ω @ 10 V; 1.8 Ω @ 4.5 V | 1.12 Ω; 2.06 Ω |
66
+ | | | Ciss / Coss / Crss 20 / 11 / 4 pF @ 25 V | 19.5 / 10.4 / 3.5 pF |
67
+ | `BS250_OJ` PMOS | BS250 | VGS(th) −1 to −3.5 V; RDS(on) 9 Ω @ −10 V | −2.4 V; 8.9 Ω |
68
+ | | | Ciss / Coss / Crss 30 / 20 / 5 pF @ 10 V | 30.0 / 20.1 / 5.0 pF |
69
+ | `2N5457_OJ` N-JFET | 2N5457, MMBF5457 | IDSS 3 mA; VGS −2.5 V @ 100 µA; gfs 1–5 mS; gos 10 µS | 3.02 mA; −2.51 V; 1.94 mS; 9.1 µS |
70
+ | | | Ciss / Crss 4.5 / 1.5 pF @ 15 V | 4.4 / 1.55 pF |
71
+ | `2N5458_OJ` N-JFET | 2N5458, MMBF5458 | IDSS 6 mA; VGS −3.5 V @ 200 µA; gfs 1.5–5.5 mS; gos 10 µS | 6.03 mA; −3.52 V; 2.74 mS; 9.4 µS |
72
+ | | | Ciss / Crss 4.5 / 1.5 pF @ 15 V | 4.3 / 1.59 pF |
73
+ | `2N5459_OJ` N-JFET | 2N5459, MMBF5459 | IDSS 9 mA; VGS −4.5 V @ 400 µA; gfs 2–6 mS; gos 10 µS | 8.98 mA; −4.53 V; 3.05 mS; 9.1 µS |
74
+ | | | Ciss / Crss 4.5 / 1.5 pF @ 15 V | 4.15 / 1.56 pF |
75
+ | `J112_OJ` N-JFET | J112, SST112 | VGS(off) −1 to −5 V; IDSS ≥ 5 mA (36 mA on the curves); rDS(on) ≤ 50 Ω | −2.19 V; 37 mA; 49 Ω |
76
+ | | | gfs 6 mS, gos 25 µS @ 1 mA; Ciss / Crss 7 / 3 pF @ −10 V | 6.4 mS, 20 µS; 7.3 / 3.0 pF |
77
+ | `J113_OJ` N-JFET | J113, SST113 | VGS(off) to −3 V; IDSS ≥ 2 mA (20 mA on the curves); rDS(on) ≤ 100 Ω (63 Ω on the curves) | −1.49 V; 20 mA; 65 Ω |
78
+ | | | gfs 6 mS, gos 25 µS @ 1 mA; Ciss / Crss 7 / 3 pF @ −10 V | 6.9 mS, 19 µS; 7.3 / 3.0 pF |
79
+ | `PN4392_OJ` N-JFET | PN4392, 2N4392 | VGS(off) −2 to −5 V; IDSS 25–75 mA; rDS(on) ≤ 60 Ω; VDS(on) 0.3 V @ 6 mA | −2.80 V; 50 mA; 49 Ω; 0.30 V |
80
+ | | | gfs 6 mS, gos 25 µS @ 1 mA; Ciss 12 pF @ 20 V; Crss 3.4 pF @ −7 V | 5.4 mS, 20 µS; 12.0 pF; 3.4 pF |
81
+ | `PN4393_OJ` N-JFET | PN4393, 2N4393 | VGS(off) −0.5 to −3 V; IDSS 5–30 mA; rDS(on) ≤ 100 Ω; VDS(on) 0.25 V @ 3 mA | −1.20 V; 14 mA; 78 Ω; 0.25 V |
82
+ | | | gfs 6 mS, gos 25 µS @ 1 mA; Ciss 12 pF @ 20 V; Crss 3.5 pF @ −5 V | 6.6 mS, 19 µS; 11.6 pF; 3.5 pF |
83
+ | `2N5460_OJ` P-JFET | 2N5460, MMBF5460 | IDSS 1–5 mA; VGS(off) 0.75–6 V; gfs 1–4 mS; Ciss / Crss 5 / 1 pF @ 15 V | 2.51 mA; 2.16 V; 2.18 mS; 4.8 / 0.99 pF |
84
+ | `2N5461_OJ` P-JFET | 2N5461, MMBF5461 | IDSS 2–9 mA; VGS(off) 1–7.5 V; gfs 1.5–5 mS; Ciss / Crss 5 / 1 pF @ 15 V | 4.50 mA; 2.96 V; 2.86 mS; 4.75 / 0.98 pF |
85
+ | `2N5462_OJ` P-JFET | 2N5462, MMBF5462 | IDSS 4–16 mA; VGS(off) 1.8–9 V; gfs 2–6 mS; Ciss / Crss 5 / 1 pF @ 15 V | 8.98 mA; 4.95 V; 3.46 mS; 4.75 / 1.01 pF |
86
+ | `1N4148_OJ` | 1N4148, 1N914 | VF 0.61 / 0.72 / 0.875 V @ 1 / 10 / 100 mA | 0.611 / 0.729 / 0.920 V |
87
+ | | | trr ≤ 8 ns (10 mA → 10 mA → 1 mA); ≤ 4 ns (10 mA, 6 V, 100 Ω) | 3.97 ns; 0.67 ns |
88
+ | `1N5819_OJ` Schottky | 1N5819 | VF 0.30 / 0.42 / 0.55 V @ 0.1 / 1 / 3 A | 0.306 / 0.419 / 0.563 V |
89
+ | `BAT54_OJ` Schottky | BAT54 | VF 0.22 / 0.29 / 0.35 / 0.41 / 0.52 V @ 0.1 / 1 / 10 / 30 / 100 mA | 0.230 / 0.290 / 0.360 / 0.410 / 0.518 V |
90
+ | | | CT 7.6 pF @ 1 V; trr ≤ 5 ns (10 mA → 10 mA → 1 mA, 100 Ω) | 7.6 pF; 2.65 ns |
91
+ | `B140_OJ` Schottky | B140, SB140 | VF ≤ 0.5 V @ 1 A; typ 0.33 / 0.44 / 0.61 / 1.07 V @ 0.1 / 1 / 3 / 10 A | 0.346 / 0.461 / 0.613 / 1.08 V |
92
+ | | | CT 110 pF @ 4 V | 115 pF |
93
+ | `BZX79C{3V3,4V7,5V1,5V6,6V2,9V1,12,15}_OJ` | BZX79 500 mW | VZ and rZ at IZT = 5 mA | exact by construction |
94
+ | `1N4733A_OJ`, `1N4742A_OJ` | 1N47xxA 1 W | 5.1 V / 12 V at datasheet IZT | exact by construction |
95
+ | `LED_RED_OJ` | Generic red | VF 1.6 / 1.79 / 1.9 / 2.01 V @ 1 / 4 / 10 / 20 mA | 1.62 / 1.79 / 1.91 / 2.01 V |
96
+ | `LED_GREEN_OJ` | Generic green | VF 1.84 / 1.92 / 2.0 / 2.2 V @ 1 / 4 / 10 / 20 mA; C 15 pF | 1.79 / 1.89 / 2.00 / 2.14 V; 15 pF |
97
+ | `LED_BLUE_OJ` | Generic InGaN blue | VF 2.45 / 2.72 / 2.93 / 3.3 / 3.53 V @ 1 / 5 / 10 / 20 / 30 mA | 2.47 / 2.80 / 3.00 / 3.31 / 3.57 V |
98
+ | `TL07X_OJ` (one section) | TL071/072/074 | AOL 106 dB, GBW 3 MHz, SR 13 V/µs | 106 dB, 2.9 MHz (57° PM), 12.9 V/µs |
99
+ | | | ±13.5 V into 10 kΩ @ ±15 V, IQ 1.4 mA | ±13.38 V, 1.4 mA |
100
+ | `TL072_OJ`, `TL074_OJ` | TL072, TL074 | Complete packages in pin order; IQ 2.8 / 5.6 mA | every section checked; 2.8 / 5.6 mA |
101
+ | `LM358_OJ` (one section) | LM358, LM324 | GBW 0.7 MHz, SR 0.3 V/µs, AOL 100 dB | 0.72 MHz, 0.3 V/µs, 100 dB |
102
+ | | | swings to ~V− at light load, V+ − 1.5 V | 6 mV / V+ − 1.52 V into 10 kΩ |
103
+ | `LM358_DUAL_OJ`, `LM324_QUAD_OJ` | LM358, LM324 | Complete packages in pin order; IQ 0.7 mA at 5 V | every section checked; 0.7 mA |
104
+ | | | LM324: 1.2 MHz, 0.5 V/µs | 1.21 MHz (65° PM), 0.50 V/µs |
105
+
106
+ Rerun every check with `python tests/validate.py`, or name models to check only
107
+ those. It needs ngspice 47 or later and Python 3.13 or later, with nothing to install from pip. If
108
+ ngspice isn't on your `PATH`, set the `NGSPICE` environment variable to its location.
109
+
110
+ The targets and tolerances live in [`tests/models.toml`](tests/models.toml). See
111
+ [CONTRIBUTING.md](CONTRIBUTING.md) to add a model.
112
+
113
+ `POT_OJ` is a generic linear potentiometer. Set the total resistance with `R` and the
114
+ wiper position with `POS`; its values are exact by construction.
115
+
116
+ ## Use as a Python dependency
117
+
118
+ ```bash
119
+ pip install openjellybean
120
+ ```
121
+
122
+ or, in your project's `pyproject.toml`:
123
+
124
+ ```toml
125
+ dependencies = ["openjellybean>=0.6"]
126
+ ```
127
+
128
+ ```python
129
+ from openjellybean import library_path
130
+ print(library_path()) # path to the bundled jellybean.lib
131
+ ```
132
+
133
+ The path is a real file, so it can go straight into a netlist, for example
134
+ `.include /path/to/jellybean.lib`. To pin to an unreleased commit instead, install from
135
+ git: `pip install "git+https://github.com/xdylanm/openjellybean@<tag-or-commit>"`.
136
+
137
+ The package version is read from the `* Version X.Y.Z` line in the header of
138
+ `jellybean.lib`. Releasing means bumping that line, tagging `vX.Y.Z`, and publishing a
139
+ GitHub release, which uploads to [PyPI](https://pypi.org/project/openjellybean/).
140
+
141
+ ## Limits — read before trusting a result
142
+
143
+ * These are *typical* devices. Real parts spread widely (BC547 hFE spans
144
+ 110–800 across groups; 2N7000 VGS(th) spans 0.8–3 V). Run corners by
145
+ editing BF, VTO etc.
146
+ * BJTs: no breakdown or quasi-saturation modelled. Temperature uses standard
147
+ SPICE coefficients (not fitted).
148
+ * MOSFETs use the VDMOS model (ngspice ≥ 47, LTspice). For PSpice you would need
149
+ a subcircuit rewrite.
150
+ * JFETs use the standard square-law model: no gate breakdown, no conduction tail below
151
+ cutoff, and gate leakage is set by the simulator (about 30 pA at 15 V, against 5 pA typ on
152
+ J112/J113). Noise is not fitted. Datasheets give wide or no typical IDSS and VGS(off) for
153
+ most of these parts, so each model is one point inside the limits, and real parts spread
154
+ far more: run corners by editing `VTO` and `BETA`.
155
+ * `2N5457_OJ`-`2N5459_OJ` follow the datasheet's typical IDSS and VGS, which give about half
156
+ the gfs of its typical curves at 3 mA (1.9 mS, about 3.5 mS). J112, J113, PN4392 and PN4393
157
+ use `LAMBDA=0.035` to approach the published gos, so their drain current climbs more with
158
+ VDS than a real part at high current (J112: 30 mA at 5 V, 37 mA at 15 V).
159
+ * Zeners: VZ temperature coefficient and noise not modelled; knee shape is
160
+ approximate.
161
+ * Op-amps: no input common-mode range limits or phase reversal, no noise,
162
+ CMRR/PSRR, offset drift, or LM358 crossover distortion. VOS defaults to 0 —
163
+ use `OPAMP_OJ params: VOS=3m ...` to add offset.
164
+ * These typical values are not matched, because fixing them would mean changing the
165
+ model structure or trading off other fits: 1N5819 leakage is 1.6 µA at 40 V (about
166
+ 20 µA on the datasheet curve), 1N4148 leakage is 2.9 nA at 20 V (about 9 nA), and
167
+ LM358 short-circuit current is 27 mA (40 mA typ at a 10 V supply). BAT54 leakage is
168
+ 14 nA at 25 V (0.2 µA typ), and B140 leakage is 0.2 µA at 40 V (about 1.7 µA).
169
+ * `TL07X_OJ` matches the slower published TL07x figures, 3 MHz and 13 V/µs; some current
170
+ versions reach 5.25 MHz and 20 V/µs. `BC557B_OJ` also uses a slower figure, fT = 150 MHz;
171
+ some datasheets list up to 320 MHz.
172
+ * The LED models are electrical only, with no light output. They represent one typical
173
+ chemistry per color: green LEDs made with InGaN run near 3.2 V instead of 2.0 V, and red
174
+ varies with chemistry too. Reverse breakdown is not fitted, and only the green capacitance
175
+ is checked against a datasheet.
176
+ * `LM358_OJ` used as one LM324 section is slower and draws twice the supply current of a real
177
+ LM324. Use `LM324_QUAD_OJ` for the LM324's own figures.
178
+ * `POT_OJ` is linear only, with no log taper, power limit or temperature coefficient.
179
+ * Tested in ngspice 47 only; LTspice should accept the syntax
180
+ but hasn't been run.
@@ -0,0 +1,161 @@
1
+ # openjellybean — MIT-licensed jelly-bean SPICE models
2
+
3
+ One include file, `jellybean.lib`, with original models that behave like the
4
+ everyday parts. Every model was written from scratch and its parameters fitted
5
+ in ngspice to **typical** values from public datasheets — no manufacturer model
6
+ file was copied or adapted — so the whole set is under the MIT license.
7
+
8
+ Names end in `_OJ` so they never collide with vendor models.
9
+
10
+ ```spice
11
+ .include jellybean.lib
12
+ Q1 c b e BC547B_OJ ; BJT: C B E (SPICE order, not TO-92 pin order)
13
+ M1 d g s 2N7000_OJ ; VDMOS: D G S (body diode built in)
14
+ J1 d g s 2N5457_OJ ; JFET: D G S (SPICE order, not TO-92 pin order)
15
+ D1 a k 1N4148_OJ ; diode: A K
16
+ X1 a k BZX79C5V1_OJ ; zener: A K
17
+ X2 a k ZENER_OJ params: VZ=8.2 IZT=5m RZ=10 NK=1 ; any voltage
18
+ XU1 inp inn vcc vee out TL07X_OJ ; op-amp: +IN -IN V+ V- OUT
19
+ XU2 o1 n1 p1 vee p2 n2 o2 vcc TL072_OJ ; complete dual: pins 1-8 in order
20
+ XU3 o1 n1 p1 vcc p2 n2 o2 o3 n3 p3 vee p4 n4 o4 TL074_OJ ; complete quad: pins 1-14 in order
21
+ XU4 o1 n1 p1 gnd p2 n2 o2 vcc LM358_DUAL_OJ ; complete dual: pins 1-8 in order
22
+ XU5 o1 n1 p1 vcc p2 n2 o2 o3 n3 p3 gnd p4 n4 o4 LM324_QUAD_OJ ; complete quad: pins 1-14 in order
23
+ D2 a k LED_RED_OJ ; LED: A K (also LED_GREEN_OJ, LED_BLUE_OJ)
24
+ XR1 a w b POT_OJ params: R=10k POS=0.25 ; pot: A WIPER B; POS 0 = at A, 1 = at B
25
+ ```
26
+
27
+ ## Contents and verified behaviour (ngspice 47, 27 °C)
28
+
29
+ | Model | Stand-in for | Target (datasheet typ.) | Model |
30
+ |---|---|---|---|
31
+ | `BC547B_OJ` NPN | BC547B | hFE 290 @ 2 mA; 150 @ 10 µA | 282; 162 |
32
+ | | | VBE 0.66 V @ 2 mA | 0.658 V |
33
+ | | | VCE(sat) 90 / 200 mV @ 10 / 100 mA | 69 / 231 mV |
34
+ | | | fT 300 MHz @ 10 mA | 304 MHz |
35
+ | `BC557B_OJ` PNP | BC557B | hFE 290 @ 2 mA | 289 |
36
+ | | | VBE(on) 0.62 V @ 2 mA | 0.658 V |
37
+ | | | VCE(sat) 75 / 250 mV @ 10 / 100 mA | 64 / 247 mV |
38
+ | | | fT 150 MHz | 150 MHz |
39
+ | `2N3904_OJ` NPN | 2N3904, MMBT3904 | hFE 100–300 @ 10 mA (min 70 @ 1 mA, 30 @ 100 mA), VCE = 1 V | 157 (164 @ 1 mA, 75 @ 100 mA) |
40
+ | | | VCE(sat) ≤ 200 / 300 mV @ 10/1, 50/5 mA | 54 / 119 mV |
41
+ | | | fT ≥ 300 MHz (20 V, 10 mA, 100 MHz); Cobo ≤ 4 pF; Cibo ≤ 8 pF | 361 MHz; 2.4 pF; 5.0 pF |
42
+ | `2N3906_OJ` PNP | 2N3906, MMBT3906 | hFE 100–300 @ 10 mA (min 30 @ 100 mA), VCE = 1 V | 158 (79 @ 100 mA) |
43
+ | | | VCE(sat) ≤ 250 / 400 mV @ 10/1, 50/5 mA | 61 / 150 mV |
44
+ | | | fT ≥ 250 MHz (20 V, 10 mA, 100 MHz); Cobo ≤ 4.5 pF; Cibo ≤ 10 pF | 289 MHz; 3.1 pF; 6.7 pF |
45
+ | `2N7000_OJ` NMOS | 2N7000, 2N7002, BS170 | VGS(th) 2.1 V @ 1 mA | 2.02 V |
46
+ | | | RDS(on) 1.2 Ω @ 10 V; 1.8 Ω @ 4.5 V | 1.12 Ω; 2.06 Ω |
47
+ | | | Ciss / Coss / Crss 20 / 11 / 4 pF @ 25 V | 19.5 / 10.4 / 3.5 pF |
48
+ | `BS250_OJ` PMOS | BS250 | VGS(th) −1 to −3.5 V; RDS(on) 9 Ω @ −10 V | −2.4 V; 8.9 Ω |
49
+ | | | Ciss / Coss / Crss 30 / 20 / 5 pF @ 10 V | 30.0 / 20.1 / 5.0 pF |
50
+ | `2N5457_OJ` N-JFET | 2N5457, MMBF5457 | IDSS 3 mA; VGS −2.5 V @ 100 µA; gfs 1–5 mS; gos 10 µS | 3.02 mA; −2.51 V; 1.94 mS; 9.1 µS |
51
+ | | | Ciss / Crss 4.5 / 1.5 pF @ 15 V | 4.4 / 1.55 pF |
52
+ | `2N5458_OJ` N-JFET | 2N5458, MMBF5458 | IDSS 6 mA; VGS −3.5 V @ 200 µA; gfs 1.5–5.5 mS; gos 10 µS | 6.03 mA; −3.52 V; 2.74 mS; 9.4 µS |
53
+ | | | Ciss / Crss 4.5 / 1.5 pF @ 15 V | 4.3 / 1.59 pF |
54
+ | `2N5459_OJ` N-JFET | 2N5459, MMBF5459 | IDSS 9 mA; VGS −4.5 V @ 400 µA; gfs 2–6 mS; gos 10 µS | 8.98 mA; −4.53 V; 3.05 mS; 9.1 µS |
55
+ | | | Ciss / Crss 4.5 / 1.5 pF @ 15 V | 4.15 / 1.56 pF |
56
+ | `J112_OJ` N-JFET | J112, SST112 | VGS(off) −1 to −5 V; IDSS ≥ 5 mA (36 mA on the curves); rDS(on) ≤ 50 Ω | −2.19 V; 37 mA; 49 Ω |
57
+ | | | gfs 6 mS, gos 25 µS @ 1 mA; Ciss / Crss 7 / 3 pF @ −10 V | 6.4 mS, 20 µS; 7.3 / 3.0 pF |
58
+ | `J113_OJ` N-JFET | J113, SST113 | VGS(off) to −3 V; IDSS ≥ 2 mA (20 mA on the curves); rDS(on) ≤ 100 Ω (63 Ω on the curves) | −1.49 V; 20 mA; 65 Ω |
59
+ | | | gfs 6 mS, gos 25 µS @ 1 mA; Ciss / Crss 7 / 3 pF @ −10 V | 6.9 mS, 19 µS; 7.3 / 3.0 pF |
60
+ | `PN4392_OJ` N-JFET | PN4392, 2N4392 | VGS(off) −2 to −5 V; IDSS 25–75 mA; rDS(on) ≤ 60 Ω; VDS(on) 0.3 V @ 6 mA | −2.80 V; 50 mA; 49 Ω; 0.30 V |
61
+ | | | gfs 6 mS, gos 25 µS @ 1 mA; Ciss 12 pF @ 20 V; Crss 3.4 pF @ −7 V | 5.4 mS, 20 µS; 12.0 pF; 3.4 pF |
62
+ | `PN4393_OJ` N-JFET | PN4393, 2N4393 | VGS(off) −0.5 to −3 V; IDSS 5–30 mA; rDS(on) ≤ 100 Ω; VDS(on) 0.25 V @ 3 mA | −1.20 V; 14 mA; 78 Ω; 0.25 V |
63
+ | | | gfs 6 mS, gos 25 µS @ 1 mA; Ciss 12 pF @ 20 V; Crss 3.5 pF @ −5 V | 6.6 mS, 19 µS; 11.6 pF; 3.5 pF |
64
+ | `2N5460_OJ` P-JFET | 2N5460, MMBF5460 | IDSS 1–5 mA; VGS(off) 0.75–6 V; gfs 1–4 mS; Ciss / Crss 5 / 1 pF @ 15 V | 2.51 mA; 2.16 V; 2.18 mS; 4.8 / 0.99 pF |
65
+ | `2N5461_OJ` P-JFET | 2N5461, MMBF5461 | IDSS 2–9 mA; VGS(off) 1–7.5 V; gfs 1.5–5 mS; Ciss / Crss 5 / 1 pF @ 15 V | 4.50 mA; 2.96 V; 2.86 mS; 4.75 / 0.98 pF |
66
+ | `2N5462_OJ` P-JFET | 2N5462, MMBF5462 | IDSS 4–16 mA; VGS(off) 1.8–9 V; gfs 2–6 mS; Ciss / Crss 5 / 1 pF @ 15 V | 8.98 mA; 4.95 V; 3.46 mS; 4.75 / 1.01 pF |
67
+ | `1N4148_OJ` | 1N4148, 1N914 | VF 0.61 / 0.72 / 0.875 V @ 1 / 10 / 100 mA | 0.611 / 0.729 / 0.920 V |
68
+ | | | trr ≤ 8 ns (10 mA → 10 mA → 1 mA); ≤ 4 ns (10 mA, 6 V, 100 Ω) | 3.97 ns; 0.67 ns |
69
+ | `1N5819_OJ` Schottky | 1N5819 | VF 0.30 / 0.42 / 0.55 V @ 0.1 / 1 / 3 A | 0.306 / 0.419 / 0.563 V |
70
+ | `BAT54_OJ` Schottky | BAT54 | VF 0.22 / 0.29 / 0.35 / 0.41 / 0.52 V @ 0.1 / 1 / 10 / 30 / 100 mA | 0.230 / 0.290 / 0.360 / 0.410 / 0.518 V |
71
+ | | | CT 7.6 pF @ 1 V; trr ≤ 5 ns (10 mA → 10 mA → 1 mA, 100 Ω) | 7.6 pF; 2.65 ns |
72
+ | `B140_OJ` Schottky | B140, SB140 | VF ≤ 0.5 V @ 1 A; typ 0.33 / 0.44 / 0.61 / 1.07 V @ 0.1 / 1 / 3 / 10 A | 0.346 / 0.461 / 0.613 / 1.08 V |
73
+ | | | CT 110 pF @ 4 V | 115 pF |
74
+ | `BZX79C{3V3,4V7,5V1,5V6,6V2,9V1,12,15}_OJ` | BZX79 500 mW | VZ and rZ at IZT = 5 mA | exact by construction |
75
+ | `1N4733A_OJ`, `1N4742A_OJ` | 1N47xxA 1 W | 5.1 V / 12 V at datasheet IZT | exact by construction |
76
+ | `LED_RED_OJ` | Generic red | VF 1.6 / 1.79 / 1.9 / 2.01 V @ 1 / 4 / 10 / 20 mA | 1.62 / 1.79 / 1.91 / 2.01 V |
77
+ | `LED_GREEN_OJ` | Generic green | VF 1.84 / 1.92 / 2.0 / 2.2 V @ 1 / 4 / 10 / 20 mA; C 15 pF | 1.79 / 1.89 / 2.00 / 2.14 V; 15 pF |
78
+ | `LED_BLUE_OJ` | Generic InGaN blue | VF 2.45 / 2.72 / 2.93 / 3.3 / 3.53 V @ 1 / 5 / 10 / 20 / 30 mA | 2.47 / 2.80 / 3.00 / 3.31 / 3.57 V |
79
+ | `TL07X_OJ` (one section) | TL071/072/074 | AOL 106 dB, GBW 3 MHz, SR 13 V/µs | 106 dB, 2.9 MHz (57° PM), 12.9 V/µs |
80
+ | | | ±13.5 V into 10 kΩ @ ±15 V, IQ 1.4 mA | ±13.38 V, 1.4 mA |
81
+ | `TL072_OJ`, `TL074_OJ` | TL072, TL074 | Complete packages in pin order; IQ 2.8 / 5.6 mA | every section checked; 2.8 / 5.6 mA |
82
+ | `LM358_OJ` (one section) | LM358, LM324 | GBW 0.7 MHz, SR 0.3 V/µs, AOL 100 dB | 0.72 MHz, 0.3 V/µs, 100 dB |
83
+ | | | swings to ~V− at light load, V+ − 1.5 V | 6 mV / V+ − 1.52 V into 10 kΩ |
84
+ | `LM358_DUAL_OJ`, `LM324_QUAD_OJ` | LM358, LM324 | Complete packages in pin order; IQ 0.7 mA at 5 V | every section checked; 0.7 mA |
85
+ | | | LM324: 1.2 MHz, 0.5 V/µs | 1.21 MHz (65° PM), 0.50 V/µs |
86
+
87
+ Rerun every check with `python tests/validate.py`, or name models to check only
88
+ those. It needs ngspice 47 or later and Python 3.13 or later, with nothing to install from pip. If
89
+ ngspice isn't on your `PATH`, set the `NGSPICE` environment variable to its location.
90
+
91
+ The targets and tolerances live in [`tests/models.toml`](tests/models.toml). See
92
+ [CONTRIBUTING.md](CONTRIBUTING.md) to add a model.
93
+
94
+ `POT_OJ` is a generic linear potentiometer. Set the total resistance with `R` and the
95
+ wiper position with `POS`; its values are exact by construction.
96
+
97
+ ## Use as a Python dependency
98
+
99
+ ```bash
100
+ pip install openjellybean
101
+ ```
102
+
103
+ or, in your project's `pyproject.toml`:
104
+
105
+ ```toml
106
+ dependencies = ["openjellybean>=0.6"]
107
+ ```
108
+
109
+ ```python
110
+ from openjellybean import library_path
111
+ print(library_path()) # path to the bundled jellybean.lib
112
+ ```
113
+
114
+ The path is a real file, so it can go straight into a netlist, for example
115
+ `.include /path/to/jellybean.lib`. To pin to an unreleased commit instead, install from
116
+ git: `pip install "git+https://github.com/xdylanm/openjellybean@<tag-or-commit>"`.
117
+
118
+ The package version is read from the `* Version X.Y.Z` line in the header of
119
+ `jellybean.lib`. Releasing means bumping that line, tagging `vX.Y.Z`, and publishing a
120
+ GitHub release, which uploads to [PyPI](https://pypi.org/project/openjellybean/).
121
+
122
+ ## Limits — read before trusting a result
123
+
124
+ * These are *typical* devices. Real parts spread widely (BC547 hFE spans
125
+ 110–800 across groups; 2N7000 VGS(th) spans 0.8–3 V). Run corners by
126
+ editing BF, VTO etc.
127
+ * BJTs: no breakdown or quasi-saturation modelled. Temperature uses standard
128
+ SPICE coefficients (not fitted).
129
+ * MOSFETs use the VDMOS model (ngspice ≥ 47, LTspice). For PSpice you would need
130
+ a subcircuit rewrite.
131
+ * JFETs use the standard square-law model: no gate breakdown, no conduction tail below
132
+ cutoff, and gate leakage is set by the simulator (about 30 pA at 15 V, against 5 pA typ on
133
+ J112/J113). Noise is not fitted. Datasheets give wide or no typical IDSS and VGS(off) for
134
+ most of these parts, so each model is one point inside the limits, and real parts spread
135
+ far more: run corners by editing `VTO` and `BETA`.
136
+ * `2N5457_OJ`-`2N5459_OJ` follow the datasheet's typical IDSS and VGS, which give about half
137
+ the gfs of its typical curves at 3 mA (1.9 mS, about 3.5 mS). J112, J113, PN4392 and PN4393
138
+ use `LAMBDA=0.035` to approach the published gos, so their drain current climbs more with
139
+ VDS than a real part at high current (J112: 30 mA at 5 V, 37 mA at 15 V).
140
+ * Zeners: VZ temperature coefficient and noise not modelled; knee shape is
141
+ approximate.
142
+ * Op-amps: no input common-mode range limits or phase reversal, no noise,
143
+ CMRR/PSRR, offset drift, or LM358 crossover distortion. VOS defaults to 0 —
144
+ use `OPAMP_OJ params: VOS=3m ...` to add offset.
145
+ * These typical values are not matched, because fixing them would mean changing the
146
+ model structure or trading off other fits: 1N5819 leakage is 1.6 µA at 40 V (about
147
+ 20 µA on the datasheet curve), 1N4148 leakage is 2.9 nA at 20 V (about 9 nA), and
148
+ LM358 short-circuit current is 27 mA (40 mA typ at a 10 V supply). BAT54 leakage is
149
+ 14 nA at 25 V (0.2 µA typ), and B140 leakage is 0.2 µA at 40 V (about 1.7 µA).
150
+ * `TL07X_OJ` matches the slower published TL07x figures, 3 MHz and 13 V/µs; some current
151
+ versions reach 5.25 MHz and 20 V/µs. `BC557B_OJ` also uses a slower figure, fT = 150 MHz;
152
+ some datasheets list up to 320 MHz.
153
+ * The LED models are electrical only, with no light output. They represent one typical
154
+ chemistry per color: green LEDs made with InGaN run near 3.2 V instead of 2.0 V, and red
155
+ varies with chemistry too. Reverse breakdown is not fitted, and only the green capacitance
156
+ is checked against a datasheet.
157
+ * `LM358_OJ` used as one LM324 section is slower and draws twice the supply current of a real
158
+ LM324. Use `LM324_QUAD_OJ` for the LM324's own figures.
159
+ * `POT_OJ` is linear only, with no log taper, power limit or temperature coefficient.
160
+ * Tested in ngspice 47 only; LTspice should accept the syntax
161
+ but hasn't been run.
@@ -0,0 +1,276 @@
1
+ * =============================================================================
2
+ * openjellybean - generic "jelly bean" SPICE models
3
+ * Version 0.6.0
4
+ * https://github.com/xdylanm/openjellybean
5
+ * SPDX-License-Identifier: MIT
6
+ * Copyright (c) 2026 openjellybean contributors. See LICENSE for the full text.
7
+ *
8
+ * Original models written from scratch: parameters were fitted in ngspice to
9
+ * typical values published in public datasheets. No manufacturer model file
10
+ * was copied or adapted. They BEHAVE LIKE the named parts at typical bias;
11
+ * they are not the manufacturer's models and carry no manufacturer warranty.
12
+ * Names end in _OJ so they never collide with vendor models in the same tree.
13
+ *
14
+ * Tested with ngspice 47. Uses only standard SPICE syntax plus the VDMOS
15
+ * model (ngspice >= 47, LTspice) and subcircuit params: (ngspice, LTspice).
16
+ * =============================================================================
17
+
18
+ * ---------------------------------------------------------------- BJTs ------
19
+ * BC547B_OJ : small-signal NPN, 45 V / 100 mA class, hFE group B
20
+ * BC557B_OJ : complementary PNP
21
+ .model BC547B_OJ NPN(IS=1.8e-14 NF=1 BF=330 VAF=65 IKF=0.12 ISE=5e-14 NE=1.5
22
+ + BR=4 NR=1 VAR=20 IKR=0.1 ISC=1e-13 NC=2
23
+ + RB=40 RE=0.4 RC=1.2
24
+ + CJE=10p VJE=0.7 MJE=0.33 CJC=4p VJC=0.6 MJC=0.33 FC=0.5
25
+ + TF=0.45n XTF=2 VTF=10 ITF=0.1 TR=50n
26
+ + EG=1.11 XTI=3 XTB=1.5)
27
+
28
+ .model BC557B_OJ PNP(IS=1.8e-14 NF=1 BF=330 VAF=40 IKF=0.1 ISE=5e-14 NE=1.5
29
+ + BR=6 NR=1 VAR=15 IKR=0.08 ISC=1e-13 NC=2
30
+ + RB=40 RE=0.6 RC=1.2
31
+ + CJE=12p VJE=0.7 MJE=0.33 CJC=7p VJC=0.6 MJC=0.33 FC=0.5
32
+ + TF=0.95n XTF=2 VTF=10 ITF=0.1 TR=60n
33
+ + EG=1.11 XTI=3 XTB=1.5)
34
+
35
+ * 2N3904_OJ : 40 V / 200 mA general-purpose NPN (TO-92 pinout E-B-C)
36
+ * 2N3906_OJ : complementary PNP
37
+ .model 2N3904_OJ NPN(IS=1e-14 NF=1 BF=200 VAF=90 IKF=0.07 ISE=4e-14 NE=1.5
38
+ + BR=4 NR=1 VAR=20 IKR=0.1 ISC=1e-13 NC=2
39
+ + RB=10 RE=0.3 RC=1
40
+ + CJE=6p VJE=0.7 MJE=0.33 CJC=5p VJC=0.6 MJC=0.33 FC=0.5
41
+ + TF=0.4n XTF=2 VTF=10 ITF=0.1 TR=30n
42
+ + EG=1.11 XTI=3 XTB=1.5)
43
+
44
+ .model 2N3906_OJ PNP(IS=1e-14 NF=1 BF=200 VAF=35 IKF=0.08 ISE=4e-14 NE=1.5
45
+ + BR=4 NR=1 VAR=15 IKR=0.08 ISC=1e-13 NC=2
46
+ + RB=10 RE=0.4 RC=1.5
47
+ + CJE=8p VJE=0.7 MJE=0.33 CJC=6.5p VJC=0.6 MJC=0.33 FC=0.5
48
+ + TF=0.5n XTF=2 VTF=10 ITF=0.1 TR=40n
49
+ + EG=1.11 XTI=3 XTB=1.5)
50
+
51
+ * ------------------------------------------------------------ MOSFETs -------
52
+ * VDMOS model: 3 terminals (D G S), body diode built in.
53
+ * 2N7000_OJ : 60 V small-signal N-channel (also a fair 2N7002 / BS170 stand-in)
54
+ * BS250_OJ : 45 V small-signal P-channel
55
+ .model 2N7000_OJ VDMOS(VTO=2.0 KP=0.3 LAMBDA=0.01 RD=0.6 RS=0.1 RG=10
56
+ + CGS=16p CGDMAX=20p CGDMIN=3p A=0.5
57
+ + CJO=40p VJ=0.75 M=0.5 IS=1e-13 N=1.1 RB=0.2 BV=60 IBV=10u TT=20n)
58
+
59
+ .model BS250_OJ VDMOS(pchan VTO=-2.1 KP=0.02 LAMBDA=0.01 RD=1.8 RS=0.2 RG=10
60
+ + CGS=25p CGDMAX=21p CGDMIN=3.7p A=0.5
61
+ + CJO=57p VJ=0.75 M=0.5 IS=1e-13 N=1.1 RB=0.5 BV=45 IBV=10u TT=30n)
62
+
63
+ * -------------------------------------------------------------- JFETs -------
64
+ * Pins D G S. VTO is negative for both polarities, as SPICE defines it.
65
+ * 2N5457_OJ .. 2N5459_OJ : N-channel general-purpose amplifiers, 25 V
66
+ .model 2N5457_OJ NJF(VTO=-3.06 BETA=3.2e-4 LAMBDA=3.3e-3 RD=20 RS=20
67
+ + CGS=3.2p CGD=5.5p PB=1 IS=1e-14 FC=0.5)
68
+ .model 2N5458_OJ NJF(VTO=-4.28 BETA=3.4e-4 LAMBDA=1.7e-3 RD=20 RS=20
69
+ + CGS=3.2p CGD=5.4p PB=1 IS=1e-14 FC=0.5)
70
+ .model 2N5459_OJ NJF(VTO=-5.7 BETA=2.9e-4 LAMBDA=1.1e-3 RD=20 RS=20
71
+ + CGS=3.2p CGD=5.2p PB=1 IS=1e-14 FC=0.5)
72
+
73
+ * J112_OJ, J113_OJ : N-channel analog switches, 35 V
74
+ .model J112_OJ NJF(VTO=-2.2 BETA=6.6e-3 LAMBDA=0.035 RD=7 RS=7
75
+ + CGS=13p CGD=9p PB=1.25 IS=1e-15 FC=0.5)
76
+ .model J113_OJ NJF(VTO=-1.5 BETA=8.3e-3 LAMBDA=0.035 RD=12 RS=12
77
+ + CGS=13p CGD=9p PB=1.25 IS=1e-15 FC=0.5)
78
+
79
+ * PN4392_OJ, PN4393_OJ : N-channel switches, 40 V
80
+ .model PN4392_OJ NJF(VTO=-2.8 BETA=4.4e-3 LAMBDA=0.035 RD=4 RS=4
81
+ + CGS=12p CGD=9p PB=1.17 IS=1e-15 FC=0.5)
82
+ .model PN4393_OJ NJF(VTO=-1.2 BETA=7.4e-3 LAMBDA=0.035 RD=10 RS=10
83
+ + CGS=12.5p CGD=8p PB=1.17 IS=1e-15 FC=0.5)
84
+
85
+ * 2N5460_OJ .. 2N5462_OJ : P-channel general-purpose amplifiers, 40 V
86
+ .model 2N5460_OJ PJF(VTO=-2.2 BETA=5.3e-4 LAMBDA=5e-3 RD=40 RS=40
87
+ + CGS=4.8p CGD=2.3p PB=1 IS=1e-14 FC=0.5)
88
+ .model 2N5461_OJ PJF(VTO=-3 BETA=5.1e-4 LAMBDA=5e-3 RD=30 RS=30
89
+ + CGS=4.8p CGD=2.3p PB=1 IS=1e-14 FC=0.5)
90
+ .model 2N5462_OJ PJF(VTO=-5 BETA=3.7e-4 LAMBDA=3e-3 RD=20 RS=20
91
+ + CGS=4.7p CGD=2.7p PB=1 IS=1e-14 FC=0.5)
92
+
93
+ * ------------------------------------------------------------- Diodes -------
94
+ * 1N4148_OJ : small-signal fast switching (also 1N914)
95
+ .model 1N4148_OJ D(IS=2.9n N=1.85 RS=0.9 BV=100 IBV=100u
96
+ + CJO=2p VJ=0.5 M=0.33 TT=2.5n EG=1.11 XTI=3)
97
+
98
+ * 1N5819_OJ : 1 A / 40 V Schottky
99
+ .model 1N5819_OJ D(IS=1.6u N=1.05 RS=0.057 BV=40 IBV=1m
100
+ + CJO=300p VJ=0.5 M=0.45 TT=0 EG=0.69 XTI=2)
101
+
102
+ * BAT54_OJ : 200 mA / 30 V small-signal Schottky (one diode of the A/C/S duals)
103
+ .model BAT54_OJ D(IS=14n N=1 RS=1.1 BV=30 IBV=10u
104
+ + CJO=13.5p VJ=0.3 M=0.39 TT=0 EG=0.69 XTI=2)
105
+
106
+ * B140_OJ : 1 A / 40 V Schottky rectifier (also a fair SB140 stand-in)
107
+ .model B140_OJ D(IS=200n N=1 RS=0.062 BV=45 IBV=500u
108
+ + CJO=310p VJ=0.5 M=0.45 TT=0 EG=0.69 XTI=2)
109
+
110
+ * ------------------------------------------------------------- Zeners -------
111
+ * Generic zener: X1 anode cathode ZENER_OJ params: VZ=5.1 IZT=5m RZ=40 NK=1.5
112
+ * VZ : zener voltage at test current IZT
113
+ * RZ : total dynamic impedance at IZT (as quoted on datasheets)
114
+ * NK : knee softness (1 = sharp, 2-3 = the soft knee of sub-5 V parts)
115
+ .subckt ZENER_OJ a k params: VZ=5.1 IZT=5m RZ=40 NK=1.5
116
+ .param RSER={max(RZ - NK*0.025865/IZT, 0.01)}
117
+ .param VOFS={VZ - IZT*RSER - NK*0.025865*ln(IZT/1e-12)}
118
+ Df a k dfwd
119
+ Vof k n1 {VOFS}
120
+ Dbk n1 n2 dknee
121
+ Rz n2 a {RSER}
122
+ .model dfwd D(IS=3n N=1.8 RS=0.5 CJO=40p VJ=0.75 M=0.4 TT=50n)
123
+ .model dknee D(IS=1e-12 N={NK})
124
+ .ends ZENER_OJ
125
+
126
+ * 500 mW glass zeners, BZX79 class, specified at IZT = 5 mA
127
+ .subckt BZX79C3V3_OJ a k
128
+ X1 a k ZENER_OJ params: VZ=3.3 IZT=5m RZ=85 NK=3
129
+ .ends
130
+ .subckt BZX79C4V7_OJ a k
131
+ X1 a k ZENER_OJ params: VZ=4.7 IZT=5m RZ=50 NK=2.5
132
+ .ends
133
+ .subckt BZX79C5V1_OJ a k
134
+ X1 a k ZENER_OJ params: VZ=5.1 IZT=5m RZ=40 NK=2
135
+ .ends
136
+ .subckt BZX79C5V6_OJ a k
137
+ X1 a k ZENER_OJ params: VZ=5.6 IZT=5m RZ=15 NK=1.5
138
+ .ends
139
+ .subckt BZX79C6V2_OJ a k
140
+ X1 a k ZENER_OJ params: VZ=6.2 IZT=5m RZ=6 NK=1
141
+ .ends
142
+ .subckt BZX79C9V1_OJ a k
143
+ X1 a k ZENER_OJ params: VZ=9.1 IZT=5m RZ=6 NK=1
144
+ .ends
145
+ .subckt BZX79C12_OJ a k
146
+ X1 a k ZENER_OJ params: VZ=12 IZT=5m RZ=10 NK=1
147
+ .ends
148
+ .subckt BZX79C15_OJ a k
149
+ X1 a k ZENER_OJ params: VZ=15 IZT=5m RZ=10 NK=1
150
+ .ends
151
+ * 1 W, 1N47xxA class, specified at the datasheet IZT
152
+ .subckt 1N4733A_OJ a k
153
+ X1 a k ZENER_OJ params: VZ=5.1 IZT=49m RZ=7 NK=2
154
+ .ends
155
+ .subckt 1N4742A_OJ a k
156
+ X1 a k ZENER_OJ params: VZ=12 IZT=21m RZ=9 NK=1
157
+ .ends
158
+
159
+ * ---------------------------------------------------------------- LEDs ------
160
+ * Generic 5 mm indicator LEDs, one color each: D1 a k LED_RED_OJ
161
+ * LED_RED_OJ : high-efficiency red, VF about 1.9 V at 10 mA
162
+ * LED_GREEN_OJ : standard green, VF about 2.0 V at 10 mA
163
+ * LED_BLUE_OJ : InGaN blue, VF about 3.3 V at 20 mA
164
+ .model LED_RED_OJ D(IS=1.4n N=4.64 RS=1.7 BV=10 IBV=10u
165
+ + CJO=15p VJ=0.75 M=0.33 TT=0 EG=2.46 XTI=0)
166
+ .model LED_GREEN_OJ D(IS=1.1e-18 N=2 RS=10 BV=10 IBV=10u
167
+ + CJO=15p VJ=0.75 M=0.33 TT=0 EG=2.44 XTI=0)
168
+ .model LED_BLUE_OJ D(IS=1.4e-10 N=6 RS=19.7 BV=10 IBV=10u
169
+ + CJO=65p VJ=0.75 M=0.33 TT=0 EG=3.8 XTI=0)
170
+
171
+ * ------------------------------------------------------------- Op-amps ------
172
+ * Pin order (TI / LTspice convention): +IN -IN V+ V- OUT
173
+ * Generic single-pole + second-pole macromodel with slew limit, output swing
174
+ * limits, short-circuit current limit and supply current that follows the
175
+ * load (output current is drawn from the correct rail).
176
+ * Not modelled: input common-mode range limits / phase reversal, noise,
177
+ * CMRR/PSRR, offset drift, LM358 crossover distortion.
178
+ * GBW [Hz] SR [V/s] AOL [V/V] VOS [V] IB [A, into each pin]
179
+ * ISC [A] IQ [A per amplifier] VOH/VOL: headroom from V+ / V- [V]
180
+ * ROUT: open-loop output resistance [ohm] FP2: second pole [Hz]
181
+ .subckt OPAMP_OJ inp inn vcc vee out params: GBW=3e6 SR=13e6 AOL=200k
182
+ + VOS=0 IB=30p RIN=1e12 CIN=3p ISC=30m IQ=1.4m VOH=1.5 VOL=1.5 ROUT=100 FP2=4.5e6
183
+ .param CC=1n
184
+ .param IMAX={SR*CC}
185
+ .param GM={6.2831853*GBW*CC}
186
+ .param VLIN={IMAX/GM}
187
+ Bmid mid 0 V={(V(vcc)+V(vee))/2}
188
+ Iq vcc vee {IQ}
189
+ Vos inp inp1 {VOS}
190
+ Ibp inp mid {IB}
191
+ Ibn inn mid {IB}
192
+ Rin inp1 inn {RIN}
193
+ Cinp inp1 mid {CIN}
194
+ Cinn inn mid {CIN}
195
+ * transconductance with tanh slew limit -> integrator
196
+ Bg mid int I={IMAX}*tanh((V(inp1)-V(inn))/{VLIN})
197
+ Cc int mid {CC}
198
+ Rint int mid {AOL/GM}
199
+ * output-swing clamps
200
+ Bhi nhi 0 V=V(vcc)-{VOH}
201
+ Blo nlo 0 V=V(vee)+{VOL}
202
+ Dhi int nhi dclamp
203
+ Dlo nlo int dclamp
204
+ * second pole
205
+ E2 p2a 0 int 0 1
206
+ Rp2 p2a p2 1k
207
+ Cp2 p2 0 {1/(6.2831853*FP2*1k)}
208
+ * current-limited output, current drawn from the rails
209
+ * soft current limit: I = ISC*x/(1+x^4)^0.25, x=(V(p2)-V(out))/(ROUT*ISC)
210
+ Bx x 0 V=(V(p2)-V(out))/({ROUT}*{ISC})
211
+ Bsrc vcc out I={ISC}*0.5*(abs(V(x))+V(x))/pwr(1+V(x)*V(x)*V(x)*V(x),0.25)
212
+ Bsnk out vee I={ISC}*0.5*(abs(V(x))-V(x))/pwr(1+V(x)*V(x)*V(x)*V(x),0.25)
213
+ .model dclamp D(IS=1e-15 N=0.02)
214
+ .ends OPAMP_OJ
215
+
216
+ * TL07X_OJ : one section of a TL071/TL072/TL074-class JFET-input op-amp
217
+ .subckt TL07X_OJ inp inn vcc vee out
218
+ * GBW/FP2 chosen so the unity-gain frequency lands at ~3 MHz with ~55-60 deg PM
219
+ X1 inp inn vcc vee out OPAMP_OJ params: GBW=3.5e6 SR=13e6 AOL=200k IB=30p
220
+ + RIN=1e12 CIN=3p ISC=30m IQ=1.4m VOH=1.5 VOL=1.5 ROUT=100 FP2=4.5e6
221
+ .ends TL07X_OJ
222
+
223
+ * TL072_OJ : complete dual package, pins 1-8 in order:
224
+ * 1OUT 1IN- 1IN+ VCC- 2IN+ 2IN- 2OUT VCC+
225
+ .subckt TL072_OJ out1 inn1 inp1 vee inp2 inn2 out2 vcc
226
+ XA inp1 inn1 vcc vee out1 TL07X_OJ
227
+ XB inp2 inn2 vcc vee out2 TL07X_OJ
228
+ .ends TL072_OJ
229
+
230
+ * TL074_OJ : complete quad package, pins 1-14 in order:
231
+ * 1OUT 1IN- 1IN+ VCC+ 2IN+ 2IN- 2OUT 3OUT 3IN- 3IN+ VCC- 4IN+ 4IN- 4OUT
232
+ .subckt TL074_OJ out1 inn1 inp1 vcc inp2 inn2 out2 out3 inn3 inp3 vee inp4 inn4 out4
233
+ XA inp1 inn1 vcc vee out1 TL07X_OJ
234
+ XB inp2 inn2 vcc vee out2 TL07X_OJ
235
+ XC inp3 inn3 vcc vee out3 TL07X_OJ
236
+ XD inp4 inn4 vcc vee out4 TL07X_OJ
237
+ .ends TL074_OJ
238
+
239
+ * LM358_OJ : one section of an LM358/LM324-class single-supply op-amp
240
+ * (output swings to within ~10 mV of V- at light load; bias current flows
241
+ * out of the pins, hence negative IB)
242
+ .subckt LM358_OJ inp inn vcc vee out
243
+ X1 inp inn vcc vee out OPAMP_OJ params: GBW=0.8e6 SR=0.3e6 AOL=100k IB=-20n
244
+ + RIN=10Meg CIN=3p ISC=30m IQ=0.35m VOH=1.5 VOL=0.02 ROUT=100 FP2=1.5e6
245
+ .ends LM358_OJ
246
+
247
+ * LM358_DUAL_OJ : complete dual package, pins 1-8 in order:
248
+ * 1OUT 1IN- 1IN+ GND 2IN+ 2IN- 2OUT VCC+
249
+ .subckt LM358_DUAL_OJ out1 inn1 inp1 vee inp2 inn2 out2 vcc
250
+ XA inp1 inn1 vcc vee out1 LM358_OJ
251
+ XB inp2 inn2 vcc vee out2 LM358_OJ
252
+ .ends LM358_DUAL_OJ
253
+
254
+ * LM324_QUAD_OJ : complete quad package, pins 1-14 in order:
255
+ * 1OUT 1IN- 1IN+ VCC+ 2IN+ 2IN- 2OUT 3OUT 3IN- 3IN+ GND 4IN+ 4IN- 4OUT
256
+ * Sections follow the LM324's own datasheet: faster than LM358_OJ, half the supply current.
257
+ .subckt LM324_QUAD_OJ out1 inn1 inp1 vcc inp2 inn2 out2 out3 inn3 inp3 vee inp4 inn4 out4
258
+ .subckt section inp inn vcc vee out
259
+ X1 inp inn vcc vee out OPAMP_OJ params: GBW=1.34e6 SR=0.5e6 AOL=100k IB=-20n
260
+ + RIN=10Meg CIN=3p ISC=30m IQ=0.175m VOH=1.5 VOL=0.02 ROUT=100 FP2=2.5e6
261
+ .ends section
262
+ XA inp1 inn1 vcc vee out1 section
263
+ XB inp2 inn2 vcc vee out2 section
264
+ XC inp3 inn3 vcc vee out3 section
265
+ XD inp4 inn4 vcc vee out4 section
266
+ .ends LM324_QUAD_OJ
267
+
268
+ * ------------------------------------------------------- Potentiometers -----
269
+ * Generic linear potentiometer: X1 a w b POT_OJ params: R=10k POS=0.5
270
+ * R : total resistance from A to B [ohm]
271
+ * POS : wiper position, 0 = at A, 1 = at B (limited to that range)
272
+ .subckt POT_OJ a w b params: R=10k POS=0.5
273
+ .param FRAC={max(min(POS,1),0)}
274
+ Ra a w {max(R*FRAC,1e-3)}
275
+ Rb w b {max(R*(1-FRAC),1e-3)}
276
+ .ends POT_OJ
@@ -0,0 +1,45 @@
1
+ [build-system]
2
+ requires = ["hatchling>=1.26"]
3
+ build-backend = "hatchling.build"
4
+
5
+ [project]
6
+ name = "openjellybean"
7
+ dynamic = ["version"]
8
+ description = "Generic, original 'jelly bean' SPICE models, packaged for use as a dependency"
9
+ readme = "README.md"
10
+ requires-python = ">=3.13"
11
+ license = "MIT"
12
+ license-files = ["LICENSE"]
13
+ authors = [{ name = "xdylanm" }]
14
+ keywords = ["spice", "ngspice", "ltspice", "models", "netlist"]
15
+ classifiers = [
16
+ "Development Status :: 3 - Alpha",
17
+ "Intended Audience :: Science/Research",
18
+ "Operating System :: OS Independent",
19
+ "Programming Language :: Python :: 3",
20
+ "Programming Language :: Python :: 3.13",
21
+ "Topic :: Scientific/Engineering :: Electronic Design Automation (EDA)",
22
+ ]
23
+ dependencies = []
24
+
25
+ [project.urls]
26
+ Homepage = "https://github.com/xdylanm/openjellybean"
27
+ Repository = "https://github.com/xdylanm/openjellybean"
28
+
29
+ # The version lives in exactly one place: the "* Version X.Y.Z" line in the
30
+ # header of jellybean.lib. Bump it there and tag the release vX.Y.Z.
31
+ [tool.hatch.version]
32
+ path = "jellybean.lib"
33
+ pattern = '(?m)^\* Version (?P<version>\d+\.\d+\.\d+\S*)\s*$'
34
+
35
+ [tool.hatch.build.targets.wheel]
36
+ packages = ["src/openjellybean"]
37
+
38
+ [tool.hatch.build.targets.wheel.force-include]
39
+ "jellybean.lib" = "openjellybean/jellybean.lib"
40
+
41
+ [tool.hatch.build.targets.sdist]
42
+ include = ["src/openjellybean", "jellybean.lib", "README.md", "LICENSE"]
43
+
44
+ [tool.hatch.build.targets.sdist.force-include]
45
+ "jellybean.lib" = "jellybean.lib"
@@ -0,0 +1,26 @@
1
+ """openjellybean: generic "jelly bean" SPICE models.
2
+
3
+ Use :func:`library_path` to locate ``jellybean.lib`` for ``.include``/``.lib``
4
+ lines or for tools that take a model file path.
5
+ """
6
+
7
+ from __future__ import annotations
8
+
9
+ from importlib import resources
10
+ from importlib.metadata import PackageNotFoundError, version as _version
11
+ from pathlib import Path
12
+
13
+ try:
14
+ __version__ = _version("openjellybean")
15
+ except PackageNotFoundError: # running from a source tree without installation
16
+ __version__ = "0+unknown"
17
+
18
+ __all__ = ["__version__", "library_path"]
19
+
20
+
21
+ def library_path() -> Path:
22
+ """Return the filesystem path of the bundled ``jellybean.lib``.
23
+
24
+ The package is installed unzipped, so the resource is a real file.
25
+ """
26
+ return Path(str(resources.files(__package__).joinpath("jellybean.lib")))