0
\$\begingroup\$

I would like to know please if there is a way I can run a LTspice simulation using only python. In other words, I need a python alternative to this command: subprocess.run(['scad3.exe','-b','netlist.cir']). I know there is an ltspice library but, to my knowledge, it is only used to extract data from the generated .raw file but does not run the simulation.

Looking forward to your suggestions.

asked Oct 21, 2020 at 8:42
\$\endgroup\$
4
  • \$\begingroup\$ A collegue of mine did that with NGspice. Took our collective LTspice netlists and had a script to interate the results via NG. Would be very interesting to know if it's possible via LTspice command line though. \$\endgroup\$ Commented Oct 21, 2020 at 8:51
  • \$\begingroup\$ @winny, are the LTspice and Ngspice netlist the same? I mean can I simulate the Ltspice netlist in NGspice? \$\endgroup\$ Commented Oct 21, 2020 at 8:52
  • 1
    \$\begingroup\$ Yes. SPICE fundation is to my knowledge the same across them all. I can enquire him if he had to parse something in or out to make NG accept it. \$\endgroup\$ Commented Oct 21, 2020 at 9:23
  • \$\begingroup\$ @winny, yes please, it'll mean a lot. Thanks \$\endgroup\$ Commented Oct 21, 2020 at 10:53

1 Answer 1

2
\$\begingroup\$

I can't answer for Python since I'm not very familiar with it, but I suspect there is some way to run an external program. And if there is, then what you have there is exactly what you need to run a netlist: the -b command line switch. See more about them in the help, under LTspice > Modes of Operation > Command Line Switches.

Extensions do not matter, they may even be missing. All that counts is the contents of the file that must be in SPICE netlist format, with elements that are recognizable by LTspice. That's all.

And if you have an .asc that you want to be run in batch mode, all you need is the -netlist switch, which converts the schematic to a netlist format.

answered Oct 21, 2020 at 9:37
\$\endgroup\$
5
  • \$\begingroup\$ I am aware of this. There is a way to run an external program, but I'd rather use a python package than an executable (ltsputil.exe)... \$\endgroup\$ Commented Oct 22, 2020 at 6:52
  • \$\begingroup\$ You mean you want to run a simulation without using a simulator? Or you just don't want to run LTspice? You could do that with other SPICE programs, provided the netlist is recognized by them (i.e. there are no elements that are particular to one program or the other, e.g. A-devices), but then why use the ltspice? \$\endgroup\$ Commented Oct 22, 2020 at 7:47
  • \$\begingroup\$ I am asking if there is a python package that runs an ltspice simulations provided the netlist instead for using this command 'subprocess.run(['scad3.exe','-b','netlist.cir'])'. Not sure if you understood my question \$\endgroup\$ Commented Oct 22, 2020 at 7:50
  • \$\begingroup\$ You want to avoid writing yourself subprocess.run() and let a readily-made script do that. Is this it? If it is, not only I don't know any, but it also has quite little to do with electronics. Since it's mostly software-related, a better place might be stackoverflow. \$\endgroup\$ Commented Oct 22, 2020 at 7:53
  • \$\begingroup\$ Yes it is. Ok I will post my question there. Thanks ! \$\endgroup\$ Commented Oct 22, 2020 at 7:57

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.