pingspice.analysis.sim.Analyzer(AnalyzerBase)
class documentation
Part of pingspice.analysis.sim
(View In Hierarchy)
Known subclasses: pingspice.analysis.sim.AC, pingspice.analysis.sim.DC, pingspice.analysis.sim.OP, pingspice.analysis.sim.TRAN
Base class for TRAN
and DC
, which run the
transient and DC analysis, respectively, for one Ngspice process and handle
the results.
Construct me with an NgspiceRunner
instance r, an integer setup ID, a list of
vectorNames, a reference to a shared avList of all AV objects
defined for my setup, and the arguments specific to the type of analysis
I'm doing.
You can also construct an instance for a one-time run by supplying,
after the NgspiceRunner
instance, just the vectorNames list and any analysis-specific
arguments.
To reduce memory consumption (which can be considerable with simulations
that take more than a few minutes on a modern PC), I tell Ngspice to
discard vectors other than those in the vectorNames list. You can
disable this and save all vectors by setting the 'full' Config
option in
r.
If you want to specify Ngspice options for my runs to override the
defaults for all runs, supply them in the args sequence as 2-tuples.
The first element of each tuple is a string with the name of the option and
the second element is the value of the option in the same format as it
would appear in the global OPTIONS
dict of pingspice.ngspice.sourcery
.
Instance Variable | maxWait | Defines how long I will wait for a result from my NgspiceRunner, which actually should time out before I do. |
Instance Variable | absVals | Set to a sequence with the names of all vectors whose raw vector values are
always treated as positive numbers. See VectorsBase . |
Instance Variable | setupHasRun | Gets set True after my setup
has run. |
Method | __init__ | Constructor (two different forms): |
Class Method | onetime | Makes an instance of me fully set up for one-time usage with its own NgspiceRunner
sourced with the supplied netlist, runs it, and shuts it down. |
Method | shutdown | After setup
and any pending calls to my instance have finished, shuts down my NgspiceRunner
r. |
Method | __repr__ | Undocumented |
Method | customize | TRAN , AC , and DC override this to
set parameters for their simulation commands. OP has no need of
it. |
Method | setup | Tells my NgspiceRunner to source a netlist and then sets it up with a number of standard options intended to make convergence more likely. |
Method | addName | Call after setup to
add a vector with name to my Vectors_Ngspice
object V. |
Method | getAlterations | Returns a Deferred that fires with a list of lines to be
placed into a netlist, doing alterations of component values and model
parameters from their defaults. |
Method | __call__ | Performs an analysis of my subclass type (TRAN , AC , or DC ), and updates my
Vectors_Ngspice
object V with the resulting simulation vectors. |
Method | study | Creates a file with a copy of my netlist and commands to do alterations in accord with the supplied values, for inspection and running in Ngspice. |
Method | _notAllVectors | Returns True if I do a TRAN analysis and will not be saving
all vectors from it. |
Method | _doAlterations | Has Ngspice do alterations on component values and model parameters in accordance with the supplied sequence of values. |
Inherited from AV_ListHolder (via AnalyzerBase):
Method | params | Property: A list of the AV objects in my avList that are parameters. |
Method | avListSorted | Property: A copy of my avList, sorted by each AV object's dmpLabel . If
I have no avList for some reason, returns an empty list. |
Method | __len__ | My length is the number of parameter AV objects in my avList. |
Method | getValuesIndexFor | Returns the index in each values list supplied to my __call__
method at which the one and only parameter AV object is found having the
same name as the supplied av. |
Method | checkValues | Checks the supplied list of values to ensure that I have a parameter AV object for every one, and no parameter AV objects not accounted for. |
Method | alterations | Performs component and device parameter alterations based on the supplied list of parameter values, using the two callables supplied as additional arguments. |
Inherited from AV_ListHolder (via AnalyzerBase):
Method | params | Property: A list of the AV objects in my avList that are parameters. |
Method | avListSorted | Property: A copy of my avList, sorted by each AV object's dmpLabel . If
I have no avList for some reason, returns an empty list. |
Method | __len__ | My length is the number of parameter AV objects in my avList. |
Method | getValuesIndexFor | Returns the index in each values list supplied to my __call__
method at which the one and only parameter AV object is found having the
same name as the supplied av. |
Method | checkValues | Checks the supplied list of values to ensure that I have a parameter AV object for every one, and no parameter AV objects not accounted for. |
Method | alterations | Performs component and device parameter alterations based on the supplied list of parameter values, using the two callables supplied as additional arguments. |
VectorsBase
.
Constructor (two different forms):
AV Mode: Analyzer(r, ID, vectorNames, avList,
*args)
One-time Mode: Analyzer(r, vectorNames, *args)
def onetime(cls, netlist, vectorNames, *args, **kw):
Makes an instance of me fully set up for one-time usage with its own NgspiceRunner
sourced with the supplied netlist, runs it, and shuts it down.
After constructing and setting up the instance of me, I run it with the
args following the vectorNames
second arg to obtain a Vectors_Ngspice
object.
The netlist first arg can be the path of a netlist file or actual netlist text. That first argument is followed by the vectorNames and then arguments specific to the type of analysis being done.
You can specify as keywords the keywords recognized by the NgspiceRunner
constructor. The study and overwrite keywords are recognized
and used as for a call to my instance. You can also include keywords set
True
for Config
options to have
enabled.
Returns a Deferred
that fires after setting up, running,
vector fetching, and shutting down the instance, with the populated Vectors_Ngspice
object.
After setup
and any pending calls to my instance have finished, shuts down my NgspiceRunner
r.
Returns a Deferred
that fires when the Ngspice process
underlying my NgspiceRunner
instance r has exited.
Calling this repeatedly will have no effect, since repeatedly calling NgspiceRunner.shutdown
doesn't have any. If Ngspice has already exited, the returned
Deferred
fires immediately.
Returns True
if I do a TRAN analysis and will not be saving
all vectors from it.
def setup(self, netlist):
Tells my NgspiceRunner to source a netlist and then sets it up with a number of standard options intended to make convergence more likely.
Any options you supplied via 2-tuples in the args to my constructor will override the standard options.
Returns a Deferred
that fires when all that is done, with a
reference to me if all went OK or None
if not. Does not fire
any errback; rely on the result to determine success.
If there was a problem and the cfg.study
option is set, a
copy of the offending netlist will be written for study.
Call after setup
to
add a vector with name to my Vectors_Ngspice
object V.
The vector will be included in Ngspice's saved outputs, even if doing a TRAN analysis and the 'full' config option is not set.
Returns a Deferred
that fires when I'm ready to run an
analysis that includes this vector as well as those defined in my
constructor.
Parameters | k | Set this to an integer to have the name inserted at a specific position in
the names list of my Vectors_Ngspice
object's NameManager
rather than appended. The order isn't usually important, but does affect
the result of a call to Vectors_Ngspice.array . |
Returns a Deferred
that fires with a list of lines to be
placed into a netlist, doing alterations of component values and model
parameters from their defaults.
Has Ngspice do alterations on component values and model parameters in accordance with the supplied sequence of values.
Returns a Deferred
that fires when the alterations are
done.
Only one call to this method can be active at a time for a single
instance of me. The __call__
method uses my dLock
to ensure that.
def __call__(self, *args, **kw):
Performs an analysis of my subclass type (TRAN
, AC
, or DC
), and updates my
Vectors_Ngspice
object V with the resulting simulation vectors.
There are two different call patterns, depending on whether I'm operating in AV mode or one-time mode.
"Returns" a Deferred
that fires with a reference
to a fresh copy of my Vectors_Ngspice
instance. It will contain the Numpy vectors resulting from the analysis,
unless the value is out of a defined range or produced a Numpy error or
there was an Ngspice error.
If there's an error and the 'stop' Config
option is set, or
a netlist study occurs with the 'study_stop' option set, I will shut myself
down and call abortAll
to abort all other analyzers. If there's already a class-wide abort
condition, I won't bother running any analysis. In either of those cases,
the Deferred
will fire with None
.
AV Mode
Call this (i.e., my instance) with a list of float values (or sub-lists of floats in the case of vector values). I will update the device values, device parameter values, and model parameter values whose names are defined in AV objects in my avList before doing the analysis.
The total number of items in the values list must equal the number of parent AV objects in my avList. If no alterables have been defined, then an empty list is what's acceptable (the default if no arg is supplied).
To get an analysis at the default values for everything, you may call this with nothing.
One-time Mode
In one-time mode, I have no setup ID or avList, and no alterations are done.
If you supply the file path or text of a netlist as an argument, I
will call my setup
with it. Otherwise, make sure that I've had my setup
method called with a netlist or that the NgspiceRunner
you constructed me with has had its NgspiceRunner.source
method called with one.
Parameters | study | Set True to have a new netlist file written with 'alter' and
'altermod' commands included in its '.options' section, whether the
analysis succeeds or not. Warning: This can cause a lot of disk
activity and should only be used for a single analysis or during debugging.
You can also set it to the filePath of the netlist file you want generated. |
stop | Set True to have Python shut down after a call to study
causes a netlist file to be written. Does not imply the study
keyword because study
might only get called on an error if that keyword is not set. | |
overwrite | Set True to have the netlist file overwrite any existing one.
Ignored if study is not set and there's no error. |
Creates a file with a copy of my netlist and commands to do alterations in accord with the supplied values, for inspection and running in Ngspice.
If you supply an integer ID, it will be used as a suffix to the
netlist filename before the extension. Otherwise, if I have an ID
(not running in one-time mode), that will be used. The file path will be
~/pingspice-setup-XXX.cir
, where XXX is the ID With
leading zeros. Alternatively, you can specify the entire filePath
yourself.
"Returns" a Deferred
that fires when the
temporary file has been written, unless stop is set
True
. In that case, the Python process is rudely and
immediately shut down.
If there's already a file at at the file path, it will not be
overwritten, unless overwrite is set True
. This is so
that the first error encountered for a given setup is the only one that
produces a netlist.