I am running an operating point simulation in ngspice and I get DC currents through capacitors.
The netlist I am using is programmatically generated. Some components from a circuit were deleted which results in dangling components/nets that do not form a closed circuit.
I am using the following netlist:
.title test_netlist
C1 GND /AFE/SRP 100n
C2 GND /AFE/SRN 100n
C3 /AFE/SRN /AFE/SRP 100n
C4 /AFE/Vbat_filtered GND 2.2u
C6 /AFE/REGOUT GND 4.7u
C9 GND /AFE/VC0 1u
R1 /AFE/SRP_Conn /AFE/SRP 100
R10 Net-_E2-Pad2_ Net-_D14-Pad1_ 100
R11 GND Net-_D13-Pad1_ 1Meg
R12 GND Net-_D14-Pad1_ 1Meg
R13 Net-_D13-Pad1_ /Gauge/SMBD 100
R14 Net-_D14-Pad1_ /Gauge/SMBC 100
R15 GND /AFE/AFE_Inputs/tmp 900
R16 /AFE/AFE_Inputs/tmp /AFE/VC0 100
R2 /AFE/SRN_Conn /AFE/SRN 100
R3 +BATT Net-_D12-Pad1_ 10k
R4 Net-_D12-Pad1_ /AFE/Vbat_filtered 100
R5 /AFE/REGOUT /AFE/SDA 10k
R6 /AFE/REGOUT /AFE/SCL 10k
R9 Net-_E1-Pad2_ Net-_D13-Pad1_ 100
Rshunt1 /AFE/SRN_Conn /AFE/SRP_Conn 0.25m
V1 +BATT /AFE/V3 dc({Vcell})
V2 /AFE/V3 /AFE/V2 dc({Vcell})
V3 /AFE/V2 /AFE/V1 dc({Vcell})
V4 /AFE/V1 GND dc({Vcell})
.param Rs1 = 900
.param Rs2 = 100
.param Rs3 = 1
.param Vcell=3.2
.options savecurrents
.op
.end
Running this in ngspice gives:
Note: can't find the initialization file spinit.
******
** ngspice-38 : Circuit level simulation program
** The U. C. Berkeley CAD Group
** Copyright 1985-1994, Regents of the University of California.
** Copyright 2001-2022, The ngspice team.
** Please get your ngspice manual from http://ngspice.sourceforge.net/docs.html
** Please file your bug-reports at http://ngspice.sourceforge.net/bugrep.html
** Creation Date: Oct 29 2022 15:21:43
******
ngspice 1 -> source test.cir
Note: No compatibility mode selected!
Circuit: test_netlist
ngspice 2 -> run
Doing analysis at TEMP = 27.000000 and TNOM = 27.000000
Warning: singular matrix: check nodes /afe/regout and /afe/regout
Note: Starting dynamic gmin stepping
Trying gmin = 1.0000E-03 Note: One successful gmin step
Trying gmin = 1.0000E-04 Note: One successful gmin step
Trying gmin = 1.0000E-05 Note: One successful gmin step
Trying gmin = 1.0000E-06 Note: One successful gmin step
Trying gmin = 1.0000E-07 Note: One successful gmin step
Trying gmin = 1.0000E-08 Note: One successful gmin step
Trying gmin = 1.0000E-09 Note: One successful gmin step
Trying gmin = 1.0000E-10 Note: One successful gmin step
Trying gmin = 1.0000E-11 Note: One successful gmin step
Trying gmin = 1.0000E-12 Note: One successful gmin step
Trying gmin = 1.0000E-12 Note: One successful gmin step
Warning: singular matrix: check nodes /afe/regout and /afe/regout
Warning: Dynamic gmin stepping failed
Note: Starting true gmin stepping
Trying gmin = 1.0000E-03 Warning: singular matrix: check nodes /afe/regout and /afe/regout
Warning: Further gmin increment
Trying gmin = 5.6234E-03 Warning: singular matrix: check nodes /afe/regout and /afe/regout
Warning: Further gmin increment
Trying gmin = 8.6596E-03 Warning: singular matrix: check nodes /afe/regout and /afe/regout
Warning: Further gmin increment
Trying gmin = 9.6466E-03 Warning: singular matrix: check nodes /afe/regout and /afe/regout
Warning: Further gmin increment
Trying gmin = 9.9105E-03 Warning: Further gmin increment
Trying gmin = 9.9775E-03 Warning: Further gmin increment
Trying gmin = 9.9944E-03 Warning: Further gmin increment
Trying gmin = 9.9986E-03 Warning: Further gmin increment
Trying gmin = 9.9996E-03 Warning: Last gmin step failed
Warning: True gmin stepping failed
Note: Starting source stepping
Supplies reduced to 0.0000%
Trying gmin = 1.0000E-02 Note: One successful gmin step
Trying gmin = 1.0000E-03 Note: One successful gmin step
Trying gmin = 1.0000E-04 Note: One successful gmin step
Trying gmin = 1.0000E-05 Note: One successful gmin step
Trying gmin = 1.0000E-06 Note: One successful gmin step
Trying gmin = 1.0000E-07 Note: One successful gmin step
Trying gmin = 1.0000E-08 Note: One successful gmin step
Trying gmin = 1.0000E-09 Note: One successful gmin step
Trying gmin = 1.0000E-10 Note: One successful gmin step
Trying gmin = 1.0000E-11 Note: One successful gmin step
Trying gmin = 1.0000E-12 Note: One successful gmin step
Note: One successful source step
Supplies reduced to 0.1000% Supplies reduced to 0.0000% Warning: source stepping failed
Note: Transient op started
Note: Transient op finished successfully
No. of Data Rows : 1
ngspice 3 -> print all
+batt = 1.280000e+01
/afe/afe_inputs/tmp = 0.000000e+00
/afe/regout = 0.000000e+00
/afe/scl = 0.000000e+00
/afe/sda = 0.000000e+00
/afe/srn = 0.000000e+00
/afe/srn_conn = 0.000000e+00
/afe/srp = 0.000000e+00
/afe/srp_conn = 0.000000e+00
/afe/v1 = 3.200000e+00
/afe/v2 = 6.400000e+00
/afe/v3 = 9.600000e+00
/afe/vbat_filtered = 5.759280e-03
/afe/vc0 = 0.000000e+00
/gauge/smbc = 0.000000e+00
/gauge/smbd = 0.000000e+00
@c1[i] = 0.000000e+00
@c2[i] = 0.000000e+00
@c3[i] = 0.000000e+00
@c4[i] = 1.266757e-03
@c6[i] = 0.000000e+00
@c9[i] = 0.000000e+00
@r1[i] = 0.000000e+00
@r2[i] = 0.000000e+00
@r3[i] = 1.266757e-03
@r4[i] = 1.266757e-03
@r5[i] = 0.000000e+00
@r6[i] = 0.000000e+00
@r9[i] = 0.000000e+00
@r10[i] = 0.000000e+00
@r11[i] = 0.000000e+00
@r12[i] = 0.000000e+00
@r13[i] = 0.000000e+00
@r14[i] = 0.000000e+00
@r15[i] = 0.000000e+00
@r16[i] = 0.000000e+00
@rshunt1[i] = 0.000000e+00
net-_d12-pad1_ = 1.324349e-01
net-_d13-pad1_ = 0.000000e+00
net-_d14-pad1_ = 0.000000e+00
net-_e1-pad2_ = 0.000000e+00
net-_e2-pad2_ = 0.000000e+00
v1#branch = -1.26676e-03
v2#branch = -1.26676e-03
v3#branch = -1.26676e-03
v4#branch = -1.26676e-03
ngspice 4 ->
There should not be any current flowing. There are no closed paths across the voltage sources. Still I get about 1.2 mA in my simulation.
I am trying determine the operating point of the dangling nets to check what voltages the deleted components might see. (Note: I am aware that this is a pointless exercise with the netlist provided. This is a heavily stripped down netlist to make it manageable to analyse it manually.)
For example: There is a dangling net that goes as follows: V1 --- R3 --- R4 --- net:/AFE/Vbat_filtered
So obviously /AFE/Vbat_filtered should be at 12.8 instead of 5.759280e-03.
How do I make this work? Is inserting very large resistors to ground at all dangling nets the only solution? I really wanted to avoid the additional work.
Also: I remember that there was an option to automatically insert very large resistances between all nets and ground, but I can't find it any longer.
Edit 1 In case anybody else encounters this problem:
I narrowed the issue down to the following failing netlist:
.title test_netlist
V1 +BATT GND dc(12.8)
R3 +BATT Net-_D12-Pad1_ 10k
R4 Net-_D12-Pad1_ /AFE/Vbat_filtered 100
C4 /AFE/Vbat_filtered GND 2.2u
C6 /AFE/REGOUT GND 4.7u
R5 /AFE/REGOUT /AFE/SDA 10k
R6 /AFE/REGOUT /AFE/SCL 10k
.options savecurrents
.op
.end
The issue seems to be the existence of the components R5, R6, and C6, which have no connection to any source.
So removing all components that have no path to a source other than through ground might solve this issue.
.options rshunt=1t
. That adds a 1 terraohm resistor to ground at every node. You can of course change the value to whatever you want. Check Section 15.1.2.1 of the ngspice manual for more info. \$\endgroup\$