I am trying to come up with a generic Python program that I can use to simulate different simple electronic circuits. The actual idea is to programmaticaly change parameters and do Montecarlo analyses.
First, I was using the PyLTSpice API but this is mainly to run an LTspice file using LTspice. I do not want to do this. I would like to work with a SPICE netlist so that we are free to do our design in whichever program we prefer.
Below you can find a netlist of a design I am currently working on:
"ExpressPCB Netlist"
"LTspice XVII"
1
0
0
""
""
""
"Part IDs Table"
"D1" "D" ""
"D2" "D" ""
"D3" "D" ""
"L1" "9µ" ""
"C1" "140µ" ""
"R1" "100m" ""
"L2" "12µ" ""
"S2" "S1" ""
"R3" "1k" ""
"V3" "PULSE(0 2 0 35u 35u 100u)" ""
"D4" "D" ""
"C2" "105µ" ""
"Net Names Table"
"N001" 1
"N003" 6
"N005" 9
"N007" 12
"0" 14
"N006" 20
"N004" 22
"N002" 24
"Net Connections Table"
1 1 1 2
1 2 2 3
1 3 1 4
1 6 1 5
1 8 2 0
2 1 2 7
2 2 1 8
2 4 1 0
3 3 2 10
3 11 1 11
3 12 1 0
4 4 2 13
4 5 1 0
5 5 2 15
5 7 2 16
5 8 4 17
5 9 2 18
5 10 2 19
5 12 2 0
6 6 2 21
6 7 1 0
7 8 1 23
7 11 2 0
8 8 3 25
8 9 1 26
8 10 1 0
Here, for instance, I would like to change the values of certain parameters and simulate this circuit, hence the netlist. How could I achieve this? Could you point me to some documentation?
Also, the netlist I have attached above is obtained when I "export" the netlist. When I "view" it, I have the following (which has the switch model etc., so I don't understand why the other one doesn't have that):
D1 N001 N003 D
D2 N003 N001 D
D3 N001 N005 D
L1 N003 N007 9µ
C1 N007 0 140µ IC=9k
R1 N001 N006 100m
L2 N006 0 12µ
S2 N004 N001 N002 0 S1
R3 N002 0 1k
V3 N002 0 PULSE(0 2 0 35u 35u 100u)
D4 N005 N004 D
C2 N005 0 105µ IC=9k
.model D D
.lib C:\Users\<user_name>\<some_dir>\LTspiceXVII\lib\cmp\standard.dio
.tran 0 {transtop} 0 {timestep} startup
.model S1 SW(Ron=1 Roff=1Meg Vt=.5 Vh=-.4)
.include trancmd.txt
.include param.txt
.backanno
.end