circuit-json-to-spice 0.0.24 → 0.0.25

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.24",
4
+ "version": "0.0.25",
5
5
  "type": "module",
6
6
  "scripts": {
7
7
  "build": "tsup-node ./lib/index.ts --dts --format esm --sourcemap inline -d dist",
@@ -1,30 +1,11 @@
1
1
  import { test, expect } from "bun:test"
2
- import { getTestFixture } from "tests/fixtures/getTestFixture"
3
2
  import { circuitJsonToSpice } from "lib/circuitJsonToSpice"
3
+ import acVoltageSource from "./assets/AC-voltage-source.json"
4
4
 
5
5
  test(
6
6
  "AC voltage source",
7
7
  async () => {
8
- const { circuit } = await getTestFixture()
9
-
10
- circuit.add(
11
- <board width="10mm" height="10mm">
12
- <voltagesource
13
- name="VS1"
14
- voltage="5V"
15
- frequency="60Hz"
16
- waveShape="sinewave"
17
- />
18
- <resistor name="R1" resistance="10k" pcbY={-2} schY={-2} />
19
- <resistor name="R2" resistance="10k" pcbY={2} schY={2} />
20
- <trace from={".VS1 > .pin1"} to={".R1 > .pin1"} />
21
- <trace from={".R1 > .pin2"} to={".R2 > .pin1"} />
22
- <trace from={".VS1 > .pin2"} to={".R2 > .pin2"} />
23
- </board>,
24
- )
25
-
26
- await circuit.renderUntilSettled()
27
- const circuitJson = circuit.getCircuitJson()
8
+ const circuitJson = acVoltageSource as any
28
9
 
29
10
  const spiceNetlist = circuitJsonToSpice(circuitJson)
30
11
  const spiceString = spiceNetlist.toSpiceString()
@@ -0,0 +1,474 @@
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": false,
141
+ "terminal1_source_port_id": "source_port_0",
142
+ "terminal2_source_port_id": "source_port_1",
143
+ "voltage": 5,
144
+ "frequency": 60,
145
+ "wave_shape": "sinewave"
146
+ },
147
+ {
148
+ "type": "schematic_component",
149
+ "schematic_component_id": "schematic_component_0",
150
+ "center": {
151
+ "x": 0,
152
+ "y": 0
153
+ },
154
+ "size": {
155
+ "width": 1.08,
156
+ "height": 0.818910699999999
157
+ },
158
+ "source_component_id": "source_component_0",
159
+ "is_box_with_pins": true,
160
+ "symbol_name": "ac_voltmeter_right",
161
+ "schematic_group_id": "schematic_group_0"
162
+ },
163
+ {
164
+ "type": "schematic_component",
165
+ "schematic_component_id": "schematic_component_1",
166
+ "center": {
167
+ "x": 0,
168
+ "y": -2
169
+ },
170
+ "size": {
171
+ "width": 1.1,
172
+ "height": 0.388910699999999
173
+ },
174
+ "source_component_id": "source_component_1",
175
+ "is_box_with_pins": true,
176
+ "symbol_name": "boxresistor_right",
177
+ "symbol_display_value": "10kΩ",
178
+ "schematic_group_id": "schematic_group_0"
179
+ },
180
+ {
181
+ "type": "schematic_component",
182
+ "schematic_component_id": "schematic_component_2",
183
+ "center": {
184
+ "x": 0,
185
+ "y": 2
186
+ },
187
+ "size": {
188
+ "width": 1.1,
189
+ "height": 0.388910699999999
190
+ },
191
+ "source_component_id": "source_component_2",
192
+ "is_box_with_pins": true,
193
+ "symbol_name": "boxresistor_right",
194
+ "symbol_display_value": "10kΩ",
195
+ "schematic_group_id": "schematic_group_0"
196
+ },
197
+ {
198
+ "type": "schematic_group",
199
+ "schematic_group_id": "schematic_group_0",
200
+ "is_subcircuit": true,
201
+ "subcircuit_id": "subcircuit_source_group_0",
202
+ "name": "unnamed_board1",
203
+ "center": {
204
+ "x": 0,
205
+ "y": 0
206
+ },
207
+ "width": 0,
208
+ "height": 0,
209
+ "schematic_component_ids": [],
210
+ "source_group_id": "source_group_0"
211
+ },
212
+ {
213
+ "type": "schematic_port",
214
+ "schematic_port_id": "schematic_port_0",
215
+ "schematic_component_id": "schematic_component_0",
216
+ "center": {
217
+ "x": -0.54,
218
+ "y": -0.0050000000000000044
219
+ },
220
+ "source_port_id": "source_port_0",
221
+ "facing_direction": "left",
222
+ "distance_from_component_edge": 0.4,
223
+ "pin_number": 1,
224
+ "display_pin_label": "terminal1",
225
+ "is_connected": true
226
+ },
227
+ {
228
+ "type": "schematic_port",
229
+ "schematic_port_id": "schematic_port_1",
230
+ "schematic_component_id": "schematic_component_0",
231
+ "center": {
232
+ "x": 0.54,
233
+ "y": 0.0049999999999999975
234
+ },
235
+ "source_port_id": "source_port_1",
236
+ "facing_direction": "right",
237
+ "distance_from_component_edge": 0.4,
238
+ "pin_number": 2,
239
+ "display_pin_label": "terminal2",
240
+ "is_connected": true
241
+ },
242
+ {
243
+ "type": "schematic_port",
244
+ "schematic_port_id": "schematic_port_2",
245
+ "schematic_component_id": "schematic_component_1",
246
+ "center": {
247
+ "x": -0.55,
248
+ "y": -1.9999999999999998
249
+ },
250
+ "source_port_id": "source_port_2",
251
+ "facing_direction": "left",
252
+ "distance_from_component_edge": 0.4,
253
+ "pin_number": 1,
254
+ "display_pin_label": "anode",
255
+ "is_connected": true
256
+ },
257
+ {
258
+ "type": "schematic_port",
259
+ "schematic_port_id": "schematic_port_3",
260
+ "schematic_component_id": "schematic_component_1",
261
+ "center": {
262
+ "x": 0.55,
263
+ "y": -1.9999999999999998
264
+ },
265
+ "source_port_id": "source_port_3",
266
+ "facing_direction": "right",
267
+ "distance_from_component_edge": 0.4,
268
+ "pin_number": 2,
269
+ "display_pin_label": "cathode",
270
+ "is_connected": false
271
+ },
272
+ {
273
+ "type": "schematic_port",
274
+ "schematic_port_id": "schematic_port_4",
275
+ "schematic_component_id": "schematic_component_2",
276
+ "center": {
277
+ "x": -0.55,
278
+ "y": 2
279
+ },
280
+ "source_port_id": "source_port_4",
281
+ "facing_direction": "left",
282
+ "distance_from_component_edge": 0.4,
283
+ "pin_number": 1,
284
+ "display_pin_label": "anode",
285
+ "is_connected": false
286
+ },
287
+ {
288
+ "type": "schematic_port",
289
+ "schematic_port_id": "schematic_port_5",
290
+ "schematic_component_id": "schematic_component_2",
291
+ "center": {
292
+ "x": 0.55,
293
+ "y": 2
294
+ },
295
+ "source_port_id": "source_port_5",
296
+ "facing_direction": "right",
297
+ "distance_from_component_edge": 0.4,
298
+ "pin_number": 2,
299
+ "display_pin_label": "cathode",
300
+ "is_connected": true
301
+ },
302
+ {
303
+ "type": "schematic_trace",
304
+ "schematic_trace_id": "schematic_trace_0",
305
+ "source_trace_id": "solver_VS1.1-R1.1",
306
+ "edges": [
307
+ {
308
+ "from": {
309
+ "x": -0.54,
310
+ "y": -0.0050000000000000044
311
+ },
312
+ "to": {
313
+ "x": -0.75,
314
+ "y": -0.0050000000000000044
315
+ }
316
+ },
317
+ {
318
+ "from": {
319
+ "x": -0.75,
320
+ "y": -0.0050000000000000044
321
+ },
322
+ "to": {
323
+ "x": -0.75,
324
+ "y": -1.9999999999999998
325
+ }
326
+ },
327
+ {
328
+ "from": {
329
+ "x": -0.75,
330
+ "y": -1.9999999999999998
331
+ },
332
+ "to": {
333
+ "x": -0.55,
334
+ "y": -1.9999999999999998
335
+ }
336
+ }
337
+ ],
338
+ "junctions": [],
339
+ "subcircuit_connectivity_map_key": "unnamedsubcircuit303_connectivity_net0"
340
+ },
341
+ {
342
+ "type": "schematic_trace",
343
+ "schematic_trace_id": "schematic_trace_1",
344
+ "source_trace_id": "solver_VS1.2-R2.2",
345
+ "edges": [
346
+ {
347
+ "from": {
348
+ "x": 0.54,
349
+ "y": 0.0049999999999999975
350
+ },
351
+ "to": {
352
+ "x": 0.75,
353
+ "y": 0.0049999999999999975
354
+ }
355
+ },
356
+ {
357
+ "from": {
358
+ "x": 0.75,
359
+ "y": 0.0049999999999999975
360
+ },
361
+ "to": {
362
+ "x": 0.75,
363
+ "y": 2
364
+ }
365
+ },
366
+ {
367
+ "from": {
368
+ "x": 0.75,
369
+ "y": 2
370
+ },
371
+ "to": {
372
+ "x": 0.55,
373
+ "y": 2
374
+ }
375
+ }
376
+ ],
377
+ "junctions": [],
378
+ "subcircuit_connectivity_map_key": "unnamedsubcircuit303_connectivity_net2"
379
+ },
380
+ {
381
+ "type": "schematic_net_label",
382
+ "schematic_net_label_id": "schematic_net_label_0",
383
+ "text": "R1_pin2/R2_pin1",
384
+ "anchor_position": {
385
+ "x": 0.55,
386
+ "y": -1.9999999999999998
387
+ },
388
+ "center": {
389
+ "x": 1.3,
390
+ "y": -1.9999999999999998
391
+ },
392
+ "anchor_side": "left"
393
+ },
394
+ {
395
+ "type": "schematic_net_label",
396
+ "schematic_net_label_id": "schematic_net_label_1",
397
+ "text": "R1_pin2/R2_pin1",
398
+ "anchor_position": {
399
+ "x": -0.55,
400
+ "y": 2
401
+ },
402
+ "center": {
403
+ "x": -1.3,
404
+ "y": 2
405
+ },
406
+ "anchor_side": "right"
407
+ },
408
+ {
409
+ "type": "pcb_component",
410
+ "pcb_component_id": "pcb_component_0",
411
+ "center": {
412
+ "x": 0,
413
+ "y": -2
414
+ },
415
+ "width": 0,
416
+ "height": 0,
417
+ "layer": "top",
418
+ "rotation": 0,
419
+ "source_component_id": "source_component_1",
420
+ "subcircuit_id": "subcircuit_source_group_0",
421
+ "do_not_place": false,
422
+ "obstructs_within_bounds": true
423
+ },
424
+ {
425
+ "type": "pcb_missing_footprint_error",
426
+ "pcb_missing_footprint_error_id": "pcb_missing_footprint_error_0",
427
+ "message": "No footprint found for component: <resistor#294 name=\".R1\" />",
428
+ "source_component_id": "source_component_1",
429
+ "error_type": "pcb_missing_footprint_error"
430
+ },
431
+ {
432
+ "type": "pcb_component",
433
+ "pcb_component_id": "pcb_component_1",
434
+ "center": {
435
+ "x": 0,
436
+ "y": 2
437
+ },
438
+ "width": 0,
439
+ "height": 0,
440
+ "layer": "top",
441
+ "rotation": 0,
442
+ "source_component_id": "source_component_2",
443
+ "subcircuit_id": "subcircuit_source_group_0",
444
+ "do_not_place": false,
445
+ "obstructs_within_bounds": true
446
+ },
447
+ {
448
+ "type": "pcb_missing_footprint_error",
449
+ "pcb_missing_footprint_error_id": "pcb_missing_footprint_error_1",
450
+ "message": "No footprint found for component: <resistor#297 name=\".R2\" />",
451
+ "source_component_id": "source_component_2",
452
+ "error_type": "pcb_missing_footprint_error"
453
+ },
454
+ {
455
+ "type": "pcb_board",
456
+ "pcb_board_id": "pcb_board_0",
457
+ "center": {
458
+ "x": 0,
459
+ "y": 0
460
+ },
461
+ "thickness": 1.4,
462
+ "num_layers": 2,
463
+ "width": 10,
464
+ "height": 10,
465
+ "material": "fr4"
466
+ },
467
+ {
468
+ "type": "pcb_autorouting_error",
469
+ "pcb_autorouting_error_id": "pcb_autorouting_error_0",
470
+ "pcb_error_id": "pcb_autorouter_error_subcircuit_subcircuit_source_group_0",
471
+ "error_type": "pcb_autorouting_error",
472
+ "message": "En ran out of iterations (capacity-autorouter@0.0.140)"
473
+ }
474
+ ]