From 1d2b613ac4c8ddca46d3b94882d0e7bd2278e5f0 Mon Sep 17 00:00:00 2001 From: Shuaishuai Yuan Date: Sun, 8 Dec 2024 22:58:21 -0500 Subject: [PATCH 1/2] Save the DFT outputs in a folder named after the current step. --- flare/learners/otf.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/flare/learners/otf.py b/flare/learners/otf.py index 1a5f9cda..4d65689a 100644 --- a/flare/learners/otf.py +++ b/flare/learners/otf.py @@ -602,10 +602,11 @@ def run_dft(self): to_copy = [target_files] else: to_copy = target_files + new_folder = os.path.join(dest, str(self.curr_step)) + os.makedirs(new_folder, exist_ok=True) for ofile in to_copy: - # if the file is in a subdirectory like dft/OUTCAR, then copy it out filename = ofile.split("/")[-1] - copyfile(ofile, dest + "/" + dt_string + filename) + copyfile(ofile, os.path.join(new_folder, filename)) self.dft_frames.append(self.curr_step) self.output.write_wall_time(tic, task="Run DFT") From 65b0320b688141921c96a322232bc81323ae9b82 Mon Sep 17 00:00:00 2001 From: Shuaishuai Yuan Date: Sun, 8 Dec 2024 23:21:29 -0500 Subject: [PATCH 2/2] Removed redundant timestamp logic, ensured proper directory creation for curr_step, and improved comments for clarity. --- flare/learners/otf.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/flare/learners/otf.py b/flare/learners/otf.py index 4d65689a..7509b248 100644 --- a/flare/learners/otf.py +++ b/flare/learners/otf.py @@ -595,17 +595,19 @@ def run_dft(self): # specified in self.store_dft_output if self.store_dft_output is not None: dest = self.store_dft_output[1] + # Ensure the destination directory exists; create it if it doesn't + os.makedirs(dest, exist_ok=True) target_files = self.store_dft_output[0] - now = datetime.now() - dt_string = now.strftime("%Y.%m.%d:%H:%M:%S:") if isinstance(target_files, str): to_copy = [target_files] else: to_copy = target_files + # Create a new subfolder under the destination directory named after the current step new_folder = os.path.join(dest, str(self.curr_step)) os.makedirs(new_folder, exist_ok=True) for ofile in to_copy: filename = ofile.split("/")[-1] + # Copy the file to the new folder, preserving its original file name copyfile(ofile, os.path.join(new_folder, filename)) self.dft_frames.append(self.curr_step) self.output.write_wall_time(tic, task="Run DFT")