lcapy.loopanalysis.LoopAnalysis

class lcapy.loopanalysis.LoopAnalysis(cct)

Bases: object

This performs for loop analysis. Currently, it uses mesh analysis and so is only applicable to circuits with a planar topology and without twoport components.

The API is likely to change since different invocations find different current loops.

>>> from lcapy import Circuit, LoopAnalysis
>>> cct = Circuit('''
... V1 1 0 {u(t)}; down
... R1 1 2; right=2
... L1 2 3; down=2
... W1 0 3; right
... W 1 5; up
... W 2 6; up
... C1 5 6; right=2
...''')

To perform loop analysis in the time domain:

>>> la = LoopAnalysis(cct)

To display the equations found by applying KVL around each mesh:

>>> la.mesh_equations().pprint()

To display the system of equations (in matrix form) that needs to be solved:

>>> la.matrix_equations().pprint()

This only works for dc, ac, or laplace domains. For example,

>>> LoopAnalysis(cct.laplace()).matrix_equations().pprint()

Methods

__init__(cct)

from_circuit(cct)

loops()

Return list of loops.

loops_by_cpt_name()

Return list of loops specified by cpt name.

matrix_equations([form, invert])

Return the equations in matrix form.

mesh_currents()

mesh_equations()

Return mesh equations as a dict keyed by the mesh current.

mesh_equations_list()

Return mesh equations as a list.

pdb()

Enter the python debugger.

solve_laplace()

Determine the unknown voltages using Laplace transforms and return as a dict

Attributes

A

Return A matrix where A y = b.

b

Return b vector where A y = b.

num_loops

unknowns

Return tuple of the unknown voltages

y

Return y vector where A y = b.

property A

Return A matrix where A y = b.

property b

Return b vector where A y = b.

loops()

Return list of loops. Note, the loops can vary for different invocations of the LoopAnalysis class.

loops_by_cpt_name()

Return list of loops specified by cpt name.

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

Return the 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_equations()

Return mesh equations as a dict keyed by the mesh current.

mesh_equations_list()

Return mesh equations as a list.

pdb()

Enter the python debugger.

solve_laplace()

Determine the unknown voltages using Laplace transforms and return as a dict

property unknowns

Return tuple of the unknown voltages

property y

Return y vector where A y = b.