Skip to content

Commit 5df4288

Browse files
committed
YMatrix: Add a simple validation of the GetCompressedYMatrix method.
1 parent f7e9c75 commit 5df4288

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

tests/validate.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
from __future__ import print_function
22
import os, sys
33
import numpy as np
4+
from scipy.sparse import csc_matrix
45

56
cd = os.getcwd()
67
no_properties = os.getenv('DSS_PYTHON_VALIDATE') == 'NOPROP'
@@ -752,6 +753,16 @@ def validate_Circuit(self):
752753
elif type(v[1]) == float:
753754
assert abs(v[0] - v[1]) < atol, (k, type(v[1]))
754755

756+
def validate_YMatrix(self):
757+
NN = self.capi.ActiveCircuit.NumNodes
758+
if NN > 2000: # test only on small strings
759+
return
760+
761+
ysparse = csc_matrix(self.capi.YMatrix.GetCompressedYMatrix(factor=False))
762+
ydense = self.capi.ActiveCircuit.SystemY.view(dtype=complex).reshape((NN, NN))
763+
assert (np.allclose(ydense, ysparse.todense(), atol=self.atol, rtol=self.rtol))
764+
765+
755766
def validate_all(self):
756767
self.rtol = 1e-5
757768

@@ -785,6 +796,8 @@ def validate_all(self):
785796
self.validate_Meters()
786797
# print('Reclosers')
787798
self.validate_Reclosers()
799+
# print('YMatrix')
800+
self.validate_YMatrix()
788801

789802
#self.atol = 1e-5
790803
# print('Buses')

0 commit comments

Comments
 (0)