How to run qspice simulation in/with python?

Are you aware this project by @masashi.nogawa?

I think no matter to run a .qsch from python or matlab or other platform, the idea is to run Qspice from command mode (i.e., not from the GUI), and the basic workflow involves using QUX.exe to convert .qsch files into a .cir file (a SPICE netlist file) and utilizing Qspice64.exe or Qspice80.exe to read the .cir file and run the simulation, outputting waveform data into a .qraw file (defaulting to binary format). Upon a quick review of qspice.py in PyQSPICE, it appears that this project is based on the .plot command and extracts (exports) data from the .qraw file using QUX.exe. Handling a binary .qraw file directly poses a challenge, so I assume it uses an export method to obtain ASCII format data. (This is just a quick overview of the code, so I may have misunderstood this aspect.) With the data in hand, the next step is simply manipulating it in Python.

Keep in mind, Qspice is not running a simulation from the schematic, but the netlist from this schematic. QUX.exe (schematic window) is just to convert this schematic into netlist (.cir), to allow Qspice (Qspice64.exe or Qspice80.exe) to run the result. You can run a simulation just with a netlist (.cir)… .qsch is NOT necessary.

So, to sweep V2, either you keep .step command in schematic (i.e. in netlist) for Qspice to run it. OR, you write a code that can modify the netlist that feed into Qspice64.exe or Qspice80.exe to run the result.

1 Like