Open aiifabbf opened 6 years ago
Thanks to report ! Unfortunately I need the lib to debug this issue but I could not find it using google
It is a proprietary lib...so I am not sure I can post it here publicly.
I have tested this on another lib, and it is the same problem. This test.tar.gz contains the lib, the netlist and test code.
The code is as simple as
from PySpice.Spice.Parser import SpiceParser
circuit = SpiceParser("two-stage-amp.cir").build_circuit()
print(circuit) # .lib statement is ignored
circuit.raw_spice += ".lib CMOS_035_Spice_Model.lib tt" # so have to manually add this
simulator = circuit.simulator(simulator="ngspice-subprocess")
analysis = simulator.ac(start_frequency=1, stop_frequency=1e+10, number_of_points=100, variation="dec") # error
The error message is
Traceback (most recent call last):
File "plot.py", line 10, in <module>
analysis = simulator.ac(start_frequency=1, stop_frequency=1e+10, number_of_points=100, variation="dec") # error
File "/home/benjamin/Desktop/test/env/lib/python3.6/site-packages/PySpice/Spice/Simulation.py", line 747, in ac
return self._run('ac', *args, **kwargs)
File "/home/benjamin/Desktop/test/env/lib/python3.6/site-packages/PySpice/Spice/NgSpice/Simulation.py", line 76, in _run
raw_file = self._spice_server(spice_input=str(self))
File "/home/benjamin/Desktop/test/env/lib/python3.6/site-packages/PySpice/Spice/NgSpice/Server.py", line 162, in __call__
return RawFile(stdout, number_of_points)
File "/home/benjamin/Desktop/test/env/lib/python3.6/site-packages/PySpice/Spice/NgSpice/RawFile.py", line 170, in __init__
raw_data = self._read_header(stdout)
File "/home/benjamin/Desktop/test/env/lib/python3.6/site-packages/PySpice/Spice/NgSpice/RawFile.py", line 193, in _read_header
self.temperature, self.nominal_temperature = self._read_temperature_line(header_line_iterator)
File "/home/benjamin/Desktop/test/env/lib/python3.6/site-packages/PySpice/Spice/RawFile.py", line 253, in _read_temperature_line
line = self._read_header_line(header_line_iterator, 'Doing analysis at TEMP')
File "/home/benjamin/Desktop/test/env/lib/python3.6/site-packages/PySpice/Spice/RawFile.py", line 223, in _read_header_line
raise NameError("Unexpected line: %s" % (line))
NameError: Unexpected line: Warning: Model issue on line 49 : .model n_33 nmos level=49 acm=3 lmin=3.5e-7 lmax=5.0e-5 ...
When I use ngspice from the command line, ngspice will prompt warnings but won't halt simulation
(env) benjamin@benjamin-Lenovo-IdeaPad-Yoga-13:~/Desktop/test$ ls
b3v3_1check.log env test.tar.gz
CMOS_035_Spice_Model.lib plot.py two-stage-amp.cir
(env) benjamin@benjamin-Lenovo-IdeaPad-Yoga-13:~/Desktop/test$ ngspice two-stage-amp.cir
******
** ngspice-26 : Circuit level simulation program
** The U. C. Berkeley CAD Group
** Copyright 1985-1994, Regents of the University of California.
** Please get your ngspice manual from http://ngspice.sourceforge.net/docs.html
** Please file your bug-reports at http://ngspice.sourceforge.net/bugrep.html
** Creation Date: Sun Feb 7 10:53:02 UTC 2016
******
Circuit: *sheet name:/opa_sr
Warning: Model issue on line 49 : .model n_33 nmos level=49 acm=3 lmin=3.5e-7 lmax=5.0e-5 ...
unrecognized parameter (acm) - ignored
unrecognized parameter (tref) - ignored
unrecognized parameter (cjgate) - ignored
unrecognized parameter (php) - ignored
Warning: Model issue on line 183 : .model p_33 pmos level=49 acm=3 lmin=3.5e-7 lmax=5.0e-5 ...
unrecognized parameter (acm) - ignored
unrecognized parameter (tref) - ignored
unrecognized parameter (cjgate) - ignored
unrecognized parameter (php) - ignored
ngspice 2 -> ac dec 100 1 10G
Doing analysis at TEMP = 27.000000 and TNOM = 27.000000
No. of Data Rows : 1001
ngspice 2 ->
Environment (OS, Python version, PySpice version, simulator)
Ubuntu 16.04, Python 3.6.5, PySpice 1.2.0, ngspice 26 as subprocess
Expected Behaviour
PySpice should not raise Python exceptions when encountered with warnings in ngspice, because the simulation can still go on in ngspice interactive mode.
Actual Behaviour
When ngspice works under interactive mode and encounters a warning, it prints the warning but does not stop the simulation.
But when PySpice reads the same warning from ngspice, it raises a Python exception and the simulation pauses.
Steps to reproduce the behaviour
Include an ngspice model lib that contains parameters undefined in ngspice(but properly defined in some commercial spice-compatible simulators like hspice) and this issue would happen, e.g. tsmc rf18 lib.