From 507fe32308422ef9edb0ec29f6cae3ac12ca33da Mon Sep 17 00:00:00 2001 From: hschnait Date: Tue, 8 Mar 2022 18:50:17 +0100 Subject: [PATCH] Update Unit-Tests to new gfstruct --- test/python/analyse_block_structure_from_gf2.py | 8 ++++---- test/python/basis_transformation.py | 3 ++- test/python/blockstructure.py | 14 ++++++-------- 3 files changed, 12 insertions(+), 13 deletions(-) diff --git a/test/python/analyse_block_structure_from_gf2.py b/test/python/analyse_block_structure_from_gf2.py index 25806815..c0faeb06 100644 --- a/test/python/analyse_block_structure_from_gf2.py +++ b/test/python/analyse_block_structure_from_gf2.py @@ -54,11 +54,11 @@ SK.symm_deg_gf(G_new_symm, 0) assert_block_gfs_are_close(G_new[0], G_new_symm) -assert SK.gf_struct_sumk == [[('ud', [0, 1, 2, 3, 4, 5, 6, 7, 8, 9])], [('ud', [0, 1, 2, 3, 4, 5, 6, 7, 8, 9])]],\ +assert SK.gf_struct_sumk == [[('ud', 10)], [('ud', 10)]],\ "wrong gf_struct_sumk" for i in range(5): assert 'ud_{}'.format(i) in SK.gf_struct_solver[0], "missing block" - assert SK.gf_struct_solver[0]['ud_{}'.format(i)] == list(range(2)), "wrong block size" + assert SK.gf_struct_solver[0]['ud_{}'.format(i)] == 2, "wrong block size" for i in range(10): assert SK.sumk_to_solver[0]['ud',i] == ('ud_{}'.format(i//2), i%2), "wrong mapping" @@ -98,11 +98,11 @@ G_new_symm = G_new[0].copy() SK.symm_deg_gf(G_new_symm, 0) assert_block_gfs_are_close(G_new[0], G_new_symm) -assert SK.gf_struct_sumk == [[('ud', [0, 1, 2, 3, 4, 5, 6, 7, 8, 9])], [('ud', [0, 1, 2, 3, 4, 5, 6, 7, 8, 9])]],\ +assert SK.gf_struct_sumk == [[('ud', 10)], [('ud', 10)]],\ "wrong gf_struct_sumk" for i in range(5): assert 'ud_{}'.format(i) in SK.gf_struct_solver[0], "missing block" - assert SK.gf_struct_solver[0]['ud_{}'.format(i)] == list(range(2)), "wrong block size" + assert SK.gf_struct_solver[0]['ud_{}'.format(i)] == 2, "wrong block size" for i in range(10): assert SK.sumk_to_solver[0]['ud',i] == ('ud_{}'.format(i//2), i%2), "wrong mapping" diff --git a/test/python/basis_transformation.py b/test/python/basis_transformation.py index 6905cdf5..a180b999 100644 --- a/test/python/basis_transformation.py +++ b/test/python/basis_transformation.py @@ -1,3 +1,4 @@ +from tkinter import W from triqs.utility.comparison_tests import * from triqs_dft_tools.sumk_dft import * import numpy as np @@ -92,7 +93,7 @@ BS.transformation = [{'up':np.array([[1,0,0],[0,1/np.sqrt(2),1/np.sqrt(2)],[0,1/ H3 = BS.convert_operator(h_int_slater(spin_names=['up','down'], orb_names=[0,1,2], U_matrix=U3x3, off_diag=True)) for op in H3: for c_op in op[0]: - assert(BS.gf_struct_solver_dict[0][c_op[1][0]][c_op[1][1]] is not None) # This crashes with a key error if the operator structure is not the solver structure + assert(BS.solver_to_sumk[0][(c_op[1][0], c_op[1][1])] is not None) # This crashes with a key error if the operator structure is not the solver structure U_trafod = transform_U_matrix(U3x3, BS.transformation[0]['up'].conjugate()) # The notorious .conjugate() H4 = h_int_slater(spin_names=['up','down'], orb_names=range(3), U_matrix=U_trafod, map_operator_structure=BS.sumk_to_solver[0]) diff --git a/test/python/blockstructure.py b/test/python/blockstructure.py index ed34bfe3..d902f757 100644 --- a/test/python/blockstructure.py +++ b/test/python/blockstructure.py @@ -174,11 +174,9 @@ cmp(m2, # check full_structure full = BlockStructure.full_structure( - [{'up_0': [0, 1], 'up_1': [0], 'down_1': [0], 'down_0': [0, 1]}], None) + [{'up_0': 2, 'up_1': 1, 'down_1': 1, 'down_0': 2}], None) -print(original_bs.gf_struct_sumk[0]) -print(gf_struct_flatten(original_bs.gf_struct_sumk[0])) -G_sumk = BlockGf(mesh=G1.mesh, gf_struct=gf_struct_flatten(original_bs.gf_struct_sumk[0])) +G_sumk = BlockGf(mesh=G1.mesh, gf_struct=original_bs.gf_struct_sumk[0]) for i in range(3): G_sumk['up'][i, i] << SemiCircular(1 if i < 2 else 2) G_sumk['down'][i, i] << SemiCircular(4 if i < 2 else 3) @@ -204,13 +202,13 @@ G_bT = transformed_bs.convert_gf(G_T, None, space_from='sumk', assert_block_gfs_are_close(G1, G_bT) assert original_bs.gf_struct_sumk_list ==\ - [[('up', [0, 1, 2]), ('down', [0, 1, 2])]] + [[('up', 3), ('down', 3)]] assert original_bs.gf_struct_solver_dict ==\ - [{'up_0': [0, 1], 'up_1': [0], 'down_1': [0], 'down_0': [0, 1]}] + [{'up_0': 2, 'up_1': 1, 'down_1': 1, 'down_0': 2}] assert original_bs.gf_struct_sumk_dict ==\ - [{'down': [0, 1, 2], 'up': [0, 1, 2]}] + [{'down': 3, 'up': 3}] assert original_bs.gf_struct_solver_list ==\ - [[('down_0', [0, 1]), ('down_1', [0]), ('up_0', [0, 1]), ('up_1', [0])]] + [[('down_0', 2), ('down_1', 1), ('up_0', 2), ('up_1', 1)]] # check __eq__ assert full == full, 'equality not correct (equal structures not equal)'