|
43 | 43 | from dpgen.generator.lib.vasp import make_vasp_incar_user_dict |
44 | 44 | from dpgen.generator.lib.vasp import incar_upper |
45 | 45 | from dpgen.generator.lib.pwscf import make_pwscf_input |
| 46 | +from dpgen.generator.lib.abacus_pw_scf import make_abacus_pw_scf_stru, make_abacus_pw_scf_input, make_abacus_pw_scf_kpt |
46 | 47 | #from dpgen.generator.lib.pwscf import cvt_1frame |
47 | 48 | from dpgen.generator.lib.pwmat import make_pwmat_input_dict |
48 | 49 | from dpgen.generator.lib.pwmat import write_input_dict |
@@ -1795,6 +1796,41 @@ def make_fp_pwscf(iter_index, |
1795 | 1796 | # link pp files |
1796 | 1797 | _link_fp_vasp_pp(iter_index, jdata) |
1797 | 1798 |
|
| 1799 | +def make_fp_abacus_pw_scf(iter_index, |
| 1800 | + jdata) : |
| 1801 | + # make config |
| 1802 | + fp_tasks = _make_fp_vasp_configs(iter_index, jdata) |
| 1803 | + if len(fp_tasks) == 0 : |
| 1804 | + return |
| 1805 | + # make abacus/pw/scf input |
| 1806 | + iter_name = make_iter_name(iter_index) |
| 1807 | + work_path = os.path.join(iter_name, fp_name) |
| 1808 | + fp_pp_files = jdata['fp_pp_files'] |
| 1809 | + if 'user_fp_params' in jdata.keys() : |
| 1810 | + fp_params = jdata['user_fp_params'] |
| 1811 | + #user_input = True |
| 1812 | + else: |
| 1813 | + raise RuntimeError("Key 'user_fp_params' and its value have to be specified in parameter json file.") |
| 1814 | + cwd = os.getcwd() |
| 1815 | + for ii in fp_tasks: |
| 1816 | + os.chdir(ii) |
| 1817 | + sys_data = dpdata.System('POSCAR').data |
| 1818 | + if 'mass_map' in jdata: |
| 1819 | + sys_data['atom_masses'] = jdata['mass_map'] |
| 1820 | + ret_input = make_abacus_pw_scf_input(fp_params) |
| 1821 | + with open('INPUT', 'w') as fp: |
| 1822 | + fp.write(ret_input) |
| 1823 | + ret_kpt = make_abacus_pw_scf_kpt(fp_params) |
| 1824 | + with open("KPT", "w") as fp: |
| 1825 | + fp.write(ret_kpt) |
| 1826 | + ret_stru = make_abacus_pw_scf_stru(sys_data, fp_pp_files) |
| 1827 | + with open("STRU", "w") as fp: |
| 1828 | + fp.write(ret_stru) |
| 1829 | + |
| 1830 | + os.chdir(cwd) |
| 1831 | + # link pp files |
| 1832 | + _link_fp_vasp_pp(iter_index, jdata) |
| 1833 | + |
1798 | 1834 |
|
1799 | 1835 | def make_fp_siesta(iter_index, |
1800 | 1836 | jdata) : |
@@ -1918,6 +1954,8 @@ def make_fp (iter_index, |
1918 | 1954 | make_fp_vasp(iter_index, jdata) |
1919 | 1955 | elif fp_style == "pwscf" : |
1920 | 1956 | make_fp_pwscf(iter_index, jdata) |
| 1957 | + elif fp_style == "abacus/scf" : |
| 1958 | + make_fp_abacus_pw_scf(iter_index, jdata) |
1921 | 1959 | elif fp_style == "siesta" : |
1922 | 1960 | make_fp_siesta(iter_index, jdata) |
1923 | 1961 | elif fp_style == "gaussian" : |
@@ -1951,6 +1989,16 @@ def _qe_check_fin(ii) : |
1951 | 1989 | return False |
1952 | 1990 | return True |
1953 | 1991 |
|
| 1992 | +def _abacus_pw_scf_check_fin(ii) : |
| 1993 | + if os.path.isfile(os.path.join(ii, 'OUT.ABACUS/running_scf.log')) : |
| 1994 | + with open(os.path.join(ii, 'OUT.ABACUS/running_scf.log'), 'r') as fp : |
| 1995 | + content = fp.read() |
| 1996 | + count = content.count('!FINAL_ETOT_IS') |
| 1997 | + if count != 1 : |
| 1998 | + return False |
| 1999 | + else : |
| 2000 | + return False |
| 2001 | + return True |
1954 | 2002 |
|
1955 | 2003 | def _siesta_check_fin(ii) : |
1956 | 2004 | if os.path.isfile(os.path.join(ii, 'output')) : |
@@ -2061,6 +2109,10 @@ def run_fp (iter_index, |
2061 | 2109 | forward_files = ['input'] + fp_pp_files |
2062 | 2110 | backward_files = ['output'] |
2063 | 2111 | run_fp_inner(iter_index, jdata, mdata, forward_files, backward_files, _qe_check_fin, log_file = 'output') |
| 2112 | + elif fp_style == "abacus/scf": |
| 2113 | + forward_files = ["INPUT", "STRU", "KPT"] + fp_pp_files |
| 2114 | + backward_files = ["output", "OUT.ABACUS"] |
| 2115 | + run_fp_inner(iter_index, jdata, mdata, forward_files, backward_files, _abacus_pw_scf_check_fin, log_file = 'output') |
2064 | 2116 | elif fp_style == "siesta": |
2065 | 2117 | forward_files = ['input'] + fp_pp_files |
2066 | 2118 | backward_files = ['output'] |
@@ -2235,6 +2287,51 @@ def post_fp_pwscf (iter_index, |
2235 | 2287 | all_sys.to_deepmd_raw(sys_data_path) |
2236 | 2288 | all_sys.to_deepmd_npy(sys_data_path, set_size = len(sys_output)) |
2237 | 2289 |
|
| 2290 | +def post_fp_abacus_pw_scf (iter_index, |
| 2291 | + jdata): |
| 2292 | + model_devi_jobs = jdata['model_devi_jobs'] |
| 2293 | + assert (iter_index < len(model_devi_jobs)) |
| 2294 | + |
| 2295 | + iter_name = make_iter_name(iter_index) |
| 2296 | + work_path = os.path.join(iter_name, fp_name) |
| 2297 | + fp_tasks = glob.glob(os.path.join(work_path, 'task.*')) |
| 2298 | + fp_tasks.sort() |
| 2299 | + if len(fp_tasks) == 0 : |
| 2300 | + return |
| 2301 | + |
| 2302 | + system_index = [] |
| 2303 | + for ii in fp_tasks : |
| 2304 | + system_index.append(os.path.basename(ii).split('.')[1]) |
| 2305 | + system_index.sort() |
| 2306 | + set_tmp = set(system_index) |
| 2307 | + system_index = list(set_tmp) |
| 2308 | + system_index.sort() |
| 2309 | + |
| 2310 | + cwd = os.getcwd() |
| 2311 | + for ss in system_index : |
| 2312 | + sys_output = glob.glob(os.path.join(work_path, "task.%s.*"%ss)) |
| 2313 | + sys_input = glob.glob(os.path.join(work_path, "task.%s.*/INPUT"%ss)) |
| 2314 | + sys_output.sort() |
| 2315 | + sys_input.sort() |
| 2316 | + |
| 2317 | + flag=True |
| 2318 | + for ii,oo in zip(sys_input,sys_output) : |
| 2319 | + if flag: |
| 2320 | + _sys = dpdata.LabeledSystem(oo, fmt = 'abacus/scf', type_map = jdata['type_map']) |
| 2321 | + if len(_sys)>0: |
| 2322 | + all_sys=_sys |
| 2323 | + flag=False |
| 2324 | + else: |
| 2325 | + pass |
| 2326 | + else: |
| 2327 | + _sys = dpdata.LabeledSystem(oo, fmt = 'abacus/scf', type_map = jdata['type_map']) |
| 2328 | + if len(_sys)>0: |
| 2329 | + all_sys.append(_sys) |
| 2330 | + |
| 2331 | + sys_data_path = os.path.join(work_path, 'data.%s'%ss) |
| 2332 | + all_sys.to_deepmd_raw(sys_data_path) |
| 2333 | + all_sys.to_deepmd_npy(sys_data_path, set_size = len(sys_output)) |
| 2334 | + |
2238 | 2335 | def post_fp_siesta (iter_index, |
2239 | 2336 | jdata): |
2240 | 2337 | model_devi_jobs = jdata['model_devi_jobs'] |
@@ -2424,6 +2521,8 @@ def post_fp (iter_index, |
2424 | 2521 | post_fp_vasp(iter_index, jdata) |
2425 | 2522 | elif fp_style == "pwscf" : |
2426 | 2523 | post_fp_pwscf(iter_index, jdata) |
| 2524 | + elif fp_style == "abacus/scf": |
| 2525 | + post_fp_abacus_pw_scf(iter_index, jdata) |
2427 | 2526 | elif fp_style == "siesta": |
2428 | 2527 | post_fp_siesta(iter_index, jdata) |
2429 | 2528 | elif fp_style == 'gaussian' : |
|
0 commit comments