pingspice.analysis.param.ParameterFinder(object)
class documentation
Part of pingspice.analysis.param
(View In Hierarchy)
Known subclasses: pingspice.analysis.diode.Diode_Finder, pingspice.analysis.mosfet.MOSFET_Finder, pingspice.analysis.thermal.Package_Finder, pingspice.examples.rlc-04.RLC_Finder, pingspice.examples.rlc-05.RLC_Finder, pingspice.examples.rlc-06.RLC_Finder, pingspice.test.analysis.test_param.AParameterFinder, pingspice.test.lib.test_diodes.SillyParameterFinder
Model parameter evolver.
I use Differential Evolution to identify an optimum combination of
alterable values and device or model parameters in a circuit for fitting
its simulated behavior to goal points you specify in your subclass of Setups
that you supply to your subclass of me with the Setups class
attribute.
Define the alterable values in your setup
method with:
f.av(name, <dev|model>, [<param>], min, max)
For the differential evolution algorithm used, you MUST define min and max bounds for each alterable.
If you set the params keyword to a dict of parameter values keyed
by their names, or a string from which I can parse such a dict, I will just
serve as a structure for my setup
method to be used by a netlist.Subcircuit
,
with no parameter-finding being done.
You can set attributes for the Setups
instance with keywords not listed here as reserved for my own use. The most
useful is IDs, a list of setup IDs for restricted parameter
finding.
Parameters | params | Parameter values from a previous parameter finding session. If this keyword
is present and not None , all of the other keywords will be
ignored. (type: dict) |
N_cores | The number of CPU cores my solver should use for evaluations. | |
wire | Set True for my solver to use a WireEvaluator. | |
tcp | Set to a TCP host:port endpoint for the WireEvaluator (TODO). | |
debug | Set True for a debugging mode with more verbose output and
opportunities to fix stuff. | |
spew | Set True for an extremely verbose mode that spews out the
communications between Python and Ngspice. | |
console | Set True to drop to an interactive Ngspice console if Ngspice
has an error. | |
autoUIC | Set True to have TRAN analysis done with the 'uic' option if
any netlist item has ic set to something. this isn't that useful as
Ngspice's uic option is very hard to tame. | |
plotFile | Set to the full path of a PNG file that will update with plots showing the
progress of parameter finding. The default is ~/pfinder.png . | |
plotDims | Set to a 2-sequence of ints with the pixel width and height of the plot, or
to None if the default defined in Plotter is to
be used. | |
logFile | The path of a file for logging output (CAUTION: File gets truncated, i.e., overwritten). Logs to STDOUT if not provided. | |
knowns | A dict of known parameter values. This is of the same type as the params keyword, but doesn't cause my instance to skip parameter finding. It also doesn't need to have all (or even any) parameter values defined. | |
twp | A percentage for varying known value(s) +/- as bounds. Default is
None , but note that it's rarely a good idea for parameter
values to not be subject to any parameter modification at all during
parameter finding. |
Class Variable | Setups | A subclass of Setups
that you define to specify parameter names, analyzers, independent vectors,
goal points, etc. |
Instance Variable | s | An instance that I construct of the Setups
subclass referenced in your subclass of me. |
Class Variable | setup | The Ngspice circuit setup for the parameter-finding testbed. The similarity of names is regretted. |
Method | __init__ | There are two different call patterns. One is for using Differential Evolution to find parameter values: |
Method | __getattr__ | Looks to my subcircuit "parent" and then my Setups
object s for attributes that I lack. |
Method | tableSources | Called by analyzerPrep
for each setup ID to possibly generate one or more TABLE
sources. |
Method | analyzerPrep | Call this with a setup ID to provide what the
Analyzer for that setup will need when it is activated. |
Method | __call__ | Call this to find best-fit alterable values for the circuit you've
defined with your setup
override method. |
Method | setupTestCircuit | You must override this to define test circuitry for one or more setups. |
Class | _EmptySetups | Undocumented |
Method | __init_pf | My constructor calls this to do the full initialization in paramfinding mode, when no parameters are supplied. |
Setups
that you define to specify parameter names, analyzers, independent vectors,
goal points, etc.
There are two different call patterns. One is for using Differential Evolution to find parameter values:
ParameterFinder( cfg, N_cores=None, wire=False, debug=False, spew=False, console=False, autoUIC=False, plotFile=~/pfinder.png, plotDims=None, logFile=None, knowns={}, twp=None)
The other is for using all-known parameter values to do an actual simulation in a circuit or subcircuit:
ParameterFinder(params={...})
My constructor calls this to do the full initialization in paramfinding mode, when no parameters are supplied.
Looks to my subcircuit "parent" and then my Setups
object s for attributes that I lack.
Called by analyzerPrep
for each setup ID to possibly generate one or more TABLE
sources.
If the specified setup ID has more than one independent vector and it's not a dual-sweep DC analysis, constructs a TABLE Ngspice voltage source for each secondary independent vector whose output is based on the primary independent vector.
This allows analyses based on real test circuits where multiple voltage vectors are acquired whose values are dependent on a primary test signal rather than behavior of the device under test.
Call this with a setup ID to provide what the
Analyzer
for that setup will need when it is activated.
Returns True
if the analyzer got prepared without any
problems. In particular, if calling your subclass's override of setupTestCircuit
with this ID didn't raise an exception.
def __call__(self, **kw):
Call this to find best-fit alterable values for the circuit you've
defined with your setup
override method.
Sets my params attribute to a dict of alterable values, keyed by
their names as defined with the f.av(<name>, ...)
calls
in that setup method.
Any keywords supplied will be passed on to the constructor of Solver
when I
make my own instance of it.
Returns a Deferred
that fires with a reference to a dict of
the best params and my ade.Population
instance in its final
state.
You must override this to define test circuitry for one or more setups.