|
18 | 18 | import dpgen.data.tools.fcc as fcc
|
19 | 19 | import dpgen.data.tools.hcp as hcp
|
20 | 20 | import dpgen.data.tools.sc as sc
|
21 |
| -from dpgen import ROOT_PATH, dlog |
| 21 | +from dpgen import dlog |
22 | 22 | from dpgen.dispatcher.Dispatcher import make_submission_compat
|
23 | 23 | from dpgen.generator.lib.utils import symlink_user_forward_files
|
24 | 24 | from dpgen.remote.decide_machine import convert_mdata
|
@@ -354,15 +354,16 @@ def make_vasp_relax(jdata):
|
354 | 354 | out_dir = jdata["out_dir"]
|
355 | 355 | potcars = jdata["potcars"]
|
356 | 356 | cwd = os.getcwd()
|
357 |
| - |
358 | 357 | work_dir = os.path.join(out_dir, global_dirname_02)
|
359 | 358 | assert os.path.isdir(work_dir)
|
360 | 359 | work_dir = os.path.abspath(work_dir)
|
| 360 | + |
361 | 361 | if os.path.isfile(os.path.join(work_dir, "INCAR")):
|
362 | 362 | os.remove(os.path.join(work_dir, "INCAR"))
|
363 | 363 | if os.path.isfile(os.path.join(work_dir, "POTCAR")):
|
364 | 364 | os.remove(os.path.join(work_dir, "POTCAR"))
|
365 | 365 | shutil.copy2(jdata["relax_incar"], os.path.join(work_dir, "INCAR"))
|
| 366 | + |
366 | 367 | out_potcar = os.path.join(work_dir, "POTCAR")
|
367 | 368 | with open(out_potcar, "w") as outfile:
|
368 | 369 | for fname in potcars:
|
@@ -442,15 +443,12 @@ def make_scale(jdata):
|
442 | 443 | for jj in scale:
|
443 | 444 | if skip_relax:
|
444 | 445 | pos_src = os.path.join(os.path.join(init_path, ii), "POSCAR")
|
445 |
| - assert os.path.isfile(pos_src) |
446 | 446 | else:
|
447 |
| - try: |
448 |
| - pos_src = os.path.join(os.path.join(init_path, ii), "CONTCAR") |
449 |
| - assert os.path.isfile(pos_src) |
450 |
| - except Exception: |
451 |
| - raise RuntimeError( |
452 |
| - "not file %s, vasp relaxation should be run before scale poscar" |
453 |
| - ) |
| 447 | + pos_src = os.path.join(os.path.join(init_path, ii), "CONTCAR") |
| 448 | + if not os.path.isfile(pos_src): |
| 449 | + raise RuntimeError( |
| 450 | + f"file {pos_src} not found, vasp relaxation should be run before scale poscar" |
| 451 | + ) |
454 | 452 | scale_path = os.path.join(work_path, ii)
|
455 | 453 | scale_path = os.path.join(scale_path, f"scale-{jj:.3f}")
|
456 | 454 | create_path(scale_path)
|
@@ -503,46 +501,45 @@ def pert_scaled(jdata):
|
503 | 501 | sys_pe.sort()
|
504 | 502 | os.chdir(cwd)
|
505 | 503 |
|
506 |
| - pert_cmd = ( |
507 |
| - sys.executable |
508 |
| - + " " |
509 |
| - + os.path.join(ROOT_PATH, "data/tools/create_random_disturb.py") |
510 |
| - ) |
511 |
| - pert_cmd += " -etmax %f -ofmt vasp POSCAR %d %f > /dev/null" % ( |
512 |
| - pert_box, |
513 |
| - pert_numb, |
514 |
| - pert_atom, |
| 504 | + ### Construct the perturbation command |
| 505 | + python_exec = os.path.join( |
| 506 | + os.path.dirname(__file__), "tools", "create_random_disturb.py" |
515 | 507 | )
|
| 508 | + pert_cmd = f"{sys.executable} {python_exec} -etmax {pert_box} -ofmt vasp POSCAR {pert_numb} {pert_atom} > /dev/null" |
| 509 | + |
| 510 | + ### Loop over each system and scale |
516 | 511 | for ii in sys_pe:
|
517 | 512 | for jj in scale:
|
518 |
| - path_scale = path_sp |
519 |
| - path_scale = os.path.join(path_scale, ii) |
520 |
| - path_scale = os.path.join(path_scale, f"scale-{jj:.3f}") |
| 513 | + path_scale = os.path.join(path_sp, ii, f"scale-{jj:.3f}") |
521 | 514 | assert os.path.isdir(path_scale)
|
522 | 515 | os.chdir(path_scale)
|
523 | 516 | dlog.info(os.getcwd())
|
524 | 517 | poscar_in = os.path.join(path_scale, "POSCAR")
|
525 | 518 | assert os.path.isfile(poscar_in)
|
| 519 | + |
| 520 | + ### Loop over each perturbation |
526 | 521 | for ll in elongs:
|
527 |
| - path_elong = path_scale |
528 |
| - path_elong = os.path.join(path_elong, f"elong-{ll:3.3f}") |
| 522 | + path_elong = os.path.join(path_scale, f"elong-{ll:3.3f}") |
529 | 523 | create_path(path_elong)
|
530 | 524 | os.chdir(path_elong)
|
531 | 525 | poscar_elong(poscar_in, "POSCAR", ll)
|
532 | 526 | sp.check_call(pert_cmd, shell=True)
|
533 | 527 | for kk in range(pert_numb):
|
534 |
| - pos_in = "POSCAR%d.vasp" % (kk + 1) |
535 |
| - dir_out = "%06d" % (kk + 1) |
| 528 | + pos_in = f"POSCAR{kk+1}.vasp" |
| 529 | + dir_out = f"{kk+1:06d}" |
536 | 530 | create_path(dir_out)
|
537 | 531 | pos_out = os.path.join(dir_out, "POSCAR")
|
538 | 532 | poscar_shuffle(pos_in, pos_out)
|
539 | 533 | os.remove(pos_in)
|
| 534 | + |
| 535 | + ### Handle special case (unperturbed ?) |
540 | 536 | kk = -1
|
541 | 537 | pos_in = "POSCAR"
|
542 |
| - dir_out = "%06d" % (kk + 1) |
| 538 | + dir_out = f"{kk+1:06d}" |
543 | 539 | create_path(dir_out)
|
544 | 540 | pos_out = os.path.join(dir_out, "POSCAR")
|
545 | 541 | poscar_shuffle(pos_in, pos_out)
|
| 542 | + |
546 | 543 | os.chdir(cwd)
|
547 | 544 |
|
548 | 545 |
|
|
0 commit comments