For circuit simulations I have mostly been using LTpice, where the netlist is generated automatically with a Python script I wrote and run using the following Python command:
subprocess.run([ltspice_executable, -b, my_netlist])
(1).
The voltages of my circuit are extracted by reading the generated raw files using the Python package: ltspice.
Now I have to move to Ngspice (@Related question with no answers here). My LTspice netlist only contains resistors inductors and capacitors so it could basically run in Ngspice with no problem whatsoever.
I would like to know if there is a similar Python command to the one I use in LTspice (expression(1)) to run Ngspice from my Python script and extract my voltages?
1 Answer 1
Following @aconcernedcitizen's comment, the command to be used in order to run Ngspice
in batch mode from python
is the following:
subprocess.run([path_to_ngspice_executable,'-r','rawfile.raw','-b','-i',my_netlist])
.
Where rawfile.raw here will contain all the voltages distributions and is supposed to be read to extract the voltage distribution. For LTspice
the ltspice
python package see here, whereas for Ngspice
raw files I am still trying to figure it out...
-b
is batch mode. I haven't used it, but you're welcome to try. \$\endgroup\$