circuit-json-to-spice 0.0.26 → 0.0.28
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.
- package/README.md +1 -0
- package/dist/index.js +80 -26
- package/lib/circuitJsonToSpice.ts +73 -4
- package/package.json +1 -1
- package/tests/examples/assets/buck-converter.json +1266 -0
- package/tests/examples/assets/switch.json +999 -0
- package/tests/examples/boost-converter.test.tsx +2 -2
- package/tests/examples/buck-converter.test.tsx +30 -0
- package/tests/examples/switch.test.tsx +29 -0
|
@@ -17,12 +17,12 @@ test(
|
|
|
17
17
|
expect(spiceString).toMatchInlineSnapshot(`
|
|
18
18
|
"* Circuit JSON to SPICE Netlist
|
|
19
19
|
.MODEL D D
|
|
20
|
-
.MODEL
|
|
20
|
+
.MODEL ENH_SW SW(Ron=0.1 Roff=1e9 Vt=2.5 Vh=0.1)
|
|
21
21
|
LL1 N1 N2 1
|
|
22
22
|
DD1 N2 N3 D
|
|
23
23
|
CC1 N3 0 10U
|
|
24
24
|
RR1 N3 0 1K
|
|
25
|
-
SM1 N2 0 N4 0
|
|
25
|
+
SM1 N2 0 N4 0 ENH_SW
|
|
26
26
|
Vsimulation_voltage_source_0 N1 0 DC 5
|
|
27
27
|
Vsimulation_voltage_source_1 N4 0 PULSE(0 10 0 1n 1n 0.00068 0.001)
|
|
28
28
|
.END"
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { test, expect } from "bun:test"
|
|
2
|
+
import { circuitJsonToSpice } from "lib/circuitJsonToSpice"
|
|
3
|
+
import buckConverterCircuit from "./assets/buck-converter.json"
|
|
4
|
+
|
|
5
|
+
test(
|
|
6
|
+
"Buck converter circuit",
|
|
7
|
+
async () => {
|
|
8
|
+
const circuitJson = buckConverterCircuit as any
|
|
9
|
+
|
|
10
|
+
const spiceNetlist = circuitJsonToSpice(circuitJson)
|
|
11
|
+
const spiceString = spiceNetlist.toSpiceString()
|
|
12
|
+
|
|
13
|
+
expect(spiceString).toMatchInlineSnapshot(`
|
|
14
|
+
"* Circuit JSON to SPICE Netlist
|
|
15
|
+
.MODEL ENH_SW SW(Ron=0.1 Roff=1e9 Vt=2.5 Vh=0.1)
|
|
16
|
+
.MODEL D D
|
|
17
|
+
SM1 N2 VP_IN VP_IN N1 ENH_SW
|
|
18
|
+
DD1 0 N2 D
|
|
19
|
+
LL1 N2 VP_OUT 10
|
|
20
|
+
CC1 VP_OUT 0 10U
|
|
21
|
+
RR1 VP_OUT 0 1K
|
|
22
|
+
Vsimulation_voltage_source_0 VP_IN 0 DC 5
|
|
23
|
+
Vsimulation_voltage_source_1 N1 0 PULSE(0 10 0 1n 1n 0.0005 0.001)
|
|
24
|
+
.PRINT TRAN V(VP_IN) V(VP_OUT)
|
|
25
|
+
.tran 0.00001 0.05 UIC
|
|
26
|
+
.END"
|
|
27
|
+
`)
|
|
28
|
+
},
|
|
29
|
+
{ timeout: 10000 },
|
|
30
|
+
)
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { test, expect } from "bun:test"
|
|
2
|
+
import { circuitJsonToSpice } from "lib/circuitJsonToSpice"
|
|
3
|
+
import switchCircuit from "./assets/switch.json"
|
|
4
|
+
|
|
5
|
+
test(
|
|
6
|
+
"Switch circuit",
|
|
7
|
+
async () => {
|
|
8
|
+
const circuitJson = switchCircuit as any
|
|
9
|
+
|
|
10
|
+
const spiceNetlist = circuitJsonToSpice(circuitJson)
|
|
11
|
+
const spiceString = spiceNetlist.toSpiceString()
|
|
12
|
+
|
|
13
|
+
expect(spiceString).toMatchInlineSnapshot(`
|
|
14
|
+
"* Circuit JSON to SPICE Netlist
|
|
15
|
+
.MODEL SW_SW1 SW(Ron=0.1 Roff=1e9 Vt=2.5 Vh=0.1)
|
|
16
|
+
.MODEL NPN NPN
|
|
17
|
+
RR_base N1 VP_BASE 10K
|
|
18
|
+
VCTRL_SW1 NCTRL_SW1 0 PULSE(0 5 0 1n 1n 0.0005 0.001)
|
|
19
|
+
SSW1 VP_BASE N2 NCTRL_SW1 0 SW_SW1
|
|
20
|
+
QQ1 VP_COLLECTOR N2 0 NPN
|
|
21
|
+
RR_collector N1 VP_COLLECTOR 300
|
|
22
|
+
Vsimulation_voltage_source_0 N1 0 DC 5
|
|
23
|
+
.PRINT TRAN V(VP_BASE) V(VP_COLLECTOR)
|
|
24
|
+
.tran 0.00005 0.004 UIC
|
|
25
|
+
.END"
|
|
26
|
+
`)
|
|
27
|
+
},
|
|
28
|
+
{ timeout: 10000 },
|
|
29
|
+
)
|