Let’s say that we have this voltage divider circuit. Is it possible to upload the qspice schematic into a python script, to show the waveform result V(in) and V(out) in python, and then to sweep the V2 voltage source from 1V to 10V with 1V step, but this sweep to be made and run within python script?
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.