SLiCAP circuit matrix equation
One of the first steps in the execution of each instruction is the construction of the MNA matrix equation (MNA: Modified Nodal Analysis). The matrix equation depends on the transfer type and the conversion type.
Every instruction returns the MNA matrix equation. The instruction doMatrix() returns the matrix equation without evaluating anything. It is the fastest way to obtain this equation.
The default settings of the transfer type and the conversion type in the doMatrix() are both None.
Settings for transfer types will be discussed in Work with feedback circuits.
Settings for conversion types will be discussed in Work with balanced circuits.
SLiCAP output dispalyed on this manual page, is generated with the script: matrix.py, imported by Manual.py.
1#!/usr/bin/env python3
2# -*- coding: utf-8 -*-
3
4"""
5matrix.py: SLiCAP scripts for the HTML help file
6"""
7import SLiCAP as sl
Obtain the matrix equation of the circuit
9# Create a circuit object
10cir = sl.makeCircuit("sch/Transimpedance.slicap_sch")
11result = sl.doMatrix(cir)
12
13Iv = result.Iv # Vector with independent variables
14 # (independent sources)
15M = result.M # MNA matrix
16Dv = result.Dv # Vector with dependent variables
17 # (unknown nodal voltages and branch currents)
18print(Iv)
19print(M)
20print(Dv)
The result is shown below:
Matrix([[0], [I_s], [0]])
Matrix([[0, 1, 0], [0, C_s*s + 1/R_t, -1/R_t], [1, -1/R_t, 1/R_t]])
Matrix([[I_N1], [V_1], [V_out]])
Naming of the dependent variables
Nodal voltages are named as V_<node_name>, where node_name is the name of the node.
Branch currents are named as I_<ref_des>, where ref_des is the reference designator of the branch element.
Reactive elements and the time-constant matrix
With method="tc", doMatrix() returns the first-order MNA matrix
\(\mathbf{M} = \mathbf{G} + s\mathbf{C}\), in which controlled sources
with a Laplace rational transfer are expanded into integrator chains, as with
method="state". In addition it returns the reactive elements of the
network:
.Nr: the incidence matrix of the reactive elements, one column per reactance and one row per network variable: the incidence vector of a capacitor (\(+1\) at its first node, \(-1\) at its second), the unit vector of the current of an inductor, and the unit vector of an integrator variable of an expanded controlled source;.Cr: the matrix of their values: \(C\) for a capacitor, \(-L\) for an inductor, \(-M\) off the diagonal for a mutual inductance, and \(1\) for an integrator variable;.reactances: the names of the columns: the reference designators of the capacitors and the inductors, then the names of the integrator variables, each in netlist order.
The coefficient matrix of \(s\) is \(\mathbf{C} = \mathbf{N}_\mathrm{r}\mathbf{C}_\mathrm{r}\mathbf{N}_\mathrm{r}^T\), and the time-constant matrix follows as \(\mathbf{T}_\mathrm{r} = \mathbf{N}_\mathrm{r}^T\mathbf{G}^{-1}\mathbf{N}_\mathrm{r}\mathbf{C}_\mathrm{r}\) when \(\mathbf{G}\) is invertible:
import SLiCAP as sl
import sympy as sp
s = sl.ini.laplace
res = sl.doMatrix(cir, method="tc")
G, C = res.M.subs(s, 0), res.M.diff(s)
Rr = res.Nr.T * G.inv() * res.Nr # resistance matrix
Tr = Rr * res.Cr # time-constant matrix
The entries of .Cr for integrator variables have no physical meaning:
the time constants of an expanded transfer are in the coefficients of its
chain. method="tc" is only available for doMatrix(), without a
conversion type and without stepping. A network with an improper transfer
(numerator order above denominator order) has no first-order form: then
.Nr, .Cr and .reactances are None.
Display the matrix equation on HTML pages and in LaTeX documents
With the aid of the report module Creating reports, the matrix equation can be displayed on HTML pages or in LaTeX documents.
Below the script for generating the rst snippet for this help file.
22# Generate RST snippets for the Help file
23rst = sl.RSTformatter()
24
25rst.matrixEqn(Iv, M, Dv).save("eqn-matrix-trimp")
The result is shown below.