nep框架重构 02.scf增加了vdw势
This commit is contained in:
@@ -450,7 +450,6 @@ class Workflow:
|
|||||||
return
|
return
|
||||||
|
|
||||||
# 3. 准备 VASP 输入文件到 'fp' 文件夹
|
# 3. 准备 VASP 输入文件到 'fp' 文件夹
|
||||||
# gpumdkit 生成的 fp 文件夹通常存放公共文件,子文件夹会软链过去
|
|
||||||
fp_dir = os.path.join(step_dir, "fp")
|
fp_dir = os.path.join(step_dir, "fp")
|
||||||
if not os.path.exists(fp_dir):
|
if not os.path.exists(fp_dir):
|
||||||
self.logger.error("'fp' directory was not created by 301.")
|
self.logger.error("'fp' directory was not created by 301.")
|
||||||
@@ -467,7 +466,6 @@ class Workflow:
|
|||||||
return
|
return
|
||||||
|
|
||||||
# B. INCAR (来自 Template)
|
# B. INCAR (来自 Template)
|
||||||
# Template 路径: template/02.scf/INCAR
|
|
||||||
incar_src = os.path.join(self.template_dir, "02.scf", "INCAR")
|
incar_src = os.path.join(self.template_dir, "02.scf", "INCAR")
|
||||||
if os.path.exists(incar_src):
|
if os.path.exists(incar_src):
|
||||||
shutil.copy(incar_src, os.path.join(fp_dir, "INCAR"))
|
shutil.copy(incar_src, os.path.join(fp_dir, "INCAR"))
|
||||||
@@ -482,6 +480,37 @@ class Workflow:
|
|||||||
else:
|
else:
|
||||||
self.logger.info("KPOINTS not found in template, assuming KSPACING in INCAR.")
|
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. 生成并提交计算任务
|
# 4. 生成并提交计算任务
|
||||||
# 这里我们不理会 gpumdkit 生成的 presub.sh,而是根据 machine.yaml 生成自己的
|
# 这里我们不理会 gpumdkit 生成的 presub.sh,而是根据 machine.yaml 生成自己的
|
||||||
executor_name = step_conf.get('executor', 'vasp_gpu') # 默认用 cpu
|
executor_name = step_conf.get('executor', 'vasp_gpu') # 默认用 cpu
|
||||||
|
|||||||
Reference in New Issue
Block a user