Bholu
Bholu

Reputation: 17

How to add Cross-diagonal elements matrix in python?

I have a capacitance matrices and I am having some trouble creating the off diagonal elements fro this matrix (the cross_off_diagonal especially Cg part of the matrix).

def capacitance_matrix_inv_sqrt(Cg, Cc, Cja, N):
  diagonal = np.ones(N) * (2 * Cja + Cg)
  diagonal[0] = Cja + Cg + Cc  # Special condition for the first element
  diagonal[-1] = Cja + Cg + Cc
  off_diagonal = np.ones(N - 1) * (-Cja)
  # Construct the capacitance matrix
  C = np.diag(diagonal) + np.diag(off_diagonal, k=1) + np.diag(off_diagonal, k=-1)    
  return C

I have attached a snapshot of the matrices, which I would like to create, sorry I do not know how to show them here.enter image description here

Upvotes: 0

Views: 27

Answers (0)

Related Questions