Skip to content

Commit

Permalink
Update Unit-Tests to new gfstruct
Browse files Browse the repository at this point in the history
  • Loading branch information
hschnait committed Mar 8, 2022
1 parent c2a53ab commit 507fe32
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 13 deletions.
8 changes: 4 additions & 4 deletions test/python/analyse_block_structure_from_gf2.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,11 +54,11 @@ def get_random_transformation(dim):
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"

Expand Down Expand Up @@ -98,11 +98,11 @@ def get_delta_from_mesh(mesh):
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"

Expand Down
3 changes: 2 additions & 1 deletion test/python/basis_transformation.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -92,7 +93,7 @@ def call_diagonalize(SK):
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])
Expand Down
14 changes: 6 additions & 8 deletions test/python/blockstructure.py
Original file line number Diff line number Diff line change
Expand Up @@ -174,11 +174,9 @@ def cmp(a, b, precision=1.e-15):

# 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)
Expand All @@ -204,13 +202,13 @@ def cmp(a, b, precision=1.e-15):
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)'
Expand Down

0 comments on commit 507fe32

Please sign in to comment.