circuit-json-to-spice 0.0.40 → 0.0.41

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/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "circuit-json-to-spice",
3
3
  "main": "dist/index.js",
4
- "version": "0.0.40",
4
+ "version": "0.0.41",
5
5
  "type": "module",
6
6
  "scripts": {
7
7
  "build": "tsup-node ./lib/index.ts --dts --format esm --sourcemap inline -d dist",
@@ -0,0 +1,472 @@
1
+ [
2
+ {
3
+ "type": "source_project_metadata",
4
+ "source_project_metadata_id": "source_project_metadata_0",
5
+ "software_used_string": "@tscircuit/core@0.0.874"
6
+ },
7
+ {
8
+ "type": "source_group",
9
+ "source_group_id": "source_group_0",
10
+ "is_subcircuit": true,
11
+ "was_automatically_named": true,
12
+ "subcircuit_id": "subcircuit_source_group_0"
13
+ },
14
+ {
15
+ "type": "source_port",
16
+ "source_port_id": "source_port_0",
17
+ "name": "pin1",
18
+ "pin_number": 1,
19
+ "port_hints": ["pin1", "terminal1", "1"],
20
+ "source_component_id": "source_component_0",
21
+ "subcircuit_id": "subcircuit_source_group_0",
22
+ "subcircuit_connectivity_map_key": "unnamedsubcircuit303_connectivity_net0"
23
+ },
24
+ {
25
+ "type": "source_port",
26
+ "source_port_id": "source_port_1",
27
+ "name": "pin2",
28
+ "pin_number": 2,
29
+ "port_hints": ["pin2", "terminal2", "2"],
30
+ "source_component_id": "source_component_0",
31
+ "subcircuit_id": "subcircuit_source_group_0",
32
+ "subcircuit_connectivity_map_key": "unnamedsubcircuit303_connectivity_net2"
33
+ },
34
+ {
35
+ "type": "source_component",
36
+ "source_component_id": "source_component_0",
37
+ "ftype": "simple_voltage_source",
38
+ "name": "VS1",
39
+ "voltage": 5,
40
+ "frequency": 60,
41
+ "wave_shape": "sinewave",
42
+ "are_pins_interchangeable": true,
43
+ "source_group_id": "source_group_0"
44
+ },
45
+ {
46
+ "type": "source_port",
47
+ "source_port_id": "source_port_2",
48
+ "name": "pin1",
49
+ "pin_number": 1,
50
+ "port_hints": ["pin1", "anode", "pos", "left", "1"],
51
+ "source_component_id": "source_component_1",
52
+ "subcircuit_id": "subcircuit_source_group_0",
53
+ "subcircuit_connectivity_map_key": "unnamedsubcircuit303_connectivity_net0"
54
+ },
55
+ {
56
+ "type": "source_port",
57
+ "source_port_id": "source_port_3",
58
+ "name": "pin2",
59
+ "pin_number": 2,
60
+ "port_hints": ["pin2", "cathode", "neg", "right", "2"],
61
+ "source_component_id": "source_component_1",
62
+ "subcircuit_id": "subcircuit_source_group_0",
63
+ "subcircuit_connectivity_map_key": "unnamedsubcircuit303_connectivity_net1"
64
+ },
65
+ {
66
+ "type": "source_component",
67
+ "source_component_id": "source_component_1",
68
+ "ftype": "simple_resistor",
69
+ "name": "R1",
70
+ "resistance": 10000,
71
+ "display_resistance": "10kΩ",
72
+ "are_pins_interchangeable": true,
73
+ "source_group_id": "source_group_0"
74
+ },
75
+ {
76
+ "type": "source_port",
77
+ "source_port_id": "source_port_4",
78
+ "name": "pin1",
79
+ "pin_number": 1,
80
+ "port_hints": ["pin1", "anode", "pos", "left", "1"],
81
+ "source_component_id": "source_component_2",
82
+ "subcircuit_id": "subcircuit_source_group_0",
83
+ "subcircuit_connectivity_map_key": "unnamedsubcircuit303_connectivity_net1"
84
+ },
85
+ {
86
+ "type": "source_port",
87
+ "source_port_id": "source_port_5",
88
+ "name": "pin2",
89
+ "pin_number": 2,
90
+ "port_hints": ["pin2", "cathode", "neg", "right", "2"],
91
+ "source_component_id": "source_component_2",
92
+ "subcircuit_id": "subcircuit_source_group_0",
93
+ "subcircuit_connectivity_map_key": "unnamedsubcircuit303_connectivity_net2"
94
+ },
95
+ {
96
+ "type": "source_component",
97
+ "source_component_id": "source_component_2",
98
+ "ftype": "simple_resistor",
99
+ "name": "R2",
100
+ "resistance": 10000,
101
+ "display_resistance": "10kΩ",
102
+ "are_pins_interchangeable": true,
103
+ "source_group_id": "source_group_0"
104
+ },
105
+ {
106
+ "type": "source_board",
107
+ "source_board_id": "source_board_0",
108
+ "source_group_id": "source_group_0"
109
+ },
110
+ {
111
+ "type": "source_trace",
112
+ "source_trace_id": "source_trace_0",
113
+ "connected_source_port_ids": ["source_port_0", "source_port_2"],
114
+ "connected_source_net_ids": [],
115
+ "subcircuit_id": "subcircuit_source_group_0",
116
+ "display_name": ".VS1 > .pin1 to .R1 > .pin1",
117
+ "subcircuit_connectivity_map_key": "unnamedsubcircuit303_connectivity_net0"
118
+ },
119
+ {
120
+ "type": "source_trace",
121
+ "source_trace_id": "source_trace_1",
122
+ "connected_source_port_ids": ["source_port_3", "source_port_4"],
123
+ "connected_source_net_ids": [],
124
+ "subcircuit_id": "subcircuit_source_group_0",
125
+ "display_name": ".R1 > .pin2 to .R2 > .pin1",
126
+ "subcircuit_connectivity_map_key": "unnamedsubcircuit303_connectivity_net1"
127
+ },
128
+ {
129
+ "type": "source_trace",
130
+ "source_trace_id": "source_trace_2",
131
+ "connected_source_port_ids": ["source_port_1", "source_port_5"],
132
+ "connected_source_net_ids": [],
133
+ "subcircuit_id": "subcircuit_source_group_0",
134
+ "display_name": ".VS1 > .pin2 to .R2 > .pin2",
135
+ "subcircuit_connectivity_map_key": "unnamedsubcircuit303_connectivity_net2"
136
+ },
137
+ {
138
+ "type": "simulation_voltage_source",
139
+ "simulation_voltage_source_id": "simulation_voltage_source_0",
140
+ "is_dc_source": true,
141
+ "terminal1_source_port_id": "source_port_0",
142
+ "terminal2_source_port_id": "source_port_1",
143
+ "voltage": 5
144
+ },
145
+ {
146
+ "type": "schematic_component",
147
+ "schematic_component_id": "schematic_component_0",
148
+ "center": {
149
+ "x": 0,
150
+ "y": 0
151
+ },
152
+ "size": {
153
+ "width": 1.08,
154
+ "height": 0.818910699999999
155
+ },
156
+ "source_component_id": "source_component_0",
157
+ "is_box_with_pins": true,
158
+ "symbol_name": "ac_voltmeter_right",
159
+ "schematic_group_id": "schematic_group_0"
160
+ },
161
+ {
162
+ "type": "schematic_component",
163
+ "schematic_component_id": "schematic_component_1",
164
+ "center": {
165
+ "x": 0,
166
+ "y": -2
167
+ },
168
+ "size": {
169
+ "width": 1.1,
170
+ "height": 0.388910699999999
171
+ },
172
+ "source_component_id": "source_component_1",
173
+ "is_box_with_pins": true,
174
+ "symbol_name": "boxresistor_right",
175
+ "symbol_display_value": "10kΩ",
176
+ "schematic_group_id": "schematic_group_0"
177
+ },
178
+ {
179
+ "type": "schematic_component",
180
+ "schematic_component_id": "schematic_component_2",
181
+ "center": {
182
+ "x": 0,
183
+ "y": 2
184
+ },
185
+ "size": {
186
+ "width": 1.1,
187
+ "height": 0.388910699999999
188
+ },
189
+ "source_component_id": "source_component_2",
190
+ "is_box_with_pins": true,
191
+ "symbol_name": "boxresistor_right",
192
+ "symbol_display_value": "10kΩ",
193
+ "schematic_group_id": "schematic_group_0"
194
+ },
195
+ {
196
+ "type": "schematic_group",
197
+ "schematic_group_id": "schematic_group_0",
198
+ "is_subcircuit": true,
199
+ "subcircuit_id": "subcircuit_source_group_0",
200
+ "name": "unnamed_board1",
201
+ "center": {
202
+ "x": 0,
203
+ "y": 0
204
+ },
205
+ "width": 0,
206
+ "height": 0,
207
+ "schematic_component_ids": [],
208
+ "source_group_id": "source_group_0"
209
+ },
210
+ {
211
+ "type": "schematic_port",
212
+ "schematic_port_id": "schematic_port_0",
213
+ "schematic_component_id": "schematic_component_0",
214
+ "center": {
215
+ "x": -0.54,
216
+ "y": -0.0050000000000000044
217
+ },
218
+ "source_port_id": "source_port_0",
219
+ "facing_direction": "left",
220
+ "distance_from_component_edge": 0.4,
221
+ "pin_number": 1,
222
+ "display_pin_label": "terminal1",
223
+ "is_connected": true
224
+ },
225
+ {
226
+ "type": "schematic_port",
227
+ "schematic_port_id": "schematic_port_1",
228
+ "schematic_component_id": "schematic_component_0",
229
+ "center": {
230
+ "x": 0.54,
231
+ "y": 0.0049999999999999975
232
+ },
233
+ "source_port_id": "source_port_1",
234
+ "facing_direction": "right",
235
+ "distance_from_component_edge": 0.4,
236
+ "pin_number": 2,
237
+ "display_pin_label": "terminal2",
238
+ "is_connected": true
239
+ },
240
+ {
241
+ "type": "schematic_port",
242
+ "schematic_port_id": "schematic_port_2",
243
+ "schematic_component_id": "schematic_component_1",
244
+ "center": {
245
+ "x": -0.55,
246
+ "y": -1.9999999999999998
247
+ },
248
+ "source_port_id": "source_port_2",
249
+ "facing_direction": "left",
250
+ "distance_from_component_edge": 0.4,
251
+ "pin_number": 1,
252
+ "display_pin_label": "anode",
253
+ "is_connected": true
254
+ },
255
+ {
256
+ "type": "schematic_port",
257
+ "schematic_port_id": "schematic_port_3",
258
+ "schematic_component_id": "schematic_component_1",
259
+ "center": {
260
+ "x": 0.55,
261
+ "y": -1.9999999999999998
262
+ },
263
+ "source_port_id": "source_port_3",
264
+ "facing_direction": "right",
265
+ "distance_from_component_edge": 0.4,
266
+ "pin_number": 2,
267
+ "display_pin_label": "cathode",
268
+ "is_connected": false
269
+ },
270
+ {
271
+ "type": "schematic_port",
272
+ "schematic_port_id": "schematic_port_4",
273
+ "schematic_component_id": "schematic_component_2",
274
+ "center": {
275
+ "x": -0.55,
276
+ "y": 2
277
+ },
278
+ "source_port_id": "source_port_4",
279
+ "facing_direction": "left",
280
+ "distance_from_component_edge": 0.4,
281
+ "pin_number": 1,
282
+ "display_pin_label": "anode",
283
+ "is_connected": false
284
+ },
285
+ {
286
+ "type": "schematic_port",
287
+ "schematic_port_id": "schematic_port_5",
288
+ "schematic_component_id": "schematic_component_2",
289
+ "center": {
290
+ "x": 0.55,
291
+ "y": 2
292
+ },
293
+ "source_port_id": "source_port_5",
294
+ "facing_direction": "right",
295
+ "distance_from_component_edge": 0.4,
296
+ "pin_number": 2,
297
+ "display_pin_label": "cathode",
298
+ "is_connected": true
299
+ },
300
+ {
301
+ "type": "schematic_trace",
302
+ "schematic_trace_id": "schematic_trace_0",
303
+ "source_trace_id": "solver_VS1.1-R1.1",
304
+ "edges": [
305
+ {
306
+ "from": {
307
+ "x": -0.54,
308
+ "y": -0.0050000000000000044
309
+ },
310
+ "to": {
311
+ "x": -0.75,
312
+ "y": -0.0050000000000000044
313
+ }
314
+ },
315
+ {
316
+ "from": {
317
+ "x": -0.75,
318
+ "y": -0.0050000000000000044
319
+ },
320
+ "to": {
321
+ "x": -0.75,
322
+ "y": -1.9999999999999998
323
+ }
324
+ },
325
+ {
326
+ "from": {
327
+ "x": -0.75,
328
+ "y": -1.9999999999999998
329
+ },
330
+ "to": {
331
+ "x": -0.55,
332
+ "y": -1.9999999999999998
333
+ }
334
+ }
335
+ ],
336
+ "junctions": [],
337
+ "subcircuit_connectivity_map_key": "unnamedsubcircuit303_connectivity_net0"
338
+ },
339
+ {
340
+ "type": "schematic_trace",
341
+ "schematic_trace_id": "schematic_trace_1",
342
+ "source_trace_id": "solver_VS1.2-R2.2",
343
+ "edges": [
344
+ {
345
+ "from": {
346
+ "x": 0.54,
347
+ "y": 0.0049999999999999975
348
+ },
349
+ "to": {
350
+ "x": 0.75,
351
+ "y": 0.0049999999999999975
352
+ }
353
+ },
354
+ {
355
+ "from": {
356
+ "x": 0.75,
357
+ "y": 0.0049999999999999975
358
+ },
359
+ "to": {
360
+ "x": 0.75,
361
+ "y": 2
362
+ }
363
+ },
364
+ {
365
+ "from": {
366
+ "x": 0.75,
367
+ "y": 2
368
+ },
369
+ "to": {
370
+ "x": 0.55,
371
+ "y": 2
372
+ }
373
+ }
374
+ ],
375
+ "junctions": [],
376
+ "subcircuit_connectivity_map_key": "unnamedsubcircuit303_connectivity_net2"
377
+ },
378
+ {
379
+ "type": "schematic_net_label",
380
+ "schematic_net_label_id": "schematic_net_label_0",
381
+ "text": "R1_pin2/R2_pin1",
382
+ "anchor_position": {
383
+ "x": 0.55,
384
+ "y": -1.9999999999999998
385
+ },
386
+ "center": {
387
+ "x": 1.3,
388
+ "y": -1.9999999999999998
389
+ },
390
+ "anchor_side": "left"
391
+ },
392
+ {
393
+ "type": "schematic_net_label",
394
+ "schematic_net_label_id": "schematic_net_label_1",
395
+ "text": "R1_pin2/R2_pin1",
396
+ "anchor_position": {
397
+ "x": -0.55,
398
+ "y": 2
399
+ },
400
+ "center": {
401
+ "x": -1.3,
402
+ "y": 2
403
+ },
404
+ "anchor_side": "right"
405
+ },
406
+ {
407
+ "type": "pcb_component",
408
+ "pcb_component_id": "pcb_component_0",
409
+ "center": {
410
+ "x": 0,
411
+ "y": -2
412
+ },
413
+ "width": 0,
414
+ "height": 0,
415
+ "layer": "top",
416
+ "rotation": 0,
417
+ "source_component_id": "source_component_1",
418
+ "subcircuit_id": "subcircuit_source_group_0",
419
+ "do_not_place": false,
420
+ "obstructs_within_bounds": true
421
+ },
422
+ {
423
+ "type": "pcb_missing_footprint_error",
424
+ "pcb_missing_footprint_error_id": "pcb_missing_footprint_error_0",
425
+ "message": "No footprint found for component: <resistor#294 name=\".R1\" />",
426
+ "source_component_id": "source_component_1",
427
+ "error_type": "pcb_missing_footprint_error"
428
+ },
429
+ {
430
+ "type": "pcb_component",
431
+ "pcb_component_id": "pcb_component_1",
432
+ "center": {
433
+ "x": 0,
434
+ "y": 2
435
+ },
436
+ "width": 0,
437
+ "height": 0,
438
+ "layer": "top",
439
+ "rotation": 0,
440
+ "source_component_id": "source_component_2",
441
+ "subcircuit_id": "subcircuit_source_group_0",
442
+ "do_not_place": false,
443
+ "obstructs_within_bounds": true
444
+ },
445
+ {
446
+ "type": "pcb_missing_footprint_error",
447
+ "pcb_missing_footprint_error_id": "pcb_missing_footprint_error_1",
448
+ "message": "No footprint found for component: <resistor#297 name=\".R2\" />",
449
+ "source_component_id": "source_component_2",
450
+ "error_type": "pcb_missing_footprint_error"
451
+ },
452
+ {
453
+ "type": "pcb_board",
454
+ "pcb_board_id": "pcb_board_0",
455
+ "center": {
456
+ "x": 0,
457
+ "y": 0
458
+ },
459
+ "thickness": 1.4,
460
+ "num_layers": 2,
461
+ "width": 10,
462
+ "height": 10,
463
+ "material": "fr4"
464
+ },
465
+ {
466
+ "type": "pcb_autorouting_error",
467
+ "pcb_autorouting_error_id": "pcb_autorouting_error_0",
468
+ "pcb_error_id": "pcb_autorouter_error_subcircuit_subcircuit_source_group_0",
469
+ "error_type": "pcb_autorouting_error",
470
+ "message": "En ran out of iterations (capacity-autorouter@0.0.140)"
471
+ }
472
+ ]
@@ -0,0 +1,17 @@
1
+ import { expect, test } from "bun:test"
2
+ import { circuitJsonToSpice } from "lib/circuitJsonToSpice"
3
+ import dcVoltageSource from "./assets/dc-voltage-source-terminals.json"
4
+
5
+ // A DC voltage source that uses terminal1_source_port_id/terminal2_source_port_id
6
+ // (instead of positive/negative) is silently dropped, so no V line is emitted.
7
+ test.failing("DC voltage source using terminal1/terminal2", () => {
8
+ const spiceString = circuitJsonToSpice(dcVoltageSource as any).toSpiceString()
9
+
10
+ expect(spiceString).toMatchInlineSnapshot(`
11
+ "* Circuit JSON to SPICE Netlist
12
+ RR1 N1 N2 10K
13
+ RR2 N2 0 10K
14
+ Vsimulation_voltage_source_0 N1 0 DC 5
15
+ .END"
16
+ `)
17
+ })