From f95f4011d48368a69ea840d2699595a7b1794637 Mon Sep 17 00:00:00 2001 From: koko <1429659362@qq.com> Date: Thu, 11 Dec 2025 20:18:59 +0800 Subject: [PATCH] =?UTF-8?q?nep=E6=A1=86=E6=9E=B6=E9=87=8D=E6=9E=84=2002.sc?= =?UTF-8?q?f=E5=A2=9E=E5=8A=A0=E4=BA=86vdw=E5=8A=BF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/workflow.py | 33 +++++++++++++++++++++++++++++++-- 1 file changed, 31 insertions(+), 2 deletions(-) diff --git a/src/workflow.py b/src/workflow.py index f563249..c89f561 100644 --- a/src/workflow.py +++ b/src/workflow.py @@ -450,7 +450,6 @@ class Workflow: return # 3. 准备 VASP 输入文件到 'fp' 文件夹 - # gpumdkit 生成的 fp 文件夹通常存放公共文件,子文件夹会软链过去 fp_dir = os.path.join(step_dir, "fp") if not os.path.exists(fp_dir): self.logger.error("'fp' directory was not created by 301.") @@ -467,7 +466,6 @@ class Workflow: return # B. INCAR (来自 Template) - # Template 路径: template/02.scf/INCAR incar_src = os.path.join(self.template_dir, "02.scf", "INCAR") if os.path.exists(incar_src): shutil.copy(incar_src, os.path.join(fp_dir, "INCAR")) @@ -482,6 +480,37 @@ class Workflow: else: self.logger.info("KPOINTS not found in template, assuming KSPACING in INCAR.") + # D. [新增] vdw_kernel.bindat (可选 + 手动软链接) + vdw_src = os.path.join(self.template_dir, "02.scf", "vdw_kernel.bindat") + vdw_fp_path = os.path.join(fp_dir, "vdw_kernel.bindat") + has_vdw = False + + if os.path.exists(vdw_src): + shutil.copy(vdw_src, vdw_fp_path) + has_vdw = True + self.logger.info("Found vdw_kernel.bindat, copied to fp folder.") + + # E. [新增] 遍历所有子目录,补全 vdw_kernel.bindat 的软链接 + # gpumdkit 只会自动链接 fp 里的 INCAR/POTCAR/KPOINTS + if has_vdw: + self.logger.info("Manually creating symlinks for vdw_kernel.bindat...") + # 获取 step_dir 下所有的 iterX_Y 文件夹 + for item in os.listdir(step_dir): + item_path = os.path.join(step_dir, item) + # 判断是否是拆分出来的子任务目录 (通常以 iter 开头) + if os.path.isdir(item_path) and item.startswith("iter"): + # 目标链接路径 + dst_link = os.path.join(item_path, "vdw_kernel.bindat") + # 如果已存在(比如是死文件),先删除 + if os.path.exists(dst_link) or os.path.islink(dst_link): + os.remove(dst_link) + + # 创建指向 ../fp/vdw_kernel.bindat 的相对软链接 + # 这样即使文件夹移动,链接也大概率有效 + try: + os.symlink(os.path.join("..", "fp", "vdw_kernel.bindat"), dst_link) + except Exception as e: + self.logger.error(f"Failed to symlink vdw in {item}: {e}") # 4. 生成并提交计算任务 # 这里我们不理会 gpumdkit 生成的 presub.sh,而是根据 machine.yaml 生成自己的 executor_name = step_conf.get('executor', 'vasp_gpu') # 默认用 cpu