lcapy.netlist.Netlist

class lcapy.netlist.Netlist(filename=None, context=None, allow_anon=False, kind='super')

Bases: NetlistOpsMixin, NetlistMixin, NetlistSimplifyMixin

This class handles a generic netlist with multiple sources. During analysis, subnetlists are created for each source kind (dc, ac, transient, etc). Since linearity is assumed, superposition is employed.

Methods

__init__([filename, context, allow_anon, kind])

ac([omega])

Return netlist for ac components of independent sources for angular frequency omega.

ac_omega_list()

Return list of the angular frequencies of the sources in the netlist.

annotate(cpts, *args, **kwargs)

Annotate a particular component (or list of components) with specified schematic attributes and return new netlist.

annotate_current(cpts[, domainvar, flow, pos])

annotate_currents([cpts, domainvar, flow, ...])

Annotate specified list of component names cpts with current (or flow).

annotate_node_voltages([nodes, domainvar, ...])

Create a new netlist with the node voltages annotated.

annotate_voltage(cpts[, domainvar, pos])

annotate_voltages([cpts, domainvar, style, ...])

Annotate specified list of component names cpts with voltage.

apply_test_current_source(Np[, Nm])

This copies the netlist, kills all the sources, and applies a Dirac delta test current source across the specified nodes.

apply_test_voltage_source(Np[, Nm])

This copies the netlist, removes any voltage sources across the specified nodes, kills all the remaining sources, and applies a Dirac delta test voltage source across the specified nodes.

branch_current_names()

Return ExprList of branch current names of the form i_cptname for the time-domain and of the form I_cptname othwerwise.

branch_currents()

Return ExprList of branch currents.

branch_voltage_names()

Return ExprList of branch voltage names of the form v_cptname for the time-domain and of the form V_cptname othwerwise.

branch_voltages()

Return ExprList of branch voltages.

convert_IVP([t])

Remove switches from netlist and convert to an initial value problem.

dc()

Return netlist for dc components of independent sources.

describe()

Print a message describing how circuit is solved.

description()

Return a message describing how circuit is solved.

evidence_matrix()

Return the evidence matrix.

expand([depth])

Expand the netlist, replacing complicated components with simpler components.

get_I(name[, nowarn])

Current through component (time-domain)

get_Vd(Np[, Nm])

Voltage drop between nodes (time-domain)

get_i(name)

Time-domain current through component

get_vd(Np[, Nm])

Time-domain voltage drop between nodes

highlight(cpts[, color])

Highlight a particular component (or list of components) with specified color and return new netlist.

initialize(cct[, T])

Set the initial values for this netlist based on the values computed for netlist cct at specified time T.

laplace([ics])

Return netlist for Laplace-domain representations of independent source values.

loop_analysis()

Perform loop analysis for this netlist.

matrix_equations([form, invert])

Return modified nodal analysis equations in matrix form.

mesh_analysis()

Perform mesh analysis for this netlist.

modified_nodal_analysis()

Perform modified nodal analysis for this netlist.

nodal_analysis([node_prefix])

Perform nodal analysis for this netlist.

noise()

Return netlist for noise components of independent sources.

noise_model([T])

"Create noise model where resistors are converted into a series combination of an ideal resistor and a noise voltage source.

noisy(*args[, T])

Return a new circuit with the specified resistors in series with noise voltage sources

noisy_except(*args[, T])

Return a new circuit with all but the specified resistors in series with noise voltage sources

open_circuit(cpt)

Apply open-circuit in series with component.

prune(name)

Prune specified element by name or elements specified in list.

remove(name)

Remove specified element by name or elements specified in list.

remove_node_positions()

Remove explicit node positions added by lcapy-tk.

renumber([node_map])

Renumber nodes using specified node_map.

replace(oldname, newname)

Replace component.

replace_switches([t, switchnames])

Replace specified switches with open-circuit or short-circuit for time at or after t.

replace_switches_before([t, switchnames])

Replace specified switches with open-circuit or short-circuit for time just before t.

save(filename)

Save netlist to file.

select(kind)

Return new netlist with transform domain kind selected for specified sources in sourcenames.

short_circuit(cpt)

Apply short-circuit across component.

switching_times([tmax])

Return sorted list of the times that switches activate prior to tmax.

time()

Return netlist for time-domain representations of independent source values.

transient()

Return netlist for transient components of independent sources.

transient_time()

Return netlist for transient components of independent sources in Time-domain.

Attributes

Idict

Return dictionary of branch currents for each transform domain

Vdict

Return dictionary of node voltages for each transform domain

cpts

Return list of component names.

kinds

Return list of transform domain kinds required to analyse the netlist.

params

Return list of symbols used as arguments in the netlist.

sim

Generate simulation object.

ss

Generate state-space representation.

sub

Return dictionary of subnetlists keyed by transform domain kind.

subcircuits

Return dictionary of subnetlists keyed by transform domain kind.

super_nodes

Super nodes are nodes linked by voltage sources.

symbols

Return dictionary of symbols defined in the netlist.

undefined_symbols

property Idict

Return dictionary of branch currents for each transform domain

property Vdict

Return dictionary of node voltages for each transform domain

ac(omega=None)

Return netlist for ac components of independent sources for angular frequency omega. If omega is undefined, the angular frequency omega0 is used.

See also: dc, laplace, transient, noise, time.

ac_omega_list()

Return list of the angular frequencies of the sources in the netlist.

annotate(cpts, *args, **kwargs)

Annotate a particular component (or list of components) with specified schematic attributes and return new netlist.

For example: cct.annotate(‘R1’, color=’blue’) cct.annotate(‘R1’, ‘color=blue, dashed’) cct.annotate((‘U1’, ‘U2’), fill=’blue’)

See also highlight.

annotate_currents(cpts=None, domainvar=None, flow=False, style='eng4', show_units=True, pos='')

Annotate specified list of component names cpts with current (or flow).

domainvar specifies the domain to calculate the voltages for (e.g., t for time-domain, s for Laplace-domain)

flow (default False) if True annotates current as a flow

style (default ‘eng4’) specifies numerical format (‘eng’, ‘ratfun’, ‘sci’, ‘spice’, ‘sympy’)

show_units (default True) if True applies the units(e.g., V for volts)

pos specifies where to position the labels(see docs)

annotate_node_voltages(nodes=None, domainvar=None, label_voltages=False, eng_format=True, evalf=True, num_digits=3, show_units=True, anchor='south west')

Create a new netlist with the node voltages annotated. This is useful for drawing a schematic with the node voltages shown. For example,

cct.annotate_node_voltages((1, 2, 3)).draw()

nodes is a list of the nodes to annotate or None for all.

domainvar specifies the domain to calculate the voltages for (e.g., t for time-domain, s for Laplace-domain)

label_voltages (default False) if True prefixes the annotation with V1 = for node 1, etc.

eng_format (default True) if True use engineering format if the voltage is a number, e.g., 100, mV instead of 0.1, V

evalf (default True) if True prints floating point numbers as decimals otherwise they are shown as rationals

num_digits (default 3) specfies the number of digits to print for floating point numbers

show_units (default True) if True applies the units(e.g., V for volts)

anchor (default ‘south west’) specifies the position of the voltage label

annotate_voltages(cpts=None, domainvar=None, style='eng4', show_units=True, pos='')

Annotate specified list of component names cpts with voltage.

domainvar specifies the domain to calculate the voltages for (e.g., t for time-domain, s for Laplace-domain)

pos specifies where to position the labels, see docs

style (default ‘eng4’) specifies numerical format (‘eng’, ‘ratfun’, ‘sci’, ‘spice’, ‘sympy’)

show_units (default True) if True applies the units(e.g., V for volts)

pos specifies where to position the labels(see docs)

apply_test_current_source(Np, Nm=None)

This copies the netlist, kills all the sources, and applies a Dirac delta test current source across the specified nodes. If the netlist is not connected to ground, the negative specified node is connected to ground. The new netlist is returned.

apply_test_voltage_source(Np, Nm=None)

This copies the netlist, removes any voltage sources across the specified nodes, kills all the remaining sources, and applies a Dirac delta test voltage source across the specified nodes. If the netlist is not connected to ground, the negative specified node is connected to ground. The new netlist is returned.

branch_current_names()

Return ExprList of branch current names of the form i_cptname for the time-domain and of the form I_cptname othwerwise.

branch_currents()

Return ExprList of branch currents. Each element is a SuperpositionVoltage object.

If you want a vector of time-domain expressions use Vector(cct.branch_currents()(t)).

branch_voltage_names()

Return ExprList of branch voltage names of the form v_cptname for the time-domain and of the form V_cptname othwerwise.

branch_voltages()

Return ExprList of branch voltages. Each element is a SuperpositionVoltage object.

If you want a vector of time-domain expressions use Vector(cct.branch_voltages()(t)).

convert_IVP(t=0)

Remove switches from netlist and convert to an initial value problem. t is used to determine the state of the switches.

property cpts

Return list of component names.

dc()

Return netlist for dc components of independent sources.

See also: ac, laplace, transient, noise, time.

describe()

Print a message describing how circuit is solved.

description()

Return a message describing how circuit is solved.

evidence_matrix()

Return the evidence matrix. This has a size NxM where N is the number of nodes and M is the number of branches.

An element is 1 for currents entering a node from a branch, -1 for currents leaving a node from a branch, and zero otherwise.

Note, each column sums to zero.

expand(depth=None)

Expand the netlist, replacing complicated components with simpler components.

get_I(name, nowarn=False)

Current through component (time-domain)

get_Vd(Np, Nm=None, **kwargs)

Voltage drop between nodes (time-domain)

get_i(name)

Time-domain current through component

get_vd(Np, Nm=None)

Time-domain voltage drop between nodes

highlight(cpts, color='blue')

Highlight a particular component (or list of components) with specified color and return new netlist.

See also annotate.

initialize(cct, T=None)

Set the initial values for this netlist based on the values computed for netlist cct at specified time T.

Alternatively, set the initial values using a dictionary of values keyed by the component name.

property kinds

Return list of transform domain kinds required to analyse the netlist.

laplace(ics=True)

Return netlist for Laplace-domain representations of independent source values.

If ics is True, compute initial conditions for capacitors and inductors.

See also: ac, dc, transient, noise, time.

loop_analysis()

Perform loop analysis for this netlist. This is cached.

This is currently an alias for mesh_analysis() and so only works for circuits with a planar topology.

matrix_equations(form='default', invert=False)

Return modified nodal analysis equations in matrix form.

Forms can be:

‘default’ ‘A y = b’ ‘b = A y’ ‘Ainv b = y’ ‘y = Ainv b’

If invert is True, evaluate the matrix inverse.

mesh_analysis()

Perform mesh analysis for this netlist. This is cached.

This is only applicable for circuits with a planar topology.

modified_nodal_analysis()

Perform modified nodal analysis for this netlist. This is cached.

nodal_analysis(node_prefix='')

Perform nodal analysis for this netlist. This is cached.

Use node_prefix to distingish between nodal voltages and voltage source voltages.

noise()

Return netlist for noise components of independent sources.

See also: ac, dc, laplace, transient, time.

noise_model(T='T')

“Create noise model where resistors are converted into a series combination of an ideal resistor and a noise voltage source.

noisy(*args, T='T')

Return a new circuit with the specified resistors in series with noise voltage sources

noisy_except(*args, T='T')

Return a new circuit with all but the specified resistors in series with noise voltage sources

open_circuit(cpt)

Apply open-circuit in series with component. Returns name of open circuit component.

property params

Return list of symbols used as arguments in the netlist.

prune(name)

Prune specified element by name or elements specified in list. Unlike remove(), this makes a copy of the netlist before removing the specified components. The updated netlist is returned.

remove(name)

Remove specified element by name or elements specified in list.

remove_node_positions()

Remove explicit node positions added by lcapy-tk.

renumber(node_map=None)

Renumber nodes using specified node_map. If node_map not specified then a mapping is created.

replace(oldname, newname)

Replace component.

For example, b = a.replace(‘C’, ‘W’) c = a.replace(‘C1’, ‘C1 1 2’)

replace_switches(t=0, switchnames=None)

Replace specified switches with open-circuit or short-circuit for time at or after t. If switchnames is not specified, all switches are replaced.

replace_switches_before(t=0, switchnames=None)

Replace specified switches with open-circuit or short-circuit for time just before t. If switchnames is not specified, all switches are replaced.

save(filename)

Save netlist to file.

select(kind)

Return new netlist with transform domain kind selected for specified sources in sourcenames.

short_circuit(cpt)

Apply short-circuit across component. Returns name of voltage source component used as the short.

property sim

Generate simulation object.

property ss

Generate state-space representation. See also state_space()

property sub

Return dictionary of subnetlists keyed by transform domain kind. Note, the subnetlists are not created until a specific one is selected.

property subcircuits

Return dictionary of subnetlists keyed by transform domain kind. Note, the subnetlists are not created until a specific one is selected. The subcircuit keys are : ‘ivp’ for an initial value problem solved using Laplace methods, ‘s’ for transient analysis using Laplace methods, ‘dc’ for DC analysis, ‘time’ for time-domain analysis when there are no reactive components, ‘n*’ for noise-analysis (there is a subcircuit for each independent noise source), and omega (where omega is a number of expression specifying the angular frequency) for phasor analysis.

property super_nodes

Super nodes are nodes linked by voltage sources.

switching_times(tmax=1000000000000.0)

Return sorted list of the times that switches activate prior to tmax.

property symbols

Return dictionary of symbols defined in the netlist.

time()

Return netlist for time-domain representations of independent source values.

See also: ac, dc, transient, laplace, noise.

transient()

Return netlist for transient components of independent sources.

See also: ac, dc, laplace, noise, time.

transient_time()

Return netlist for transient components of independent sources in Time-domain.

See also: ac, dc, laplace, noise, time.