*** Wartungsfenster jeden ersten Mittwoch vormittag im Monat ***

Skip to content
Snippets Groups Projects
Commit 08a9e648 authored by Patrick Kappl's avatar Patrick Kappl
Browse files

Add unique ID to temporary file names

This allows to run multiple Jackknives at the same time.
parent ae2d9959
No related branches found
No related tags found
No related merge requests found
......@@ -3,6 +3,7 @@ from shutil import copyfile
import numpy as np
import subprocess
import os
import time
# TODO: Exceptions
......@@ -25,10 +26,13 @@ class Adga(object):
self.executable = adga_root_path + "/bin/abinitiodga"
self.symmetrize_script = adga_root_path + "/scripts/symmetrize.py"
self.config_file_name = adga_config_file_name
self.output_file_name = "adga.hdf5"
# Generate and a unique id for the names of the temporary files.
# This allows to run multiple Jackknives at once.
self.unique_id = int(time.time_ns() * 1e3)
self.output_file_name = "adga{}.hdf5".format(self.unique_id)
self.g2_file = h5py.File(two_particle_greens_function_file_name, "r")
g4iw_file_name = "g4iw.hdf5"
g4iw_file_name = "g4iw{}.hdf5".format(self.unique_id)
copyfile(two_particle_greens_function_file_name, g4iw_file_name)
self.g4iw_file = h5py.File(g4iw_file_name, "r+")
......@@ -71,13 +75,14 @@ class Adga(object):
# TODO: Make a subroutine for symmetrizing g2
# g4iw_sym.hdf5 must not exist when calling symmetrize.py
symmetry_file = "g4iw_sym.hdf5"
symmetry_file = "g4iw{}_sym.hdf5".format(self.unique_id)
if os.path.exists(symmetry_file):
os.remove(symmetry_file)
# Symmetrize the 2-particle Green's function
print(self.symmetrize_script + " worm-001")
subprocess.call([self.symmetrize_script, "worm-001"])
print(self.symmetrize_script + " worm-001 " + self.g4iw_file.filename)
subprocess.call([self.symmetrize_script, "worm-001",
self.g4iw_file.filename])
# TODO: Make a subroutine for the whole DGA calculation
# TODO: Values should be added if not existent
......@@ -93,9 +98,9 @@ class Adga(object):
self.config_file_name])
# TODO: Make a subroutine for getting the self-energy
adga_file = h5py.File(self.output_file_name, "r")
self_energy = np.array(adga_file["selfenergy/nonloc/dga"][...])
adga_file.close()
output_file = h5py.File(self.output_file_name, "r")
self_energy = np.array(output_file["selfenergy/nonloc/dga"][...])
output_file.close()
return self_energy[0, 0, :, :, 0, :]
def _replace_value_in_config_file(self, key, value):
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment