Load_circuit failing for some reasons


  • OS: MacOS Catilina (version 10.15.7)
  • Python framework with PyCharm + Conda environment
  • PySpice installed with Conda (version 1.4.3)
  • libngspice installed with Conda
  • NGSPICE installed with homebrew (version 33)
    • location: /usr/local/bin/ngspice
    • functionality check: NGSPICE works from terminal and does simulate a circuit

Hi,

this is my first test with the “PySpice” flow. I went through the explained installation steps:

By running the “resistor-bridge.py” example:

I get the following error:


PySpice.Spice.NgSpice.Shared.NgSpiceCommandError: Command ‘run’ failed

By placing a breakpoint and debugging the code I see that the failing point is at (every line nested hierarchically):

analysis = simulator.operating_point()
return self._run(‘operating_point’, *args, **kwargs)
self._ngspice_shared.run()
self.exec_command(command)
raise NgSpiceCommandError(“Command ‘{}’ failed”.format(command))

And is due to stderr = ‘Error: there aren’t any circuits loaded.’

By debugging further I could nail down that the def run() method of the Simulation class fails because the run command after the load_circuit command complains that the circuit wasn’t loaded.

def _run(self, analysis_method, *args, **kwargs):

    super()._run(analysis_method, *args, **kwargs)

    self._ngspice_shared.destroy()
    # Fixme: Error: circuit not parsed.
    self._ngspice_shared.load_circuit(str(self))
    self._ngspice_shared.run()
    self._logger.debug(str(self._ngspice_shared.plot_names))
    self.reset_analysis()

    plot_name = self._ngspice_shared.last_plot
    if plot_name == 'const':
        raise NameError('Simulation failed')

    return self._ngspice_shared.plot(self, plot_name).to_analysis()

So the load_circuit method seems to not load the circuit properly in the sim, any idea why? (although it does execute it and no error is raised within that method).

I tried also the listing() method to query the circuit description back and also doesn’t seem to provide anything back.

Actually the only communication with the simulator seems to be successful is the “version -f” command which returns the valuable infos from it.

Thanks,
Andrea