mirror of
https://github.com/triqs/dft_tools
synced 2024-09-12 05:38:31 +02:00
Merge pull request #208 from hschnait/new_gf_struct
Modify gf_struct to be in line with triqs/3.1.x
This commit is contained in:
commit
d6e04091b0
@ -22,6 +22,13 @@ DFTTools Version 3.1.0 is a release that
|
|||||||
* update documentation of W90 Converter
|
* update documentation of W90 Converter
|
||||||
* 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
|
||||||
|
* 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)]`
|
||||||
|
* 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.
|
||||||
|
* 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
|
||||||
* clean up various doc files
|
* clean up various doc files
|
||||||
|
@ -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 *
|
||||||
@ -20,8 +19,8 @@ filename = 'nio'
|
|||||||
|
|
||||||
SK = SumkDFT(hdf_file = filename+'.h5', use_dft_blocks = False)
|
SK = SumkDFT(hdf_file = filename+'.h5', use_dft_blocks = False)
|
||||||
|
|
||||||
beta = 5.0
|
beta = 5.0
|
||||||
|
|
||||||
Sigma = SK.block_structure.create_gf(beta=beta)
|
Sigma = SK.block_structure.create_gf(beta=beta)
|
||||||
SK.put_Sigma([Sigma])
|
SK.put_Sigma([Sigma])
|
||||||
G = SK.extract_G_loc()
|
G = SK.extract_G_loc()
|
||||||
@ -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)
|
||||||
@ -49,7 +48,7 @@ mpi.report('GF struct solver: %s'%SK.gf_struct_solver)
|
|||||||
S = Solver(beta=beta, gf_struct=gf_struct)
|
S = Solver(beta=beta, gf_struct=gf_struct)
|
||||||
|
|
||||||
# Construct the Hamiltonian and save it in Hamiltonian_store.txt
|
# Construct the Hamiltonian and save it in Hamiltonian_store.txt
|
||||||
H = Operator()
|
H = Operator()
|
||||||
U = 8.0
|
U = 8.0
|
||||||
J = 1.0
|
J = 1.0
|
||||||
|
|
||||||
@ -130,14 +129,14 @@ mpi.report('%s DMFT cycles requested. Starting with iteration %s.'%(n_iterations
|
|||||||
|
|
||||||
# The infamous DMFT self consistency cycle
|
# The infamous DMFT self consistency cycle
|
||||||
for it in range(iteration_offset, iteration_offset + n_iterations):
|
for it in range(iteration_offset, iteration_offset + n_iterations):
|
||||||
|
|
||||||
mpi.report('Doing iteration: %s'%it)
|
mpi.report('Doing iteration: %s'%it)
|
||||||
|
|
||||||
# Get G0
|
# Get G0
|
||||||
S.G0_iw << inverse(S.Sigma_iw + inverse(S.G_iw))
|
S.G0_iw << inverse(S.Sigma_iw + inverse(S.G_iw))
|
||||||
# Solve the impurity problem
|
# Solve the impurity problem
|
||||||
S.solve(h_int = H, **p)
|
S.solve(h_int = H, **p)
|
||||||
if mpi.is_master_node():
|
if mpi.is_master_node():
|
||||||
ar['DMFT_input']['Iterations']['solver_dict_it'+str(it)] = p
|
ar['DMFT_input']['Iterations']['solver_dict_it'+str(it)] = p
|
||||||
ar['DMFT_results']['Iterations']['Gimp_it'+str(it)] = S.G_iw
|
ar['DMFT_results']['Iterations']['Gimp_it'+str(it)] = S.G_iw
|
||||||
ar['DMFT_results']['Iterations']['Gtau_it'+str(it)] = S.G_tau
|
ar['DMFT_results']['Iterations']['Gtau_it'+str(it)] = S.G_tau
|
||||||
@ -150,13 +149,13 @@ for it in range(iteration_offset, iteration_offset + n_iterations):
|
|||||||
SK.put_Sigma(Sigma_imp=[S.Sigma_iw])
|
SK.put_Sigma(Sigma_imp=[S.Sigma_iw])
|
||||||
SK.calc_mu(precision=0.01)
|
SK.calc_mu(precision=0.01)
|
||||||
S.G_iw << SK.extract_G_loc()[0]
|
S.G_iw << SK.extract_G_loc()[0]
|
||||||
|
|
||||||
# print densities
|
# print densities
|
||||||
for sig,gf in S.G_iw:
|
for sig,gf in S.G_iw:
|
||||||
mpi.report("Orbital %s density: %.6f"%(sig,dm[sig][0,0]))
|
mpi.report("Orbital %s density: %.6f"%(sig,dm[sig][0,0]))
|
||||||
mpi.report('Total charge of Gloc : %.6f'%S.G_iw.total_density())
|
mpi.report('Total charge of Gloc : %.6f'%S.G_iw.total_density())
|
||||||
|
|
||||||
if mpi.is_master_node():
|
if mpi.is_master_node():
|
||||||
ar['DMFT_results']['iteration_count'] = it
|
ar['DMFT_results']['iteration_count'] = it
|
||||||
ar['DMFT_results']['Iterations']['Sigma_it'+str(it)] = S.Sigma_iw
|
ar['DMFT_results']['Iterations']['Sigma_it'+str(it)] = S.Sigma_iw
|
||||||
ar['DMFT_results']['Iterations']['Gloc_it'+str(it)] = S.G_iw
|
ar['DMFT_results']['Iterations']['Gloc_it'+str(it)] = S.G_iw
|
||||||
|
@ -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 *
|
||||||
@ -21,14 +20,14 @@ warnings.filterwarnings("ignore", category=FutureWarning)
|
|||||||
|
|
||||||
def dmft_cycle():
|
def dmft_cycle():
|
||||||
filename = 'nio'
|
filename = 'nio'
|
||||||
|
|
||||||
Converter = VaspConverter(filename=filename)
|
Converter = VaspConverter(filename=filename)
|
||||||
Converter.convert_dft_input()
|
Converter.convert_dft_input()
|
||||||
|
|
||||||
SK = SumkDFT(hdf_file = filename+'.h5', use_dft_blocks = False)
|
SK = SumkDFT(hdf_file = filename+'.h5', use_dft_blocks = False)
|
||||||
|
|
||||||
beta = 5.0
|
beta = 5.0
|
||||||
|
|
||||||
Sigma = SK.block_structure.create_gf(beta=beta)
|
Sigma = SK.block_structure.create_gf(beta=beta)
|
||||||
SK.put_Sigma([Sigma])
|
SK.put_Sigma([Sigma])
|
||||||
G = SK.extract_G_loc()
|
G = SK.extract_G_loc()
|
||||||
@ -40,38 +39,38 @@ def dmft_cycle():
|
|||||||
mpi.report('block {0:d} consists of orbitals:'.format(iblock))
|
mpi.report('block {0:d} consists of orbitals:'.format(iblock))
|
||||||
for keys in list(SK.deg_shells[i_sh][iblock].keys()):
|
for keys in list(SK.deg_shells[i_sh][iblock].keys()):
|
||||||
mpi.report(' '+keys)
|
mpi.report(' '+keys)
|
||||||
|
|
||||||
# Setup CTQMC Solver
|
# Setup CTQMC Solver
|
||||||
|
|
||||||
n_orb = SK.corr_shells[0]['dim']
|
n_orb = SK.corr_shells[0]['dim']
|
||||||
spin_names = ['up','down']
|
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 = 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)
|
||||||
|
|
||||||
S = Solver(beta=beta, gf_struct=gf_struct)
|
S = Solver(beta=beta, gf_struct=gf_struct)
|
||||||
|
|
||||||
# Construct the Hamiltonian and save it in Hamiltonian_store.txt
|
# Construct the Hamiltonian and save it in Hamiltonian_store.txt
|
||||||
H = Operator()
|
H = Operator()
|
||||||
U = 8.0
|
U = 8.0
|
||||||
J = 1.0
|
J = 1.0
|
||||||
|
|
||||||
|
|
||||||
U_sph = U_matrix(l=2, U_int=U, J_hund=J)
|
U_sph = U_matrix(l=2, U_int=U, J_hund=J)
|
||||||
U_cubic = transform_U_matrix(U_sph, spherical_to_cubic(l=2, convention=''))
|
U_cubic = transform_U_matrix(U_sph, spherical_to_cubic(l=2, convention=''))
|
||||||
Umat, Upmat = reduce_4index_to_2index(U_cubic)
|
Umat, Upmat = reduce_4index_to_2index(U_cubic)
|
||||||
|
|
||||||
H = h_int_density(spin_names, orb_names, map_operator_structure=SK.sumk_to_solver[0], U=Umat, Uprime=Upmat)
|
H = h_int_density(spin_names, orb_names, map_operator_structure=SK.sumk_to_solver[0], U=Umat, Uprime=Upmat)
|
||||||
|
|
||||||
# Print some information on the master node
|
# Print some information on the master node
|
||||||
mpi.report('Greens function structure is: %s '%gf_struct)
|
mpi.report('Greens function structure is: %s '%gf_struct)
|
||||||
mpi.report('U Matrix set to:\n%s'%Umat)
|
mpi.report('U Matrix set to:\n%s'%Umat)
|
||||||
mpi.report('Up Matrix set to:\n%s'%Upmat)
|
mpi.report('Up Matrix set to:\n%s'%Upmat)
|
||||||
|
|
||||||
# Parameters for the CTQMC Solver
|
# Parameters for the CTQMC Solver
|
||||||
p = {}
|
p = {}
|
||||||
p["max_time"] = -1
|
p["max_time"] = -1
|
||||||
@ -84,14 +83,14 @@ def dmft_cycle():
|
|||||||
p["fit_min_n"] = 30
|
p["fit_min_n"] = 30
|
||||||
p["fit_max_n"] = 50
|
p["fit_max_n"] = 50
|
||||||
p["perform_tail_fit"] = True
|
p["perform_tail_fit"] = True
|
||||||
|
|
||||||
# Double Counting: 0 FLL, 1 Held, 2 AMF
|
# Double Counting: 0 FLL, 1 Held, 2 AMF
|
||||||
DC_type = 0
|
DC_type = 0
|
||||||
DC_value = 59.0
|
DC_value = 59.0
|
||||||
|
|
||||||
# Prepare hdf file and and check for previous iterations
|
# Prepare hdf file and and check for previous iterations
|
||||||
n_iterations = 1
|
n_iterations = 1
|
||||||
|
|
||||||
iteration_offset = 0
|
iteration_offset = 0
|
||||||
if mpi.is_master_node():
|
if mpi.is_master_node():
|
||||||
ar = HDFArchive(filename+'.h5','a')
|
ar = HDFArchive(filename+'.h5','a')
|
||||||
@ -119,33 +118,33 @@ def dmft_cycle():
|
|||||||
SK.dc_imp = mpi.bcast(SK.dc_imp)
|
SK.dc_imp = mpi.bcast(SK.dc_imp)
|
||||||
SK.dc_energ = mpi.bcast(SK.dc_energ)
|
SK.dc_energ = mpi.bcast(SK.dc_energ)
|
||||||
SK.chemical_potential = mpi.bcast(SK.chemical_potential)
|
SK.chemical_potential = mpi.bcast(SK.chemical_potential)
|
||||||
|
|
||||||
# Calc the first G0
|
# Calc the first G0
|
||||||
SK.symm_deg_gf(S.Sigma_iw, ish=0)
|
SK.symm_deg_gf(S.Sigma_iw, ish=0)
|
||||||
SK.put_Sigma(Sigma_imp = [S.Sigma_iw])
|
SK.put_Sigma(Sigma_imp = [S.Sigma_iw])
|
||||||
SK.calc_mu(precision=0.01)
|
SK.calc_mu(precision=0.01)
|
||||||
S.G_iw << SK.extract_G_loc()[0]
|
S.G_iw << SK.extract_G_loc()[0]
|
||||||
SK.symm_deg_gf(S.G_iw, ish=0)
|
SK.symm_deg_gf(S.G_iw, ish=0)
|
||||||
|
|
||||||
#Init the DC term and the self-energy if no previous iteration was found
|
#Init the DC term and the self-energy if no previous iteration was found
|
||||||
if iteration_offset == 0:
|
if iteration_offset == 0:
|
||||||
dm = S.G_iw.density()
|
dm = S.G_iw.density()
|
||||||
SK.calc_dc(dm, U_interact=U, J_hund=J, orb=0, use_dc_formula=DC_type,use_dc_value=DC_value)
|
SK.calc_dc(dm, U_interact=U, J_hund=J, orb=0, use_dc_formula=DC_type,use_dc_value=DC_value)
|
||||||
S.Sigma_iw << SK.dc_imp[0]['up'][0,0]
|
S.Sigma_iw << SK.dc_imp[0]['up'][0,0]
|
||||||
|
|
||||||
mpi.report('%s DMFT cycles requested. Starting with iteration %s.'%(n_iterations,iteration_offset))
|
mpi.report('%s DMFT cycles requested. Starting with iteration %s.'%(n_iterations,iteration_offset))
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# The infamous DMFT self consistency cycle
|
# The infamous DMFT self consistency cycle
|
||||||
for it in range(iteration_offset, iteration_offset + n_iterations):
|
for it in range(iteration_offset, iteration_offset + n_iterations):
|
||||||
mpi.report('Doing iteration: %s'%it)
|
mpi.report('Doing iteration: %s'%it)
|
||||||
|
|
||||||
# Get G0
|
# Get G0
|
||||||
S.G0_iw << inverse(S.Sigma_iw + inverse(S.G_iw))
|
S.G0_iw << inverse(S.Sigma_iw + inverse(S.G_iw))
|
||||||
# Solve the impurity problem
|
# Solve the impurity problem
|
||||||
S.solve(h_int = H, **p)
|
S.solve(h_int = H, **p)
|
||||||
if mpi.is_master_node():
|
if mpi.is_master_node():
|
||||||
ar['DMFT_input']['Iterations']['solver_dict_it'+str(it)] = p
|
ar['DMFT_input']['Iterations']['solver_dict_it'+str(it)] = p
|
||||||
ar['DMFT_results']['Iterations']['Gimp_it'+str(it)] = S.G_iw
|
ar['DMFT_results']['Iterations']['Gimp_it'+str(it)] = S.G_iw
|
||||||
ar['DMFT_results']['Iterations']['Gtau_it'+str(it)] = S.G_tau
|
ar['DMFT_results']['Iterations']['Gtau_it'+str(it)] = S.G_tau
|
||||||
@ -158,13 +157,13 @@ def dmft_cycle():
|
|||||||
SK.put_Sigma(Sigma_imp=[S.Sigma_iw])
|
SK.put_Sigma(Sigma_imp=[S.Sigma_iw])
|
||||||
SK.calc_mu(precision=0.01)
|
SK.calc_mu(precision=0.01)
|
||||||
S.G_iw << SK.extract_G_loc()[0]
|
S.G_iw << SK.extract_G_loc()[0]
|
||||||
|
|
||||||
# print densities
|
# print densities
|
||||||
for sig,gf in S.G_iw:
|
for sig,gf in S.G_iw:
|
||||||
mpi.report("Orbital %s density: %.6f"%(sig,dm[sig][0,0]))
|
mpi.report("Orbital %s density: %.6f"%(sig,dm[sig][0,0]))
|
||||||
mpi.report('Total charge of Gloc : %.6f'%S.G_iw.total_density())
|
mpi.report('Total charge of Gloc : %.6f'%S.G_iw.total_density())
|
||||||
|
|
||||||
if mpi.is_master_node():
|
if mpi.is_master_node():
|
||||||
ar['DMFT_results']['iteration_count'] = it
|
ar['DMFT_results']['iteration_count'] = it
|
||||||
ar['DMFT_results']['Iterations']['Sigma_it'+str(it)] = S.Sigma_iw
|
ar['DMFT_results']['Iterations']['Sigma_it'+str(it)] = S.Sigma_iw
|
||||||
ar['DMFT_results']['Iterations']['Gloc_it'+str(it)] = S.G_iw
|
ar['DMFT_results']['Iterations']['Gloc_it'+str(it)] = S.G_iw
|
||||||
@ -172,31 +171,31 @@ def dmft_cycle():
|
|||||||
ar['DMFT_results']['Iterations']['dc_imp'+str(it)] = SK.dc_imp
|
ar['DMFT_results']['Iterations']['dc_imp'+str(it)] = SK.dc_imp
|
||||||
ar['DMFT_results']['Iterations']['dc_energ'+str(it)] = SK.dc_energ
|
ar['DMFT_results']['Iterations']['dc_energ'+str(it)] = SK.dc_energ
|
||||||
ar['DMFT_results']['Iterations']['chemical_potential'+str(it)] = SK.chemical_potential
|
ar['DMFT_results']['Iterations']['chemical_potential'+str(it)] = SK.chemical_potential
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if mpi.is_master_node():
|
if mpi.is_master_node():
|
||||||
print('calculating mu...')
|
print('calculating mu...')
|
||||||
SK.chemical_potential = SK.calc_mu( precision = 0.000001 )
|
SK.chemical_potential = SK.calc_mu( precision = 0.000001 )
|
||||||
|
|
||||||
if mpi.is_master_node():
|
if mpi.is_master_node():
|
||||||
print('calculating GAMMA')
|
print('calculating GAMMA')
|
||||||
SK.calc_density_correction(dm_type='vasp')
|
SK.calc_density_correction(dm_type='vasp')
|
||||||
|
|
||||||
if mpi.is_master_node():
|
if mpi.is_master_node():
|
||||||
print('calculating energy corrections')
|
print('calculating energy corrections')
|
||||||
|
|
||||||
correnerg = 0.5 * (S.G_iw * S.Sigma_iw).total_density()
|
correnerg = 0.5 * (S.G_iw * S.Sigma_iw).total_density()
|
||||||
|
|
||||||
dm = S.G_iw.density() # compute the density matrix of the impurity problem
|
dm = S.G_iw.density() # compute the density matrix of the impurity problem
|
||||||
SK.calc_dc(dm, U_interact=U, J_hund=J, orb=0, use_dc_formula=DC_type,use_dc_value=DC_value)
|
SK.calc_dc(dm, U_interact=U, J_hund=J, orb=0, use_dc_formula=DC_type,use_dc_value=DC_value)
|
||||||
dc_energ = SK.dc_energ[0]
|
dc_energ = SK.dc_energ[0]
|
||||||
|
|
||||||
if mpi.is_master_node():
|
if mpi.is_master_node():
|
||||||
ar['DMFT_results']['Iterations']['corr_energy_it'+str(it)] = correnerg
|
ar['DMFT_results']['Iterations']['corr_energy_it'+str(it)] = correnerg
|
||||||
ar['DMFT_results']['Iterations']['dc_energy_it'+str(it)] = dc_energ
|
ar['DMFT_results']['Iterations']['dc_energy_it'+str(it)] = dc_energ
|
||||||
|
|
||||||
if mpi.is_master_node(): del ar
|
if mpi.is_master_node(): del ar
|
||||||
|
|
||||||
return correnerg, dc_energ
|
return correnerg, dc_energ
|
||||||
|
@ -48,11 +48,11 @@ class BlockStructure(object):
|
|||||||
Parameters
|
Parameters
|
||||||
----------
|
----------
|
||||||
gf_struct_sumk : list of list of tuple
|
gf_struct_sumk : list of list of tuple
|
||||||
gf_struct_sumk[ish][idx] = (block_name,list of indices in block)
|
gf_struct_sumk[ish][idx] = (block_name, dimension of block)
|
||||||
|
|
||||||
for correlated shell ish; idx is just a counter in the list
|
for correlated shell ish; idx is just a counter in the list
|
||||||
gf_struct_solver : list of dict
|
gf_struct_solver : list of dict
|
||||||
gf_struct_solver[ish][block] = list of indices in that block
|
gf_struct_solver[ish][block] = dimension of that block
|
||||||
|
|
||||||
for *inequivalent* correlated shell ish
|
for *inequivalent* correlated shell ish
|
||||||
solver_to_sumk : list of dict
|
solver_to_sumk : list of dict
|
||||||
@ -120,8 +120,27 @@ class BlockStructure(object):
|
|||||||
deg_shells=None,
|
deg_shells=None,
|
||||||
corr_to_inequiv = None,
|
corr_to_inequiv = None,
|
||||||
transformation=None):
|
transformation=None):
|
||||||
|
|
||||||
|
# Ensure backwards-compatibility with pre-3.1.x gf_structs
|
||||||
|
show_gf_struct_warning = False
|
||||||
|
if gf_struct_sumk != None:
|
||||||
|
for gf_struct in gf_struct_sumk:
|
||||||
|
for i, block in enumerate(gf_struct):
|
||||||
|
if isinstance(block[1], (list, np.ndarray)):
|
||||||
|
gf_struct[i] = (block[0], len(block[1]))
|
||||||
|
show_gf_struct_warning = True
|
||||||
|
if gf_struct_solver != None:
|
||||||
|
for gf_struct in gf_struct_solver:
|
||||||
|
for block in gf_struct:
|
||||||
|
if isinstance(gf_struct[block], (list, np.ndarray)):
|
||||||
|
gf_struct[block] = len(gf_struct[block])
|
||||||
|
show_gf_struct_warning = True
|
||||||
|
if show_gf_struct_warning:
|
||||||
|
warn('Old (pre 3.1.x) form of gf_struct provided! The structure will be updated to the new convention!')
|
||||||
|
|
||||||
self.gf_struct_sumk = gf_struct_sumk
|
self.gf_struct_sumk = gf_struct_sumk
|
||||||
self.gf_struct_solver = gf_struct_solver
|
self.gf_struct_solver = gf_struct_solver
|
||||||
|
|
||||||
self.solver_to_sumk = solver_to_sumk
|
self.solver_to_sumk = solver_to_sumk
|
||||||
self.sumk_to_solver = sumk_to_solver
|
self.sumk_to_solver = sumk_to_solver
|
||||||
self.solver_to_sumk_block = solver_to_sumk_block
|
self.solver_to_sumk_block = solver_to_sumk_block
|
||||||
@ -136,13 +155,13 @@ class BlockStructure(object):
|
|||||||
This is returned as a
|
This is returned as a
|
||||||
list (for each shell)
|
list (for each shell)
|
||||||
of lists (for each block)
|
of lists (for each block)
|
||||||
of tuples (block_name, block_indices).
|
of tuples (block_name, block_dimension).
|
||||||
|
|
||||||
That is,
|
That is,
|
||||||
``gf_struct_solver_list[ish][b][0]``
|
``gf_struct_solver_list[ish][b][0]``
|
||||||
is the name of the block number ``b`` of shell ``ish``, and
|
is the name of the block number ``b`` of shell ``ish``, and
|
||||||
``gf_struct_solver_list[ish][b][1]``
|
``gf_struct_solver_list[ish][b][1]``
|
||||||
is a list of its indices.
|
is the dimension of the block ``b``.
|
||||||
|
|
||||||
The list for each shell is sorted alphabetically by block name.
|
The list for each shell is sorted alphabetically by block name.
|
||||||
"""
|
"""
|
||||||
@ -159,13 +178,13 @@ class BlockStructure(object):
|
|||||||
This is returned as a
|
This is returned as a
|
||||||
list (for each shell)
|
list (for each shell)
|
||||||
of lists (for each block)
|
of lists (for each block)
|
||||||
of tuples (block_name, block_indices)
|
of tuples (block_name, block_dimension)
|
||||||
|
|
||||||
That is,
|
That is,
|
||||||
``gf_struct_sumk_list[ish][b][0]``
|
``gf_struct_sumk_list[ish][b][0]``
|
||||||
is the name of the block number ``b`` of shell ``ish``, and
|
is the name of the block number ``b`` of shell ``ish``, and
|
||||||
``gf_struct_sumk_list[ish][b][1]``
|
``gf_struct_sumk_list[ish][b][1]``
|
||||||
is a list of its indices.
|
is the dimension of the block ``b``.
|
||||||
"""
|
"""
|
||||||
return self.gf_struct_sumk
|
return self.gf_struct_sumk
|
||||||
|
|
||||||
@ -179,7 +198,7 @@ class BlockStructure(object):
|
|||||||
|
|
||||||
That is,
|
That is,
|
||||||
``gf_struct_solver_dict[ish][bname]``
|
``gf_struct_solver_dict[ish][bname]``
|
||||||
is a list of the indices of block ``bname`` of shell ``ish``.
|
is the dimension of block ``bname`` of shell ``ish``.
|
||||||
"""
|
"""
|
||||||
return self.gf_struct_solver
|
return self.gf_struct_solver
|
||||||
|
|
||||||
@ -193,11 +212,11 @@ class BlockStructure(object):
|
|||||||
|
|
||||||
That is,
|
That is,
|
||||||
``gf_struct_sumk_dict[ish][bname]``
|
``gf_struct_sumk_dict[ish][bname]``
|
||||||
is a list of the indices of block ``bname`` of shell ``ish``.
|
is the dimension of block ``bname`` of shell ``ish``.
|
||||||
"""
|
"""
|
||||||
if self.gf_struct_sumk is None:
|
if self.gf_struct_sumk is None:
|
||||||
return None
|
return None
|
||||||
return [{block: indices for block, indices in gfs}
|
return [{block: block_dim for block, block_dim in gfs}
|
||||||
for gfs in self.gf_struct_sumk]
|
for gfs in self.gf_struct_sumk]
|
||||||
|
|
||||||
@property
|
@property
|
||||||
@ -249,7 +268,7 @@ class BlockStructure(object):
|
|||||||
raise Exception('gf_struct_solver not set.')
|
raise Exception('gf_struct_solver not set.')
|
||||||
|
|
||||||
if trans is None:
|
if trans is None:
|
||||||
trans = [{block: np.eye(len(indices)) for block, indices in gfs}
|
trans = [{block: np.eye(block_dim) for block, block_dim in gfs}
|
||||||
for gfs in self.gf_struct_sumk]
|
for gfs in self.gf_struct_sumk]
|
||||||
|
|
||||||
assert isinstance(trans, list),\
|
assert isinstance(trans, list),\
|
||||||
@ -261,12 +280,12 @@ class BlockStructure(object):
|
|||||||
for icrsh in list(range(len(trans))):
|
for icrsh in list(range(len(trans))):
|
||||||
ish = self.corr_to_inequiv[icrsh]
|
ish = self.corr_to_inequiv[icrsh]
|
||||||
if trans[icrsh] is None:
|
if trans[icrsh] is None:
|
||||||
trans[icrsh] = {block: np.eye(len(indices))
|
trans[icrsh] = {block: np.eye(block_dim)
|
||||||
for block, indices in self.gf_struct_sumk[icrsh]}
|
for block, block_dim in self.gf_struct_sumk[icrsh]}
|
||||||
|
|
||||||
if not isinstance(trans[icrsh], dict):
|
if not isinstance(trans[icrsh], dict):
|
||||||
trans[icrsh] = {block: copy.deepcopy(trans[icrsh])
|
trans[icrsh] = {block: copy.deepcopy(trans[icrsh])
|
||||||
for block, indices in self.gf_struct_sumk[icrsh]}
|
for block, block_dim in self.gf_struct_sumk[icrsh]}
|
||||||
|
|
||||||
assert list(trans[icrsh].keys()) == list(self.gf_struct_sumk_dict[icrsh].keys()),\
|
assert list(trans[icrsh].keys()) == list(self.gf_struct_sumk_dict[icrsh].keys()),\
|
||||||
"wrong block names used in transformation (icrsh = {})".format(icrsh)
|
"wrong block names used in transformation (icrsh = {})".format(icrsh)
|
||||||
@ -275,13 +294,13 @@ class BlockStructure(object):
|
|||||||
assert trans[icrsh][block].shape[0] == trans[icrsh][block].shape[1],\
|
assert trans[icrsh][block].shape[0] == trans[icrsh][block].shape[1],\
|
||||||
"Transformation has to be quadratic; throwing away orbitals can be achieved on the level of the mapping. (icrsh = {}, block = {})".format(icrsh, block)
|
"Transformation has to be quadratic; throwing away orbitals can be achieved on the level of the mapping. (icrsh = {}, block = {})".format(icrsh, block)
|
||||||
|
|
||||||
assert trans[icrsh][block].shape[0] == len(self.gf_struct_sumk_dict[icrsh][block]),\
|
assert trans[icrsh][block].shape[0] == self.gf_struct_sumk_dict[icrsh][block],\
|
||||||
"Transformation block shape does not match gf_struct_sumk. (icrsh = {}, block = {})".format(icrsh, block)
|
"Transformation block shape does not match gf_struct_sumk. (icrsh = {}, block = {})".format(icrsh, block)
|
||||||
|
|
||||||
# zero out all the lines of the transformation that are
|
# zero out all the lines of the transformation that are
|
||||||
# not included in gf_struct_solver
|
# not included in gf_struct_solver
|
||||||
for iorb, norb in enumerate(self.gf_struct_sumk_dict[icrsh][block]):
|
for iorb in range(self.gf_struct_sumk_dict[icrsh][block]):
|
||||||
if self.sumk_to_solver[ish][(block, norb)][0] is None:
|
if self.sumk_to_solver[ish][(block, iorb)][0] is None:
|
||||||
trans[icrsh][block][iorb, :] = 0.0
|
trans[icrsh][block][iorb, :] = 0.0
|
||||||
return trans
|
return trans
|
||||||
|
|
||||||
@ -321,10 +340,10 @@ class BlockStructure(object):
|
|||||||
for block in self.gf_struct_solver[ish]:
|
for block in self.gf_struct_solver[ish]:
|
||||||
block_sumk = self.solver_to_sumk_block[ish][block]
|
block_sumk = self.solver_to_sumk_block[ish][block]
|
||||||
T = eff_trans_sumk[icrsh][block_sumk]
|
T = eff_trans_sumk[icrsh][block_sumk]
|
||||||
ets[ish][block] = np.zeros((len(self.gf_struct_solver[ish][block]),
|
ets[ish][block] = np.zeros((self.gf_struct_solver[ish][block],
|
||||||
len(T)),
|
len(T)),
|
||||||
dtype=T.dtype)
|
dtype=T.dtype)
|
||||||
for i in self.gf_struct_solver[ish][block]:
|
for i in range(self.gf_struct_solver[ish][block]):
|
||||||
i_sumk = self.solver_to_sumk[ish][block, i]
|
i_sumk = self.solver_to_sumk[ish][block, i]
|
||||||
assert i_sumk[0] == block_sumk,\
|
assert i_sumk[0] == block_sumk,\
|
||||||
"Wrong block in solver_to_sumk"
|
"Wrong block in solver_to_sumk"
|
||||||
@ -343,7 +362,7 @@ class BlockStructure(object):
|
|||||||
Parameters
|
Parameters
|
||||||
----------
|
----------
|
||||||
gf_struct : list of dict
|
gf_struct : list of dict
|
||||||
gf_struct[ish][block] = list of indices in that block
|
gf_struct[ish][block] = block dimension of that block
|
||||||
|
|
||||||
for (inequivalent) correlated shell ish
|
for (inequivalent) correlated shell ish
|
||||||
corr_to_inequiv : list
|
corr_to_inequiv : list
|
||||||
@ -365,7 +384,7 @@ class BlockStructure(object):
|
|||||||
gss = []
|
gss = []
|
||||||
for block in gf_struct[ish]:
|
for block in gf_struct[ish]:
|
||||||
so2sublock[block]=block
|
so2sublock[block]=block
|
||||||
for ind in gf_struct[ish][block]:
|
for ind in range(gf_struct[ish][block]):
|
||||||
so2su[(block,ind)]=(block,ind)
|
so2su[(block,ind)]=(block,ind)
|
||||||
gss.append((block,gf_struct[ish][block]))
|
gss.append((block,gf_struct[ish][block]))
|
||||||
solver_to_sumk.append(so2su)
|
solver_to_sumk.append(so2su)
|
||||||
@ -409,16 +428,14 @@ class BlockStructure(object):
|
|||||||
|
|
||||||
[{'up':[0],'down':[1]}]
|
[{'up':[0],'down':[1]}]
|
||||||
|
|
||||||
Note that the indices will be renamed to be a 0-based
|
Note that as of version 3.1.x, the new structure itself will
|
||||||
sequence of integers, i.e. the new structure will actually
|
actually be stored as [{'up':1,'down':1}].
|
||||||
be [{'up':[0],'down':[0]}].
|
|
||||||
|
|
||||||
For dropped indices, sumk_to_solver will map to (None,None).
|
For dropped indices, sumk_to_solver will map to (None,None).
|
||||||
|
|
||||||
Parameters
|
Parameters
|
||||||
----------
|
----------
|
||||||
new_gf_struct : list of dict
|
new_gf_struct : list of dict
|
||||||
formatted the same as gf_struct_solver:
|
|
||||||
|
|
||||||
new_gf_struct[ish][block]=list of indices in that block.
|
new_gf_struct[ish][block]=list of indices in that block.
|
||||||
"""
|
"""
|
||||||
@ -454,7 +471,8 @@ class BlockStructure(object):
|
|||||||
|
|
||||||
# reindexing gf_struct so that it starts with 0
|
# reindexing gf_struct so that it starts with 0
|
||||||
for k in gf_struct:
|
for k in gf_struct:
|
||||||
gf_struct[k]=list(range(len(gf_struct[k])))
|
# gf_struct[k]=list(range(len(gf_struct[k])))
|
||||||
|
gf_struct[k]=len(gf_struct[k])
|
||||||
self.gf_struct_solver[ish]=gf_struct
|
self.gf_struct_solver[ish]=gf_struct
|
||||||
|
|
||||||
def adapt_deg_shells(self, gf_struct, ish=0):
|
def adapt_deg_shells(self, gf_struct, ish=0):
|
||||||
@ -468,7 +486,7 @@ class BlockStructure(object):
|
|||||||
if not key in gf_struct:
|
if not key in gf_struct:
|
||||||
del degsh[key]
|
del degsh[key]
|
||||||
continue
|
continue
|
||||||
if gf_struct[key] != self.gf_struct_solver[ish][key]:
|
if len(gf_struct[key]) != self.gf_struct_solver[ish][key]:
|
||||||
v, C = degsh[key]
|
v, C = degsh[key]
|
||||||
degsh[key][0] = \
|
degsh[key][0] = \
|
||||||
v[gf_struct[key], :][:, gf_struct[key]]
|
v[gf_struct[key], :][:, gf_struct[key]]
|
||||||
@ -509,7 +527,6 @@ class BlockStructure(object):
|
|||||||
Parameters
|
Parameters
|
||||||
----------
|
----------
|
||||||
new_gf_struct : list of dict
|
new_gf_struct : list of dict
|
||||||
formatted the same as gf_struct_solver:
|
|
||||||
|
|
||||||
new_gf_struct[ish][block]=list of indices in that block.
|
new_gf_struct[ish][block]=list of indices in that block.
|
||||||
|
|
||||||
@ -529,16 +546,16 @@ class BlockStructure(object):
|
|||||||
# one non-zero entry
|
# one non-zero entry
|
||||||
|
|
||||||
for icrsh in range(len(new_gf_struct)):
|
for icrsh in range(len(new_gf_struct)):
|
||||||
for block, indices in self.gf_struct_sumk[icrsh]:
|
for block, block_dim in self.gf_struct_sumk[icrsh]:
|
||||||
if not block in new_gf_struct[icrsh]:
|
if not block in new_gf_struct[icrsh]:
|
||||||
#del new_gf_struct_transformed[block] # this MUST be wrong, as new_gf_struct_transformed needs to have a integer index for icrsh... # error when index is not kept at all
|
#del new_gf_struct_transformed[block] # this MUST be wrong, as new_gf_struct_transformed needs to have a integer index for icrsh... # error when index is not kept at all
|
||||||
continue
|
continue
|
||||||
T = eff_trans_sumk[icrsh][block]
|
T = eff_trans_sumk[icrsh][block]
|
||||||
for index in indices:
|
for index in range(block_dim):
|
||||||
if not index in new_gf_struct[icrsh][block]:
|
if not index in new_gf_struct[icrsh][block]:
|
||||||
T[:, index] = 0.0
|
T[:, index] = 0.0
|
||||||
new_indices = []
|
new_indices = []
|
||||||
for index in indices:
|
for index in range(block_dim):
|
||||||
if np.any(np.abs(T[index, :]) > 1.e-15):
|
if np.any(np.abs(T[index, :]) > 1.e-15):
|
||||||
new_indices.append(index)
|
new_indices.append(index)
|
||||||
new_gf_struct_transformed[icrsh][block] = new_indices
|
new_gf_struct_transformed[icrsh][block] = new_indices
|
||||||
@ -609,6 +626,11 @@ class BlockStructure(object):
|
|||||||
if not k in su2so:
|
if not k in su2so:
|
||||||
su2so[k] = (None, None)
|
su2so[k] = (None, None)
|
||||||
|
|
||||||
|
for new_block in gf_struct:
|
||||||
|
assert all(np.sort(gf_struct[new_block]) == list(range(len(gf_struct[new_block])))) ,\
|
||||||
|
"New gf_struct does not have valid 0-based indices!"
|
||||||
|
gf_struct[new_block] = len(gf_struct[new_block])
|
||||||
|
|
||||||
self.adapt_deg_shells(gf_struct, ish)
|
self.adapt_deg_shells(gf_struct, ish)
|
||||||
|
|
||||||
self.gf_struct_solver[ish] = gf_struct
|
self.gf_struct_solver[ish] = gf_struct
|
||||||
@ -660,8 +682,8 @@ class BlockStructure(object):
|
|||||||
which space the structure should correspond to
|
which space the structure should correspond to
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def gf_function(indices):
|
def gf_function(target_shape):
|
||||||
return np.zeros((len(indices), len(indices)), dtype=dtype)
|
return np.zeros(target_shape, dtype=dtype)
|
||||||
|
|
||||||
def block_function(name_list, block_list):
|
def block_function(name_list, block_list):
|
||||||
d = dict()
|
d = dict()
|
||||||
@ -683,7 +705,7 @@ class BlockStructure(object):
|
|||||||
names = list(gf_struct[ish].keys())
|
names = list(gf_struct[ish].keys())
|
||||||
blocks = []
|
blocks = []
|
||||||
for n in names:
|
for n in names:
|
||||||
G = gf_function(indices=gf_struct[ish][n], **kwargs)
|
G = gf_function(target_shape=(gf_struct[ish][n],gf_struct[ish][n]), **kwargs)
|
||||||
blocks.append(G)
|
blocks.append(G)
|
||||||
G = block_function(name_list=names, block_list=blocks)
|
G = block_function(name_list=names, block_list=blocks)
|
||||||
return G
|
return G
|
||||||
@ -766,7 +788,7 @@ class BlockStructure(object):
|
|||||||
for block, gf in G:
|
for block, gf in G:
|
||||||
assert block in gf_struct[ish],\
|
assert block in gf_struct[ish],\
|
||||||
"block " + block + " not in struct (shell {})".format(ish)
|
"block " + block + " not in struct (shell {})".format(ish)
|
||||||
assert list(gf.indices) == 2 * [list(map(str, gf_struct[ish][block]))],\
|
assert (gf.target_shape) == (gf_struct[ish][block], gf_struct[ish][block]),\
|
||||||
"block " + block + \
|
"block " + block + \
|
||||||
" has wrong indices (shell {})".format(ish)
|
" has wrong indices (shell {})".format(ish)
|
||||||
else:
|
else:
|
||||||
@ -776,7 +798,7 @@ class BlockStructure(object):
|
|||||||
for block, gf in list(G.items()):
|
for block, gf in list(G.items()):
|
||||||
assert block in gf_struct[ish],\
|
assert block in gf_struct[ish],\
|
||||||
"block " + block + " not in struct (shell {})".format(ish)
|
"block " + block + " not in struct (shell {})".format(ish)
|
||||||
assert list(range(len(gf))) == 2 * [list(map(str, gf_struct[ish][block]))],\
|
assert len(gf) == gf_struct[ish][block],\
|
||||||
"block " + block + \
|
"block " + block + \
|
||||||
" has wrong indices (shell {})".format(ish)
|
" has wrong indices (shell {})".format(ish)
|
||||||
|
|
||||||
@ -936,8 +958,8 @@ class BlockStructure(object):
|
|||||||
block_mapping_from = G_struct.sumk_to_solver_block[ish_from]
|
block_mapping_from = G_struct.sumk_to_solver_block[ish_from]
|
||||||
elif space_from == 'sumk':
|
elif space_from == 'sumk':
|
||||||
gf_struct_from = G_struct.gf_struct_sumk_dict[ish_from]
|
gf_struct_from = G_struct.gf_struct_sumk_dict[ish_from]
|
||||||
eff_trans_from = {block: np.eye(len(indices))
|
eff_trans_from = {block: np.eye(block_dim)
|
||||||
for block, indices in G_struct.gf_struct_sumk[ish_from]}
|
for block, block_dim in G_struct.gf_struct_sumk[ish_from]}
|
||||||
block_mapping_from = {b: [b] for b in gf_struct_from}
|
block_mapping_from = {b: [b] for b in gf_struct_from}
|
||||||
else:
|
else:
|
||||||
raise Exception(
|
raise Exception(
|
||||||
@ -949,8 +971,8 @@ class BlockStructure(object):
|
|||||||
block_mapping_to = self.solver_to_sumk_block[ish_to]
|
block_mapping_to = self.solver_to_sumk_block[ish_to]
|
||||||
elif space_to == 'sumk':
|
elif space_to == 'sumk':
|
||||||
gf_struct_to = self.gf_struct_sumk_dict[ish_to]
|
gf_struct_to = self.gf_struct_sumk_dict[ish_to]
|
||||||
eff_trans_to = {block: np.eye(len(indices))
|
eff_trans_to = {block: np.eye(block_dim)
|
||||||
for block, indices in self.gf_struct_sumk_list[ish_to]}
|
for block, block_dim in self.gf_struct_sumk_list[ish_to]}
|
||||||
block_mapping_to = {b: b for b in gf_struct_to}
|
block_mapping_to = {b: b for b in gf_struct_to}
|
||||||
else:
|
else:
|
||||||
raise Exception(
|
raise Exception(
|
||||||
@ -1046,7 +1068,7 @@ class BlockStructure(object):
|
|||||||
self.solver_to_sumk_block.append({})
|
self.solver_to_sumk_block.append({})
|
||||||
for frm,to in list(self.sumk_to_solver[ish].items()):
|
for frm,to in list(self.sumk_to_solver[ish].items()):
|
||||||
if to[0] is not None:
|
if to[0] is not None:
|
||||||
self.gf_struct_solver[ish][frm[0]+'_'+str(frm[1])]=[0]
|
self.gf_struct_solver[ish][frm[0]+'_'+str(frm[1])]=1
|
||||||
self.sumk_to_solver[ish][frm]=(frm[0]+'_'+str(frm[1]),0)
|
self.sumk_to_solver[ish][frm]=(frm[0]+'_'+str(frm[1]),0)
|
||||||
self.solver_to_sumk[ish][(frm[0]+'_'+str(frm[1]),0)]=frm
|
self.solver_to_sumk[ish][(frm[0]+'_'+str(frm[1]),0)]=frm
|
||||||
self.solver_to_sumk_block[ish][frm[0]+'_'+str(frm[1])]=frm[0]
|
self.solver_to_sumk_block[ish][frm[0]+'_'+str(frm[1])]=frm[0]
|
||||||
@ -1168,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)
|
||||||
|
@ -138,10 +138,10 @@ class SumkDFT(object):
|
|||||||
# GF structure used for the local things in the k sums
|
# GF structure used for the local things in the k sums
|
||||||
# Most general form allowing for all hybridisation, i.e. largest
|
# Most general form allowing for all hybridisation, i.e. largest
|
||||||
# blocks possible
|
# blocks possible
|
||||||
self.gf_struct_sumk = [[(sp, list(range(self.corr_shells[icrsh]['dim']))) for sp in self.spin_block_names[self.corr_shells[icrsh]['SO']]]
|
self.gf_struct_sumk = [[(sp, self.corr_shells[icrsh]['dim']) for sp in self.spin_block_names[self.corr_shells[icrsh]['SO']]]
|
||||||
for icrsh in range(self.n_corr_shells)]
|
for icrsh in range(self.n_corr_shells)]
|
||||||
# First set a standard gf_struct solver:
|
# First set a standard gf_struct solver:
|
||||||
self.gf_struct_solver = [dict([(sp, list(range(self.corr_shells[self.inequiv_to_corr[ish]]['dim'])))
|
self.gf_struct_solver = [dict([(sp, self.corr_shells[self.inequiv_to_corr[ish]]['dim'])
|
||||||
for sp in self.spin_block_names[self.corr_shells[self.inequiv_to_corr[ish]]['SO']]])
|
for sp in self.spin_block_names[self.corr_shells[self.inequiv_to_corr[ish]]['SO']]])
|
||||||
for ish in range(self.n_inequiv_shells)]
|
for ish in range(self.n_inequiv_shells)]
|
||||||
# Set standard (identity) maps from gf_struct_sumk <->
|
# Set standard (identity) maps from gf_struct_sumk <->
|
||||||
@ -151,9 +151,9 @@ class SumkDFT(object):
|
|||||||
self.solver_to_sumk_block = [{}
|
self.solver_to_sumk_block = [{}
|
||||||
for ish in range(self.n_inequiv_shells)]
|
for ish in range(self.n_inequiv_shells)]
|
||||||
for ish in range(self.n_inequiv_shells):
|
for ish in range(self.n_inequiv_shells):
|
||||||
for block, inner_list in self.gf_struct_sumk[self.inequiv_to_corr[ish]]:
|
for block, inner_dim in self.gf_struct_sumk[self.inequiv_to_corr[ish]]:
|
||||||
self.solver_to_sumk_block[ish][block] = block
|
self.solver_to_sumk_block[ish][block] = block
|
||||||
for inner in inner_list:
|
for inner in range(inner_dim):
|
||||||
self.sumk_to_solver[ish][
|
self.sumk_to_solver[ish][
|
||||||
(block, inner)] = (block, inner)
|
(block, inner)] = (block, inner)
|
||||||
self.solver_to_sumk[ish][
|
self.solver_to_sumk[ish][
|
||||||
@ -743,13 +743,13 @@ class SumkDFT(object):
|
|||||||
G_loc = [self.Sigma_imp_iw[icrsh].copy() for icrsh in range(
|
G_loc = [self.Sigma_imp_iw[icrsh].copy() for icrsh in range(
|
||||||
self.n_corr_shells)] # this list will be returned
|
self.n_corr_shells)] # this list will be returned
|
||||||
beta = G_loc[0].mesh.beta
|
beta = G_loc[0].mesh.beta
|
||||||
G_loc_inequiv = [BlockGf(name_block_generator=[(block, GfImFreq(indices=inner, mesh=G_loc[0].mesh)) for block, inner in self.gf_struct_solver[ish].items()],
|
G_loc_inequiv = [BlockGf(name_block_generator=[(block, GfImFreq(target_shape=(block_dim, block_dim), mesh=G_loc[0].mesh)) for block, block_dim in self.gf_struct_solver[ish].items()],
|
||||||
make_copies=False) for ish in range(self.n_inequiv_shells)]
|
make_copies=False) for ish in range(self.n_inequiv_shells)]
|
||||||
elif iw_or_w == "w":
|
elif iw_or_w == "w":
|
||||||
G_loc = [self.Sigma_imp_w[icrsh].copy() for icrsh in range(
|
G_loc = [self.Sigma_imp_w[icrsh].copy() for icrsh in range(
|
||||||
self.n_corr_shells)] # this list will be returned
|
self.n_corr_shells)] # this list will be returned
|
||||||
mesh = G_loc[0].mesh
|
mesh = G_loc[0].mesh
|
||||||
G_loc_inequiv = [BlockGf(name_block_generator=[(block, GfReFreq(indices=inner, mesh=mesh)) for block, inner in self.gf_struct_solver[ish].items()],
|
G_loc_inequiv = [BlockGf(name_block_generator=[(block, GfReFreq(target_shape=(block_dim, block_dim), mesh=mesh)) for block, block_dim in self.gf_struct_solver[ish].items()],
|
||||||
make_copies=False) for ish in range(self.n_inequiv_shells)]
|
make_copies=False) for ish in range(self.n_inequiv_shells)]
|
||||||
|
|
||||||
for icrsh in range(self.n_corr_shells):
|
for icrsh in range(self.n_corr_shells):
|
||||||
@ -911,7 +911,7 @@ class SumkDFT(object):
|
|||||||
for i in range(num_blocs):
|
for i in range(num_blocs):
|
||||||
blocs[i].sort()
|
blocs[i].sort()
|
||||||
self.gf_struct_solver[ish].update(
|
self.gf_struct_solver[ish].update(
|
||||||
[('%s_%s' % (sp, i), list(range(len(blocs[i]))))])
|
[('%s_%s' % (sp, i), len(blocs[i]))])
|
||||||
|
|
||||||
# Construct sumk_to_solver taking (sumk_block, sumk_index) --> (solver_block, solver_inner)
|
# Construct sumk_to_solver taking (sumk_block, sumk_index) --> (solver_block, solver_inner)
|
||||||
# and solver_to_sumk taking (solver_block, solver_inner) -->
|
# and solver_to_sumk taking (solver_block, solver_inner) -->
|
||||||
@ -930,12 +930,12 @@ class SumkDFT(object):
|
|||||||
|
|
||||||
# Now calculate degeneracies of orbitals
|
# Now calculate degeneracies of orbitals
|
||||||
dm = {}
|
dm = {}
|
||||||
for block, inner in self.gf_struct_solver[ish].items():
|
for block, block_dim in self.gf_struct_solver[ish].items():
|
||||||
# get dm for the blocks:
|
# get dm for the blocks:
|
||||||
dm[block] = numpy.zeros(
|
dm[block] = numpy.zeros(
|
||||||
[len(inner), len(inner)], numpy.complex_)
|
[block_dim, block_dim], numpy.complex_)
|
||||||
for ind1 in inner:
|
for ind1 in range(block_dim):
|
||||||
for ind2 in inner:
|
for ind2 in range(block_dim):
|
||||||
block_sumk, ind1_sumk = self.solver_to_sumk[
|
block_sumk, ind1_sumk = self.solver_to_sumk[
|
||||||
ish][(block, ind1)]
|
ish][(block, ind1)]
|
||||||
block_sumk, ind2_sumk = self.solver_to_sumk[
|
block_sumk, ind2_sumk = self.solver_to_sumk[
|
||||||
@ -1100,7 +1100,7 @@ class SumkDFT(object):
|
|||||||
for i in range(num_blocs):
|
for i in range(num_blocs):
|
||||||
blocs[i].sort()
|
blocs[i].sort()
|
||||||
self.gf_struct_solver[ish].update(
|
self.gf_struct_solver[ish].update(
|
||||||
[('%s_%s' % (sp, i), list(range(len(blocs[i]))))])
|
[('%s_%s' % (sp, i), len(blocs[i]))])
|
||||||
|
|
||||||
# Construct sumk_to_solver taking (sumk_block, sumk_index) --> (solver_block, solver_inner)
|
# Construct sumk_to_solver taking (sumk_block, sumk_index) --> (solver_block, solver_inner)
|
||||||
# and solver_to_sumk taking (solver_block, solver_inner) -->
|
# and solver_to_sumk taking (solver_block, solver_inner) -->
|
||||||
@ -1119,7 +1119,7 @@ class SumkDFT(object):
|
|||||||
|
|
||||||
# transform G to the new structure
|
# transform G to the new structure
|
||||||
full_structure = BlockStructure.full_structure(
|
full_structure = BlockStructure.full_structure(
|
||||||
[{sp:list(range(self.corr_shells[self.inequiv_to_corr[ish]]['dim']))
|
[{sp:self.corr_shells[self.inequiv_to_corr[ish]]['dim']
|
||||||
for sp in self.spin_block_names[self.corr_shells[self.inequiv_to_corr[ish]]['SO']]}
|
for sp in self.spin_block_names[self.corr_shells[self.inequiv_to_corr[ish]]['SO']]}
|
||||||
for ish in range(self.n_inequiv_shells)],self.corr_to_inequiv)
|
for ish in range(self.n_inequiv_shells)],self.corr_to_inequiv)
|
||||||
G_transformed = [
|
G_transformed = [
|
||||||
@ -1420,7 +1420,7 @@ class SumkDFT(object):
|
|||||||
"calculate_diagonalization_matrix: Choices for prop_to_be_diagonal are 'eal' or 'dm'.")
|
"calculate_diagonalization_matrix: Choices for prop_to_be_diagonal are 'eal' or 'dm'.")
|
||||||
return 0
|
return 0
|
||||||
|
|
||||||
trans = [{block: numpy.eye(len(indices)) for block, indices in gfs} for gfs in self.gf_struct_sumk]
|
trans = [{block: numpy.eye(block_dim) for block, block_dim in gfs} for gfs in self.gf_struct_sumk]
|
||||||
|
|
||||||
for ish in shells:
|
for ish in shells:
|
||||||
trafo = {}
|
trafo = {}
|
||||||
|
@ -97,8 +97,8 @@ class SumkDFTTools(SumkDFT):
|
|||||||
G_loc = []
|
G_loc = []
|
||||||
for icrsh in range(self.n_corr_shells):
|
for icrsh in range(self.n_corr_shells):
|
||||||
spn = self.spin_block_names[self.corr_shells[icrsh]['SO']]
|
spn = self.spin_block_names[self.corr_shells[icrsh]['SO']]
|
||||||
glist = [GfReFreq(indices=inner, window=(om_min, om_max), n_points=n_om)
|
glist = [GfReFreq(target_shape=(block_dim, block_dim), window=(om_min, om_max), n_points=n_om)
|
||||||
for block, inner in self.gf_struct_sumk[icrsh]]
|
for block, block_dim in self.gf_struct_sumk[icrsh]]
|
||||||
G_loc.append(
|
G_loc.append(
|
||||||
BlockGf(name_list=spn, block_list=glist, make_copies=False))
|
BlockGf(name_list=spn, block_list=glist, make_copies=False))
|
||||||
for icrsh in range(self.n_corr_shells):
|
for icrsh in range(self.n_corr_shells):
|
||||||
@ -236,8 +236,8 @@ class SumkDFTTools(SumkDFT):
|
|||||||
n_local_orbs = self.proj_mat_csc.shape[2]
|
n_local_orbs = self.proj_mat_csc.shape[2]
|
||||||
gf_struct_parproj_all = [[(sp, list(range(n_local_orbs))) for sp in spn]]
|
gf_struct_parproj_all = [[(sp, list(range(n_local_orbs))) for sp in spn]]
|
||||||
|
|
||||||
glist_all = [GfReFreq(indices=inner, window=(om_min, om_max), n_points=n_om)
|
glist_all = [GfReFreq(target_shape=(block_dim, block_dim), window=(om_min, om_max), n_points=n_om)
|
||||||
for block, inner in gf_struct_parproj_all[0]]
|
for block, block_dim in gf_struct_parproj_all[0]]
|
||||||
G_loc_all = BlockGf(name_list=spn, block_list=glist_all, make_copies=False)
|
G_loc_all = BlockGf(name_list=spn, block_list=glist_all, make_copies=False)
|
||||||
|
|
||||||
DOS = {sp: numpy.zeros([n_om], numpy.float_)
|
DOS = {sp: numpy.zeros([n_om], numpy.float_)
|
||||||
@ -364,11 +364,11 @@ class SumkDFTTools(SumkDFT):
|
|||||||
|
|
||||||
G_loc = []
|
G_loc = []
|
||||||
spn = self.spin_block_names[self.SO]
|
spn = self.spin_block_names[self.SO]
|
||||||
gf_struct_parproj = [[(sp, list(range(self.shells[ish]['dim']))) for sp in spn]
|
gf_struct_parproj = [[(sp, self.shells[ish]['dim']) for sp in spn]
|
||||||
for ish in range(self.n_shells)]
|
for ish in range(self.n_shells)]
|
||||||
for ish in range(self.n_shells):
|
for ish in range(self.n_shells):
|
||||||
glist = [GfReFreq(indices=inner, window=(om_min, om_max), n_points=n_om)
|
glist = [GfReFreq(target_shape=(block_dim, block_dim), window=(om_min, om_max), n_points=n_om)
|
||||||
for block, inner in gf_struct_parproj[ish]]
|
for block, block_dim in gf_struct_parproj[ish]]
|
||||||
G_loc.append(
|
G_loc.append(
|
||||||
BlockGf(name_list=spn, block_list=glist, make_copies=False))
|
BlockGf(name_list=spn, block_list=glist, make_copies=False))
|
||||||
for ish in range(self.n_shells):
|
for ish in range(self.n_shells):
|
||||||
@ -873,9 +873,9 @@ class SumkDFTTools(SumkDFT):
|
|||||||
|
|
||||||
if not ishell is None:
|
if not ishell is None:
|
||||||
gf_struct_parproj = [
|
gf_struct_parproj = [
|
||||||
(sp, list(range(self.shells[ishell]['dim']))) for sp in spn]
|
(sp, self.shells[ishell]['dim']) for sp in spn]
|
||||||
G_loc = BlockGf(name_block_generator=[(block, GfReFreq(indices=inner, mesh=self.Sigma_imp_w[0].mesh))
|
G_loc = BlockGf(name_block_generator=[(block, GfReFreq(target_shape=(block_dim, block_dim), mesh=self.Sigma_imp_w[0].mesh))
|
||||||
for block, inner in gf_struct_parproj], make_copies=False)
|
for block, block_dim in gf_struct_parproj], make_copies=False)
|
||||||
G_loc.zero()
|
G_loc.zero()
|
||||||
|
|
||||||
ikarray = numpy.array(list(range(self.n_k)))
|
ikarray = numpy.array(list(range(self.n_k)))
|
||||||
@ -993,16 +993,16 @@ class SumkDFTTools(SumkDFT):
|
|||||||
for ish in range(self.n_shells)]
|
for ish in range(self.n_shells)]
|
||||||
for isp in range(len(spn))]
|
for isp in range(len(spn))]
|
||||||
# Set up G_loc
|
# Set up G_loc
|
||||||
gf_struct_parproj = [[(sp, list(range(self.shells[ish]['dim']))) for sp in spn]
|
gf_struct_parproj = [[(sp, self.shells[ish]['dim']) for sp in spn]
|
||||||
for ish in range(self.n_shells)]
|
for ish in range(self.n_shells)]
|
||||||
if with_Sigma:
|
if with_Sigma:
|
||||||
G_loc = [BlockGf(name_block_generator=[(block, GfImFreq(indices=inner, mesh=self.Sigma_imp_iw[0].mesh))
|
G_loc = [BlockGf(name_block_generator=[(block, GfImFreq(target_shape=(block_dim, block_dim), mesh=self.Sigma_imp_iw[0].mesh))
|
||||||
for block, inner in gf_struct_parproj[ish]], make_copies=False)
|
for block, block_dim in gf_struct_parproj[ish]], make_copies=False)
|
||||||
for ish in range(self.n_shells)]
|
for ish in range(self.n_shells)]
|
||||||
beta = self.Sigma_imp_iw[0].mesh.beta
|
beta = self.Sigma_imp_iw[0].mesh.beta
|
||||||
else:
|
else:
|
||||||
G_loc = [BlockGf(name_block_generator=[(block, GfImFreq(indices=inner, beta=beta))
|
G_loc = [BlockGf(name_block_generator=[(block, GfImFreq(target_shape=(block_dim, block_dim), beta=beta))
|
||||||
for block, inner in gf_struct_parproj[ish]], make_copies=False)
|
for block, block_dim in gf_struct_parproj[ish]], make_copies=False)
|
||||||
for ish in range(self.n_shells)]
|
for ish in range(self.n_shells)]
|
||||||
for ish in range(self.n_shells):
|
for ish in range(self.n_shells):
|
||||||
G_loc[ish].zero()
|
G_loc[ish].zero()
|
||||||
@ -1227,8 +1227,8 @@ class SumkDFTTools(SumkDFT):
|
|||||||
for icrsh in range(self.n_corr_shells):
|
for icrsh in range(self.n_corr_shells):
|
||||||
Sigma_save = self.Sigma_imp_w[icrsh].copy()
|
Sigma_save = self.Sigma_imp_w[icrsh].copy()
|
||||||
spn = self.spin_block_names[self.corr_shells[icrsh]['SO']]
|
spn = self.spin_block_names[self.corr_shells[icrsh]['SO']]
|
||||||
glist = lambda: [GfReFreq(indices=inner, window=(self.omega[
|
glist = lambda: [GfReFreq(target_shape=(block_dim, block_dim), window=(self.omega[
|
||||||
0], self.omega[-1]), n_points=n_om) for block, inner in self.gf_struct_sumk[icrsh]]
|
0], self.omega[-1]), n_points=n_om) for block, block_dim in self.gf_struct_sumk[icrsh]]
|
||||||
self.Sigma_imp_w[icrsh] = BlockGf(
|
self.Sigma_imp_w[icrsh] = BlockGf(
|
||||||
name_list=spn, block_list=glist(), make_copies=False)
|
name_list=spn, block_list=glist(), make_copies=False)
|
||||||
for i, g in self.Sigma_imp_w[icrsh]:
|
for i, g in self.Sigma_imp_w[icrsh]:
|
||||||
|
@ -150,14 +150,14 @@ class TransBasis:
|
|||||||
|
|
||||||
# build a full GF
|
# build a full GF
|
||||||
gfrotated = BlockGf(name_block_generator=[(block, GfImFreq(
|
gfrotated = BlockGf(name_block_generator=[(block, GfImFreq(
|
||||||
indices=inner, mesh=gf_to_rot.mesh)) for block, inner in self.SK.gf_struct_sumk[0]], make_copies=False)
|
target_shape=(block_dim, block_dim), mesh=gf_to_rot.mesh)) for block, block_dim in self.SK.gf_struct_sumk[0]], make_copies=False)
|
||||||
|
|
||||||
# transform the CTQMC blocks to the full matrix:
|
# transform the CTQMC blocks to the full matrix:
|
||||||
# ish is the index of the inequivalent shell corresponding to icrsh
|
# ish is the index of the inequivalent shell corresponding to icrsh
|
||||||
ish = self.SK.corr_to_inequiv[0]
|
ish = self.SK.corr_to_inequiv[0]
|
||||||
for block, inner in self.gf_struct_solver[ish].items():
|
for block, block_dim in self.gf_struct_solver[ish].items():
|
||||||
for ind1 in inner:
|
for ind1 in range(block_dim):
|
||||||
for ind2 in inner:
|
for ind2 in range(block_dim):
|
||||||
gfrotated[self.SK.solver_to_sumk_block[ish][block]][
|
gfrotated[self.SK.solver_to_sumk_block[ish][block]][
|
||||||
ind1, ind2] << gf_to_rot[block][ind1, ind2]
|
ind1, ind2] << gf_to_rot[block][ind1, ind2]
|
||||||
|
|
||||||
@ -168,9 +168,9 @@ class TransBasis:
|
|||||||
|
|
||||||
gfreturn = gf_to_rot.copy()
|
gfreturn = gf_to_rot.copy()
|
||||||
# Put back into CTQMC basis:
|
# Put back into CTQMC basis:
|
||||||
for block, inner in self.gf_struct_solver[ish].items():
|
for block, block_dim in self.gf_struct_solver[ish].items():
|
||||||
for ind1 in inner:
|
for ind1 in range(block_dim):
|
||||||
for ind2 in inner:
|
for ind2 in range(block_dim):
|
||||||
gfreturn[block][ind1, ind2] << gfrotated[
|
gfreturn[block][ind1, ind2] << gfrotated[
|
||||||
self.SK.solver_to_sumk_block[0][block]][ind1, ind2]
|
self.SK.solver_to_sumk_block[0][block]][ind1, ind2]
|
||||||
|
|
||||||
|
@ -54,11 +54,11 @@ SK.symm_deg_gf(G_new_symm, 0)
|
|||||||
assert_block_gfs_are_close(G_new[0], G_new_symm)
|
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"
|
"wrong gf_struct_sumk"
|
||||||
for i in range(5):
|
for i in range(5):
|
||||||
assert 'ud_{}'.format(i) in SK.gf_struct_solver[0], "missing block"
|
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):
|
for i in range(10):
|
||||||
assert SK.sumk_to_solver[0]['ud',i] == ('ud_{}'.format(i//2), i%2), "wrong mapping"
|
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)
|
SK.symm_deg_gf(G_new_symm, 0)
|
||||||
assert_block_gfs_are_close(G_new[0], G_new_symm)
|
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"
|
"wrong gf_struct_sumk"
|
||||||
for i in range(5):
|
for i in range(5):
|
||||||
assert 'ud_{}'.format(i) in SK.gf_struct_solver[0], "missing block"
|
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):
|
for i in range(10):
|
||||||
assert SK.sumk_to_solver[0]['ud',i] == ('ud_{}'.format(i//2), i%2), "wrong mapping"
|
assert SK.sumk_to_solver[0]['ud',i] == ('ud_{}'.format(i//2), i%2), "wrong mapping"
|
||||||
|
|
||||||
|
@ -92,7 +92,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))
|
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 op in H3:
|
||||||
for c_op in op[0]:
|
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()
|
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])
|
H4 = h_int_slater(spin_names=['up','down'], orb_names=range(3), U_matrix=U_trafod, map_operator_structure=BS.sumk_to_solver[0])
|
||||||
|
@ -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
|
||||||
|
|
||||||
|
|
||||||
@ -174,11 +174,9 @@ cmp(m2,
|
|||||||
|
|
||||||
# check full_structure
|
# check full_structure
|
||||||
full = BlockStructure.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])
|
G_sumk = BlockGf(mesh=G1.mesh, gf_struct=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]))
|
|
||||||
for i in range(3):
|
for i in range(3):
|
||||||
G_sumk['up'][i, i] << SemiCircular(1 if i < 2 else 2)
|
G_sumk['up'][i, i] << SemiCircular(1 if i < 2 else 2)
|
||||||
G_sumk['down'][i, i] << SemiCircular(4 if i < 2 else 3)
|
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_block_gfs_are_close(G1, G_bT)
|
||||||
|
|
||||||
assert original_bs.gf_struct_sumk_list ==\
|
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 ==\
|
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 ==\
|
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 ==\
|
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__
|
# check __eq__
|
||||||
assert full == full, 'equality not correct (equal structures not equal)'
|
assert full == full, 'equality not correct (equal structures not equal)'
|
||||||
|
Loading…
Reference in New Issue
Block a user