Skip to content

Commit

Permalink
method conductance_matrix() updated to handle CCCSs
Browse files Browse the repository at this point in the history
  • Loading branch information
giaccone committed Aug 6, 2018
1 parent a919782 commit b12454d
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions netlist.py
Original file line number Diff line number Diff line change
Expand Up @@ -486,6 +486,7 @@ def conductance_matrix(self):
indexL = sorted(self.isort[1])
indexV = sorted(self.isort[3])
indexE = sorted(self.isort[5])
indexF = sorted(self.isort[6])

# cycle on resistances
for ir in indexR:
Expand Down Expand Up @@ -695,6 +696,32 @@ def conductance_matrix(self):
g_row.append(self.node_num + len(indexL) + len(indexV) + k)
g_col.append(N2 - 1)

# cycle on CCCSs
for k, indF in enumerate(indexF):
# get nodes
N1, N2 = self.nodes[indF]
# get Vsens and its index
Vsens = self.control_source[self.names[indF]]
h = sorted(self.isort[3]).index(self.names.index(Vsens))
n = self.node_num + h

if N1 == 0: # if grounded to N1 ...
g.append(-self.values[indF])
g_row.append(N2 - 1)
g_col.append(n)
elif N2 == 0: # if grounded to N2 ...
g.append(self.values[indF])
g_row.append(N1 - 1)
g_col.append(n)
else: # if not grounded ...
g.append(self.values[indF])
g_row.append(N1 - 1)
g_col.append(n)
#
g.append(-self.values[indF])
g_row.append(N2 - 1)
g_col.append(n)

# create conductance matrix
self.G = csr_matrix((g,(g_row,g_col)))

Expand Down

0 comments on commit b12454d

Please sign in to comment.