3
0
mirror of https://github.com/triqs/dft_tools synced 2024-12-23 04:43:42 +01:00

remove gf_struct_flatten function and replace with triqs version

This commit is contained in:
Alexander Hampel 2022-03-09 09:15:10 -05:00
parent d28fe3c1ef
commit 320b2d2dfd
5 changed files with 57 additions and 99 deletions

View File

@ -23,11 +23,11 @@ DFTTools Version 3.1.0 is a release that
* bugfix: This fix makes the function find_rot_mat() safer to use in case there are errors in finding the correct mapping. The converter will now abort if the agreement in mapping is below a user-definable threshold. * bugfix: This fix makes the function find_rot_mat() safer to use in case there are errors in finding the correct mapping. The converter will now abort if the agreement in mapping is below a user-definable threshold.
### Change in gf_struct ### Change in gf_struct
* In line with TRIQS 3.1.x, the form of the Green's function's structure (`gf_struct`) has been modified * In line with TRIQS 3.1.x, the form of the Green's function's structure (`gf_struct`) has been modified (see [triqs changelog](https://triqs.github.io/triqs/latest/ChangeLog.html#change-in-gf-struct-objects) for more information)
* Instead of `gf_struct = [("up", [0, 1]), ("down", [0, 1])]`, the new convention uses `gf_struct = [("up", 2), ("down", 2)]` * Instead of `gf_struct = [("up", [0, 1]), ("down", [0, 1])]`, the new convention uses `gf_struct = [("up", 2), ("down", 2)]`
* This modifies the form of `gf_struct_solver` (and `sumk`) in `block_structure` and `SumkDFT` as well. * This modifies the form of `gf_struct_solver` (and `sumk`) in `block_structure` and `SumkDFT` as well.
* Backwards-compatibility with old, stored `block_structure` objects is given, however a warning is issued. * Backwards-compatibility with old, stored `block_structure` objects is given, however a warning is issued.
* A helper-function `block_structure.gf_struct_flatten(...)` is provided to manually bring `gf_struct`s to the new form. * A helper-function `triqs.gf.block_gf.fix_gf_struct_type(gf_struct_old)` is provided in triqs to manually bring `gf_struct`s to the new form.
### Documentation ### Documentation
* change to read the docs sphinx theme * change to read the docs sphinx theme

View File

@ -6,7 +6,6 @@ from triqs.gf import *
import sys, triqs.version as triqs_version import sys, triqs.version as triqs_version
from triqs_dft_tools.sumk_dft import * from triqs_dft_tools.sumk_dft import *
from triqs_dft_tools.sumk_dft_tools import * from triqs_dft_tools.sumk_dft_tools import *
from triqs_dft_tools.block_structure import gf_struct_flatten
from triqs.operators.util.hamiltonians import * from triqs.operators.util.hamiltonians import *
from triqs.operators.util.U_matrix import * from triqs.operators.util.U_matrix import *
from triqs_cthyb import * from triqs_cthyb import *
@ -41,7 +40,7 @@ spin_names = ['up','down']
orb_names = [i for i in range(0,n_orb)] orb_names = [i for i in range(0,n_orb)]
#gf_struct = set_operator_structure(spin_names, orb_names, orb_hyb) #gf_struct = set_operator_structure(spin_names, orb_names, orb_hyb)
gf_struct = gf_struct_flatten(SK.gf_struct_solver[0]) gf_struct = SK.gf_struct_solver_list[0]
mpi.report('Sumk to Solver: %s'%SK.sumk_to_solver) mpi.report('Sumk to Solver: %s'%SK.sumk_to_solver)
mpi.report('GF struct sumk: %s'%SK.gf_struct_sumk) mpi.report('GF struct sumk: %s'%SK.gf_struct_sumk)
mpi.report('GF struct solver: %s'%SK.gf_struct_solver) mpi.report('GF struct solver: %s'%SK.gf_struct_solver)

View File

@ -6,7 +6,6 @@ from triqs.gf import *
import sys, triqs.version as triqs_version import sys, triqs.version as triqs_version
from triqs_dft_tools.sumk_dft import * from triqs_dft_tools.sumk_dft import *
from triqs_dft_tools.sumk_dft_tools import * from triqs_dft_tools.sumk_dft_tools import *
from triqs_dft_tools.block_structure import gf_struct_flatten
from triqs.operators.util.hamiltonians import * from triqs.operators.util.hamiltonians import *
from triqs.operators.util.U_matrix import * from triqs.operators.util.U_matrix import *
from triqs_cthyb import * from triqs_cthyb import *
@ -48,7 +47,7 @@ def dmft_cycle():
orb_names = [i for i in range(0,n_orb)] orb_names = [i for i in range(0,n_orb)]
#gf_struct = set_operator_structure(spin_names, orb_names, orb_hyb) #gf_struct = set_operator_structure(spin_names, orb_names, orb_hyb)
gf_struct = SK.gf_struct_solver[0] gf_struct = SK.gf_struct_solver_list[0]
mpi.report('Sumk to Solver: %s'%SK.sumk_to_solver) mpi.report('Sumk to Solver: %s'%SK.sumk_to_solver)
mpi.report('GF struct sumk: %s'%SK.gf_struct_sumk) mpi.report('GF struct sumk: %s'%SK.gf_struct_sumk)
mpi.report('GF struct solver: %s'%SK.gf_struct_solver) mpi.report('GF struct solver: %s'%SK.gf_struct_solver)

View File

@ -1190,45 +1190,5 @@ class BlockStructure(object):
s += str(self.transformation) s += str(self.transformation)
return s return s
def gf_struct_flatten(gf_struct):
'''
flattens gf_struct objecti
input gf_struct can looks like this:
[('up', [0, 1, 2]), ('down', [0, 1, 2])]
and will be returned as
[('up', 3), ('down', 3)]
Same for dict but replacing the values. This is for compatibility with the upcoming triqs releases.
Parameters
----------
gf_struct: list of tuple or dict representing the Gf structure
__Returns:__
gf_struct_flat: flattens the values of the dict or the tuple representing the Gf indices by replacing them with the len of the list of indices
'''
if isinstance(gf_struct, list):
# create a copy of the original list
gf_struct_flat = gf_struct.copy()
for idx, block in enumerate(gf_struct_flat):
# exchange list of indices with length of list
gf_struct_flat[idx] = (block[0], len(block[1]))
elif isinstance(gf_struct, dict):
# create a copy of the original dict
gf_struct_flat = dict(gf_struct)
for key, value in gf_struct_flat.items():
# exchange list of indices with length of list
gf_struct_flat[key] = len(value)
else:
raise Exception('gf_struct input needs to be list or dict')
return gf_struct_flat
from h5.formats import register_class from h5.formats import register_class
register_class(BlockStructure) register_class(BlockStructure)

View File

@ -3,7 +3,7 @@ from triqs.utility.h5diff import h5diff, compare, failures
from triqs.gf import * from triqs.gf import *
from triqs.utility.comparison_tests import assert_block_gfs_are_close from triqs.utility.comparison_tests import assert_block_gfs_are_close
from scipy.linalg import expm from scipy.linalg import expm
from triqs_dft_tools.block_structure import BlockStructure, gf_struct_flatten from triqs_dft_tools.block_structure import BlockStructure
import numpy as np import numpy as np