To get the impedance profile for a circuit, I am using its admittance (G) and capacitance (C) matrices.
I am using Python to compute impedance profile at different frequencies but the issue is that I need to invert the matrix to get impedance from admittance and this turns out to be a very expensive operation in a loop.
For a large matrix (1000*1000) I have, inverting a matrix using numpy.linalg.inv
needs approx 1 second and therefore for a loop running 10^6 iterations below, I get unreasonably large execution time.
Need some guidance on ways to optimise this or if there's anyway to bypass matrix inversion and yet get the impedance matrix.
My code is like the code below:
A = j*2*3.14*C #j 2pi C to create susceptance matrix when multiplied by freq below.
for freq in range (1, 100000000, 100):
Y = G + A * freq #admittance matrix
Z = np.linalg.inv(Y) #inverse the matrix to get impedance matrix
output[freq] = Z
I have already tried numpy.linalg.solve
instead of using inversion. But the execution time remains unreasonably large.