Newer
Older
# %%
import h5py
from shutil import copyfile
import numpy as np
def __init__(self, adga_root_path, adga_config_file_name,
two_particle_greens_function_file_name):
self.adga_executable = adga_root_path + "/bin/abinitiodga"
self.symmetrize_script = adga_root_path + "/scripts/symmetrize.py"
self.adga_config_file_name = adga_config_file_name
self.adga_output_file_name = "adga.hdf5"
self.configure_adga_output_file_name()
self.g2_file = h5py.File(two_particle_greens_function_file_name, "r")
copyfile(two_particle_greens_function_file_name, "g4iw.hdf5")
self.g4iw_file = h5py.File("g4iw.hdf5", "r+")
self.worm_groups = [s + "/ineq-001/g4iw-worm/"
for s in self.g2_file.keys()
if (("worm-" in s) and (s != "worm-last"))]
self.n_worm_samples = len(self.worm_groups)
self.compound_indexes = list(self.g2_file[self.worm_groups[0]].keys())
def get_worm_sample_generator(self):
"""Return a generator yielding green's functions from different
worm samples."""
def worm_sample_generator():
for worm_group in self.worm_groups:
value_groups = [worm_group + i + "/value"
for i in self.compound_indexes]
for value_group in value_groups])
return worm_sample_generator
def __call__(self, two_particle_greens_function):
g2 = two_particle_greens_function
# Write g2 to g4iw.hdf5/worm-001
for i in range(len(self.compound_indexes)):
data_set = self.g4iw_file["worm-001/ineq-001/g4iw-worm/" +
self.compound_indexes[i] + "/value"]
output = subprocess.check_output("python print_hdf5_data.py g4iw.hdf5"
+ " worm-001/ineq-001/g4iw-worm"
+ "/00001/value", shell=True)
print(output.decode("utf-8"))
output = subprocess.check_output("python print_hdf5_data.py g4iw.hdf5"
+ " worm-001/ineq-001/g4iw-worm"
+ "/00001/value", shell=True)
print(output.decode("utf-8"))
# Delete g4iw_sym.hdf5
symmetry_file = "g4iw_sym.hdf5"
if os.path.exists(symmetry_file):
os.remove(symmetry_file)
print(self.symmetrize_script + " worm-001")
subprocess.call([self.symmetrize_script, "worm-001"])
# Call /ADGA/bin/abinitiodga <path/to/dga.conf>
print(self.adga_executable + " " + self.adga_config_file_name)
subprocess.call([self.adga_executable, self.adga_config_file_name])
# Return adga.hdf5/selfenergy/nonloc/dga
adga_file = h5py.File(self.adga_output_file_name, "r")
data_set = adga_file["selfenergy/nonloc/dga"]
self_energy = np.array(data_set[...])
adga_file.close()
print(self_energy[0, 0, 0, 0, 0, 0])
return self_energy[0, 0, 0, 0, 0, 0]
def configure_adga_output_file_name(self):
# TODO: Read the config file and check if "Outfile" exists in
# [General]. If not, create it. In any case, set the "Outfile" in
# self.adga_config_file_path
pass