MSP Simulation Example

System decoupling based on Diakoptics

Sample Circuit

Determine mesh currents for the circuit and apply the method of Diakoptics by removing the branches $Z_7$ and $Z_8$

$z_1$=$1 \Omega$, $z_2$=$1 \Omega$, $z_3$=$1 \Omega$, $z_4$=$1 \Omega$, $z_5$=$1 \Omega$, $z_7$=$1 \Omega$
$z_2$=$1 \Omega$, $z_8$=$1 \Omega$
$E_1$=$20 V$, $E_2$=$3 V$, $E_3$=$5 V$, $E_4$=$-5 V$

Circuit and Simulation Setup

In [1]:
import numpy as np
import matplotlib.pyplot as plt
np.set_printoptions(sign=' ')

# Circuit parameters:
z1 =1.0
z2 = 1.0
z3=1.0
z4 = 1.0
z5 = 1.0
z6 = 2.0
z7 = 1.0
z8 = 2.0

E1 = 15.0 
E2=3.0
E3=5.0
E4=-5.0

Standard mesh current analysis

In [2]:
E_orgn = np.array([ [E1],
                 [E2],
                 [E3],
                 [E4]])

Z_orgn = np.array([[(z1+z3+z7), -z3, -z7, 0],
                 [-z3, (z3+z5+z8), 0, -z8],
                 [-z7, 0, (z2+z4+z7), -z4],
                 [0, -z8, -z4, (z4+z6+z8)]])

# Mesh currents:
i_orgn = np.matmul(np.linalg.inv(Z_orgn),E_orgn)

print('Impedance matrix: \n' + str(Z_orgn))
print('\nProblem size: 4x4')
print('\nMesh currents: \n' + str(i_orgn))
Impedance matrix: 
[[ 3. -1. -1.  0.]
 [-1.  4.  0. -2.]
 [-1.  0.  3. -1.]
 [ 0. -2. -1.  5.]]

Problem size: 4x4

Mesh currents: 
[[ 7.63265306]
 [ 3.2755102 ]
 [ 4.62244898]
 [ 1.23469388]]

Diakoptics

Equivalent network

Removed network

In [3]:
# Removed branches
y7 = 1/z7
y8 = 1/z8
Y = np.array([ [y7, 0],
             [ 0, y8]])

# Connection matrix
C = np.array([ [-1, 0, 1, 0],
             [ 0, 1, 0, -1]])

# Impedance matrix for subsystem 1
Z11 = np.array([[(z1+z3), -z3],
                 [-z3, (z3+z5)]])

# Impedance matrix for subsystem 2
Z22 = np.array([[(z2+z4), -z4],
                 [-z4, (z4+z6)]])

# Block-diagonal impedance matrix of the equivalent network
Z = np.block([[Z11,            np.zeros((2, 2))],
            [np.zeros((2, 2)),      Z22]])

E = np.array([[E1],
             [E2],
             [E3],
             [E4]])

Circuit solution

In [4]:
print('\nBlock-diagonal impedance matrix of the equivalent network: \n' + str(Z))

# Matrix inverse of impedance matrix of the equivalent network
# The matrix is block-diagonal - we can invert 2 blocks of the size 2x2 independently
Z_inv = np.block([[np.linalg.inv(Z11),            np.zeros((2, 2))],
            [np.zeros((2, 2)),      np.linalg.inv(Z22)]])

print('\nMatrix inversion of the block diagnoal matrix: \n' + str(Z_inv))

# This matrix must be inverted, the size is 2x2
Y_psi = Y + np.matmul(C, np.matmul(Z_inv,C.transpose())) 
Y_psi_inv = np.linalg.inv(Y_psi)

# Solution obtained based on the method of diakoptics
i_diak= np.dot(Z_inv,E) - np.matmul( np.matmul(np.matmul(Z_inv,C.transpose()) , np.matmul(Y_psi_inv,C)) , np.matmul(Z_inv,E))    

print('\nMesh currents obtained based on diakoptics: \n' + str(i_diak))
print('\nMesh currents obtained based on standard meshed current analysis: \n' + str(i_diak))
Block-diagonal impedance matrix of the equivalent network: 
[[ 2. -1.  0.  0.]
 [-1.  2.  0.  0.]
 [ 0.  0.  2. -1.]
 [ 0.  0. -1.  3.]]

Matrix inversion of the block diagnoal matrix: 
[[ 0.66666667  0.33333333  0.          0.        ]
 [ 0.33333333  0.66666667  0.          0.        ]
 [ 0.          0.          0.6         0.2       ]
 [ 0.          0.          0.2         0.4       ]]

Mesh currents obtained based on diakoptics: 
[[ 7.63265306]
 [ 3.2755102 ]
 [ 4.62244898]
 [ 1.23469388]]

Mesh currents obtained based on standard meshed current analysis: 
[[ 7.63265306]
 [ 3.2755102 ]
 [ 4.62244898]
 [ 1.23469388]]

The solution obtained by the method of diakoptics is an exact solution of original problem.

Computational effort:
Standard solution requires 1 matrix inversion of matrix size 4x4.
Solution based on diakoptics requires 3 matrix inversions of matrix size 2x2.
If we assume that matrix inversion scales with the cube of the matrix size, the following is valid:
$3*2^3 < 4^3$