NEP框架重构00阶段

This commit is contained in:
2025-12-09 11:30:26 +08:00
parent 0a9dc8d8f5
commit 081540c274

View File

@@ -125,7 +125,7 @@ class Workflow:
self.logger.info(">>> Starting Production...")
os.makedirs(prod_dir, exist_ok=True)
# 软链接
# 1. 准备基础文件到 production 根目录
src_sample = os.path.abspath(os.path.join(preheat_dir, "sampled_structures.xyz"))
dst_sample = os.path.join(prod_dir, "sampled_structures.xyz")
if os.path.exists(dst_sample): os.remove(dst_sample)
@@ -135,7 +135,8 @@ class Workflow:
shutil.copy(os.path.join(self.template_dir, "00.md", "production", "run.in"),
os.path.join(prod_dir, "run.in"))
# A. 运行 302 生成 presub.sh
# 2. 运行 302 (生成 md 文件夹, sample_* 文件夹, presub.sh)
# 302 通常会读取当前目录的 run.in 并在 md/ 下生成拆分后的 run_x.in
input_str_302 = "302"
if not run_cmd_with_log(kit_path, prod_dir, "step_exec.log", input_str=input_str_302):
self.logger.error("302 command failed.")
@@ -145,7 +146,20 @@ class Workflow:
self.logger.error("presub.sh not found.")
return
# B. 运行 presub.sh
# ---------------------------------------------------------
# [新增] 3. 补全文件:将 nep.txt 和 run.in 复制到 md 文件夹
# ---------------------------------------------------------
md_subdir = os.path.join(prod_dir, "md")
if os.path.exists(md_subdir):
self.logger.info("Copying nep.txt and run.in to 'md' folder...")
shutil.copy(os.path.join(prod_dir, "nep.txt"), os.path.join(md_subdir, "nep.txt"))
# 复制 run.in虽然 302 可能已经生成了 run_1.in 等,但为了保险或用户习惯,我们也拷进去
shutil.copy(os.path.join(prod_dir, "run.in"), os.path.join(md_subdir, "run.in"))
else:
self.logger.error("'md' folder was not created by 302 command.")
return
# 4. 运行 presub.sh
os.chmod(os.path.join(prod_dir, "presub.sh"), 0o755)
self.logger.info(">>> Executing presub.sh...")
@@ -153,14 +167,14 @@ class Workflow:
self.logger.error("presub.sh execution failed.")
return
# C. 合并 dump
# 5. 合并 dump
self.logger.info("Merging dump files...")
run_cmd_with_log("cat sample_*/dump.xyz > dump.xyz", prod_dir, "step_exec.log")
self.last_dump_path = os.path.join(prod_dir, "dump.xyz")
self.tracker.mark_done(task_id_prod)
else:
self.logger.info("Skipping Production (Already Done).")
# 即使跳过,也要更新变量给下一步用
self.last_dump_path = os.path.join(prod_dir, "dump.xyz")
# ==========================