@@ -19,15 +19,15 @@ def test_MIN_SR(node_type, quad_type, M):
1919
2020 # Check non-stiff limit
2121 QDelta = sweeper .get_Qdelta_implicit ('MIN-SR-NS' )[1 :, 1 :]
22- assert np .all (np .diag (np .diag (QDelta )) == QDelta ), "no diagonal QDelta "
22+ assert np .all (np .diag (np .diag (QDelta )) == QDelta ), "QDelta not diagonal "
2323 K = Q - QDelta
2424 Km = np .linalg .matrix_power (K , M )
2525 nilpotency = np .linalg .norm (Km , ord = np .inf )
2626 assert nilpotency < 1e-10 , "Q-QDelta not nilpotent " f"(M={ M } , norm={ nilpotency } )"
2727
2828 # Check stiff limit
2929 QDelta = sweeper .get_Qdelta_implicit ('MIN-SR-S' )[1 :, 1 :]
30- assert np .all (np .diag (np .diag (QDelta )) == QDelta ), "no diagonal QDelta "
30+ assert np .all (np .diag (np .diag (QDelta )) == QDelta ), "QDelta not diagonal "
3131
3232 if params ['quad_type' ] in ['LOBATTO' , 'RADAU-LEFT' ]:
3333 QDelta = np .diag (1 / np .diag (QDelta [1 :, 1 :]))
@@ -41,6 +41,38 @@ def test_MIN_SR(node_type, quad_type, M):
4141 assert nilpotency < 1e-10 , "I-QDelta^{-1}Q not nilpotent " f"(M={ M } , norm={ nilpotency } )"
4242
4343
44+ @pytest .mark .base
45+ @pytest .mark .parametrize ("node_type" , node_types )
46+ @pytest .mark .parametrize ("quad_type" , quad_types )
47+ @pytest .mark .parametrize ("M" , num_nodes )
48+ def test_MIN_SR_FLEX (node_type , quad_type , M ):
49+ params = {'num_nodes' : M , 'quad_type' : quad_type , 'node_type' : node_type }
50+ sweeper = Sweeper (params )
51+
52+ start_idx = 1
53+ for i in range (M ):
54+ if sweeper .coll .nodes [i ] == 0 :
55+ start_idx += 1
56+ else :
57+ break
58+
59+ Q = sweeper .coll .Qmat [start_idx :, start_idx :]
60+
61+ QDelta = [sweeper .get_Qdelta_implicit ('MIN-SR-FLEX' , k = i + 1 )[start_idx :, start_idx :] for i in range (M )]
62+ for QD in QDelta :
63+ assert np .all (np .diag (np .diag (QD )) == QD ), "QDelta not diagonal"
64+
65+ I = np .eye (M + 1 - start_idx )
66+ K = np .eye (M + 1 - start_idx )
67+ for QD in QDelta :
68+ K = (I - np .linalg .inv (QD ) @ Q ) @ K
69+
70+ nilpotency = np .linalg .norm (K , ord = np .inf )
71+ assert (
72+ nilpotency < 1e-10
73+ ), f"Applying FLEX preconditioner does not give nilpotent SDC iteration matrix after { M } iterations! (M={ M } , norm={ nilpotency } )"
74+
75+
4476@pytest .mark .base
4577@pytest .mark .parametrize ("node_type" , node_types )
4678@pytest .mark .parametrize ("quad_type" , quad_types )
@@ -122,6 +154,8 @@ def test_PIC(node_type, quad_type, M):
122154
123155
124156if __name__ == '__main__' :
157+ test_MIN_SR_FLEX ('LEGENDRE' , 'LOBATTO' , 4 )
158+
125159 test_MIN_SR ('LEGENDRE' , 'RADAU-RIGHT' , 4 )
126160 test_MIN_SR ('EQUID' , 'LOBATTO' , 5 )
127161
0 commit comments