pingspice.circuit.netlist.Netlist(object)
class documentation
Part of pingspice.circuit.netlist
(View In Hierarchy)
I construct an Ngspice netlist with a circuit name.
There are several possible constructor argument patterns available to you:
- If you supply the path to a netlist file for me to generate, it must be the first (possibly only) argument. I will make up a circuit name based on the file name. I will open (as new), write to, and close a file at the path.
- If you supply a file-like object for me to write to, it must be the first argument. It may be followed by a circuit name, since I can't use a file name for that. If not, I will make up a circuit name based on the present date and time. NOTE: I don't close the file-like object; that's up to you.
- If you supply neither a file path nor a file-like object, I will write the netlist lines to myself. You can obtain the netlist text by coercing my instance to a string or via my netlist attribute. I will make up a circuit name based on the present date and time. You can't specify a circuit name as a first argument because I'd have no way of differentiating that from a relative file path; I will make one up based on the present date and time.
-
If you supply a
None
object as the first argument, I will write netlist lines to myself and you can obtain the netlist text by coercing my instance to a string, as with pattern #3. You can specify a circuit name as a second argument if you wish. -
For any of these patterns #1-4, you can supply as an additional
argument an instance of
AV_Manager
that will handle any alterable values in the netlist by representing them with instances ofAV
.
With any set of arguments, you can include constructor keywords that
override default values of pingspice-only simulation options defined in PS_Options
,
or define the values of Ngspice options to follow the circuit text in the
netlist, or both. There won't be any conflicts because the names of the
pingspice-only simulation options (and there are just a few) were chosen to
not be the same as any Ngspice option names.
Here's an example combining patterns #1 and #6. It supplies the path of a netlist file for me to write, as a sole argument, and sets the pingspice-only simulation option ts to a timestep target of 1 Nanosecond:
with Netlist(FILEPATH, ts=1E-9)() as f: f.V(1, 0, 'DC', 1, 'AC', 1) f.R(1, 2, R) f.L(2, 3, L) f.C(3, 0, C)
When you call an instance of me in a with ... as
statement,
it yields an instance of Elements
that you call to generate circuit elements.
Then context-call the instance with any parametric attributes for the
entire circuit (§2.8.1), obtaining an instance of Elements
for use inside your with
statement. Note that these keywords
are different from the constructor keywords, which only define simulation
options.
Call that instance to add circuit lines, or call my instance again (in a
sub-context) to get another instance of Elements
to use inside a nested with
statement, to add circuit lines of
a subcircuit.
When I'm done with the context call, if you opted for pattern option #5,
the AV_Manager
object you supplied to me will be shared with the Elements
instance and will have an avList populated with AV objects
constructed in the call.
Parameters | debug | Set True to log info about the nodes connected for each Include and
Subcircuit
I construct. Default is False , because this can result in a
lot of info clogging up your logs. |
Instance Variable | avm | An instance of AV_Manager
supplied as a final constructor argument. |
Instance Variable | netlist | My netlist text, if I was constructed without a file path or file-like object to write it to. |
Instance Variable | nodes | A set of all nodes that were connected in my top-level circuit. These are
all the nodes you can access from a call to ngspice.runner.NgspiceRunner.get
or ngspice.runner.NgspiceRunner.getVector ,
or from a call to the analysis.vectors.Vectors_Ngspice
object you receive from an analysis with an analysis.sim.Analyzer . |
Instance Variable | debug | This is set based on the value of the constructor keyword (option)
debug, default False . Don't try setting it directly. |
Method | __init__ | Undocumented |
Class Method | uic | Returns True if initial conditions have been defined for
any component. |
Method | __str__ | If you constructed me without a file path or file-like object, you can obtain my netlist text by coercing me to a string. |
Method | write | Called with a newline-terminated chunk of text when I am writing to myself as a file-like object. |
Method | __call__ | Call this as part of a "with ... as" statement. Yields an
instance of Elements
to use within the context of that statement. |
Method | _dashes | Undocumented |
ngspice.runner.NgspiceRunner.get
or ngspice.runner.NgspiceRunner.getVector
,
or from a call to the analysis.vectors.Vectors_Ngspice
object you receive from an analysis with an analysis.sim.Analyzer
.
False
. Don't try setting it directly.
def uic(cls, yes=None):
Returns True
if initial conditions have been defined for
any component.
If you constructed me without a file path or file-like object, you can obtain my netlist text by coercing me to a string.
Called with a newline-terminated chunk of text when I am writing to myself as a file-like object.
def __call__(self, *args, **params):
Call this as part of a "with ... as" statement. Yields an
instance of Elements
to use within the context of that statement.
You can call this again within that context to get other instances of Elements
for subcircuits.
For subcircuit calls, the arguments specify the external nodes of the subcircuit.
Define any parameter values as keywords. They will appear in a .PARAM line and can be referenced by name in a brace expression anywhere in your circuit.