pwact 0.2.0__py3-none-any.whl → 0.2.1__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- pwact/active_learning/explore/run_model_md.py +110 -0
- pwact/active_learning/explore/select_image.py +10 -5
- pwact/active_learning/init_bulk/direct.py +182 -0
- pwact/active_learning/init_bulk/duplicate_scale.py +1 -1
- pwact/active_learning/init_bulk/explore.py +300 -0
- pwact/active_learning/init_bulk/init_bulk_run.py +87 -47
- pwact/active_learning/init_bulk/relabel.py +149 -116
- pwact/active_learning/label/labeling.py +132 -18
- pwact/active_learning/train/train_model.py +13 -3
- pwact/active_learning/user_input/init_bulk_input.py +55 -6
- pwact/active_learning/user_input/iter_input.py +12 -0
- pwact/active_learning/user_input/resource.py +19 -7
- pwact/active_learning/user_input/scf_param.py +24 -6
- pwact/active_learning/user_input/train_param/optimizer_param.py +1 -1
- pwact/main.py +18 -8
- pwact/utils/app_lib/do_direct_sample.py +145 -0
- pwact/utils/app_lib/do_eqv2model.py +41 -0
- pwact/utils/constant.py +31 -11
- pwact/utils/file_operation.py +12 -5
- pwact-0.2.1.dist-info/METADATA +17 -0
- {pwact-0.2.0.dist-info → pwact-0.2.1.dist-info}/RECORD +25 -21
- pwact-0.2.0.dist-info/METADATA +0 -107
- {pwact-0.2.0.dist-info → pwact-0.2.1.dist-info}/LICENSE +0 -0
- {pwact-0.2.0.dist-info → pwact-0.2.1.dist-info}/WHEEL +0 -0
- {pwact-0.2.0.dist-info → pwact-0.2.1.dist-info}/entry_points.txt +0 -0
- {pwact-0.2.0.dist-info → pwact-0.2.1.dist-info}/top_level.txt +0 -0
|
@@ -5,12 +5,13 @@ from pwact.active_learning.init_bulk.relax import Relax
|
|
|
5
5
|
from pwact.active_learning.init_bulk.duplicate_scale import do_pertub_work, do_post_pertub, pertub_done, \
|
|
6
6
|
duplicate_scale_done, duplicate_scale, do_post_duplicate_scale
|
|
7
7
|
from pwact.active_learning.init_bulk.aimd import AIMD
|
|
8
|
+
from pwact.active_learning.init_bulk.explore import BIGMODEL
|
|
8
9
|
from pwact.active_learning.init_bulk.relabel import Relabel
|
|
9
10
|
from pwact.active_learning.user_input.init_bulk_input import InitBulkParam
|
|
10
11
|
from pwact.active_learning.user_input.resource import Resource
|
|
11
12
|
from pwact.active_learning.slurm.slurm import scancle_job
|
|
12
|
-
from pwact.utils.constant import INIT_BULK, DFT_STYLE, TEMP_STRUCTURE, PWDATA
|
|
13
|
-
from pwact.utils.file_operation import copy_file, copy_dir, search_files, del_file, del_file_list, write_to_file
|
|
13
|
+
from pwact.utils.constant import INIT_BULK, DFT_STYLE, TEMP_STRUCTURE, PWDATA, LABEL_FILE_STRUCTURE
|
|
14
|
+
from pwact.utils.file_operation import copy_file, copy_dir, search_files, del_file, del_file_list, write_to_file, del_file_list_by_patten
|
|
14
15
|
from pwact.data_format.configop import extract_pwdata
|
|
15
16
|
|
|
16
17
|
def init_bulk_run(resource: Resource, input_param:InitBulkParam):
|
|
@@ -42,13 +43,26 @@ def init_bulk_run(resource: Resource, input_param:InitBulkParam):
|
|
|
42
43
|
aimd.do_aimd_jobs()
|
|
43
44
|
aimd.do_post_process()
|
|
44
45
|
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
46
|
+
elif input_param.is_bigmodel:
|
|
47
|
+
bigmodel = BIGMODEL(resource, input_param)
|
|
48
|
+
if not bigmodel.check_work_done():
|
|
49
|
+
bigmodel.make_bigmodel_work()
|
|
50
|
+
bigmodel.do_bigmodel_jobs()
|
|
51
|
+
bigmodel.do_post_process()
|
|
52
|
+
|
|
53
|
+
# do direct
|
|
54
|
+
if not bigmodel.check_direct_done():
|
|
55
|
+
bigmodel.make_direct_work()
|
|
56
|
+
bigmodel.do_direct_jobs() # after
|
|
57
|
+
|
|
58
|
+
# do relabel
|
|
59
|
+
if input_param.is_scf:
|
|
60
|
+
relabel = Relabel(resource, input_param)
|
|
61
|
+
if not relabel.check_work_done():
|
|
62
|
+
relabel.make_scf_work()
|
|
63
|
+
relabel.do_scf_jobs()
|
|
64
|
+
relabel.do_post_process()
|
|
65
|
+
|
|
52
66
|
do_collection(resource, input_param)
|
|
53
67
|
|
|
54
68
|
def do_collection(resource: Resource, input_param:InitBulkParam):
|
|
@@ -59,6 +73,8 @@ def do_collection(resource: Resource, input_param:InitBulkParam):
|
|
|
59
73
|
pertub_dir = os.path.join(input_param.root_dir, TEMP_STRUCTURE.tmp_init_bulk_dir, INIT_BULK.pertub)
|
|
60
74
|
aimd_dir = os.path.join(input_param.root_dir, TEMP_STRUCTURE.tmp_init_bulk_dir, INIT_BULK.aimd)
|
|
61
75
|
collection_dir = os.path.join(input_param.root_dir, TEMP_STRUCTURE.tmp_init_bulk_dir, INIT_BULK.collection)
|
|
76
|
+
bigmodel_dir = os.path.join(input_param.root_dir, TEMP_STRUCTURE.tmp_init_bulk_dir, INIT_BULK.bigmodel)
|
|
77
|
+
direct_dir = os.path.join(bigmodel_dir, INIT_BULK.direct)
|
|
62
78
|
|
|
63
79
|
real_collection_dir = os.path.join(input_param.root_dir, INIT_BULK.collection)
|
|
64
80
|
real_relax_dir = os.path.join(input_param.root_dir, INIT_BULK.relax)
|
|
@@ -68,7 +84,9 @@ def do_collection(resource: Resource, input_param:InitBulkParam):
|
|
|
68
84
|
|
|
69
85
|
relabel_dir = os.path.join(input_param.root_dir, TEMP_STRUCTURE.tmp_init_bulk_dir, INIT_BULK.scf)
|
|
70
86
|
real_relabel_dir = os.path.join(input_param.root_dir, INIT_BULK.scf)
|
|
71
|
-
|
|
87
|
+
real_bigmodel_dir = os.path.join(input_param.root_dir, INIT_BULK.bigmodel)
|
|
88
|
+
real_direct_dir = os.path.join(input_param.root_dir, INIT_BULK.direct)
|
|
89
|
+
|
|
72
90
|
|
|
73
91
|
for init_config in init_configs:
|
|
74
92
|
init_config_name = "init_config_{}".format(init_config.config_index)
|
|
@@ -112,24 +130,66 @@ def do_collection(resource: Resource, input_param:InitBulkParam):
|
|
|
112
130
|
data_shuffle=input_param.data_shuffle,
|
|
113
131
|
interval=1
|
|
114
132
|
)
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
if len(
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
133
|
+
# print the dir of pwdatas from aimd
|
|
134
|
+
if input_param.data_format == PWDATA.extxyz:
|
|
135
|
+
pwdatas = search_files(real_collection_dir, "*/{}".format(INIT_BULK.get_save_format(input_param.data_format)))
|
|
136
|
+
elif input_param.data_format == PWDATA.pwmlff_npy: # */PWdata/*.npy
|
|
137
|
+
tmp = search_files(real_collection_dir, "*/{}/*/position.npy".format(INIT_BULK.get_save_format(input_param.data_format)))
|
|
138
|
+
pwdatas = [os.path.dirname(_) for _ in tmp]
|
|
139
|
+
if len(pwdatas) > 0:
|
|
140
|
+
pwdatas = sorted(pwdatas)
|
|
141
|
+
result_lines = ["\"{}\",".format(_) for _ in pwdatas]
|
|
142
|
+
result_lines = "\n".join(result_lines)
|
|
143
|
+
# result_lines = result_lines[:-1] # Filter the last ','
|
|
144
|
+
result_save_path = os.path.join(collection_dir, INIT_BULK.npy_format_name)
|
|
145
|
+
write_to_file(result_save_path, result_lines, mode='w')
|
|
146
|
+
|
|
147
|
+
#6 convert relabel datas
|
|
148
|
+
result_save_path = []
|
|
149
|
+
if input_param.is_scf:
|
|
150
|
+
source_scf = search_files(relabel_dir,\
|
|
151
|
+
"*/{}".format(DFT_STYLE.get_scf_config(resource.dft_style)))
|
|
152
|
+
# init/0-aimd/0-scf/OUTCAR
|
|
153
|
+
source_scf = sorted(source_scf, key=lambda x:int(os.path.basename(os.path.dirname(x))), reverse=False)
|
|
154
|
+
#5. convert the aimd files (for vasp is outcar, for pwmat is movement) to npy format
|
|
155
|
+
extract_pwdata(input_data_list=source_scf,
|
|
156
|
+
intput_data_format= DFT_STYLE.get_format_by_postfix(os.path.basename(source_scf[0])),
|
|
157
|
+
save_data_path = os.path.join(collection_dir, INIT_BULK.scf),
|
|
158
|
+
save_data_name = INIT_BULK.get_save_format(input_param.data_format),
|
|
159
|
+
save_data_format= input_param.data_format,
|
|
160
|
+
data_shuffle=input_param.data_shuffle,
|
|
161
|
+
interval=1
|
|
162
|
+
)
|
|
163
|
+
result_save_path.append(os.path.join(real_collection_dir, INIT_BULK.scf, INIT_BULK.get_save_format(input_param.data_format)))
|
|
164
|
+
#7 bigmodel infos
|
|
165
|
+
if input_param.is_bigmodel:
|
|
166
|
+
if not input_param.is_scf:
|
|
167
|
+
extract_pwdata(input_data_list=[os.path.join(direct_dir, INIT_BULK.direct_traj)],
|
|
168
|
+
intput_data_format= PWDATA.extxyz,
|
|
169
|
+
save_data_path = direct_dir,
|
|
128
170
|
save_data_name = INIT_BULK.get_save_format(input_param.data_format),
|
|
129
171
|
save_data_format= input_param.data_format,
|
|
130
172
|
data_shuffle=input_param.data_shuffle,
|
|
131
173
|
interval=1
|
|
132
174
|
)
|
|
175
|
+
result_save_path.append(os.path.join(real_collection_dir, INIT_BULK.bigmodel, INIT_BULK.direct, INIT_BULK.get_save_format(input_param.data_format)))
|
|
176
|
+
# copy bigmodel and direct files to realdir
|
|
177
|
+
copy_dir(bigmodel_dir, os.path.join(collection_dir, INIT_BULK.bigmodel))
|
|
178
|
+
# delete logs
|
|
179
|
+
if len(result_save_path) > 0:
|
|
180
|
+
_path_path = []
|
|
181
|
+
for _data_path in result_save_path:
|
|
182
|
+
if input_param.data_format == PWDATA.extxyz:
|
|
183
|
+
_path_path.append(_data_path)
|
|
184
|
+
elif input_param.data_format == PWDATA.pwmlff_npy: # */PWdata/*.npy
|
|
185
|
+
tmp = search_files(_data_path, "*/position.npy")
|
|
186
|
+
_path_path.extend([os.path.dirname(_) for _ in tmp])
|
|
187
|
+
|
|
188
|
+
result_lines = ["\"{}\",".format(_) for _ in _path_path]
|
|
189
|
+
result_lines = "\n".join(result_lines)
|
|
190
|
+
# result_lines = result_lines[:-1] # Filter the last ','
|
|
191
|
+
result_save_path = os.path.join(collection_dir, INIT_BULK.npy_format_name)
|
|
192
|
+
write_to_file(result_save_path, result_lines, mode='w')
|
|
133
193
|
|
|
134
194
|
# delete link files
|
|
135
195
|
del_file(real_relax_dir)
|
|
@@ -137,7 +197,10 @@ def do_collection(resource: Resource, input_param:InitBulkParam):
|
|
|
137
197
|
del_file(real_pertub_dir)
|
|
138
198
|
del_file(real_aimd_dir)
|
|
139
199
|
del_file(real_relabel_dir)
|
|
140
|
-
|
|
200
|
+
del_file(real_bigmodel_dir)
|
|
201
|
+
# del slurm logs and tags
|
|
202
|
+
del_file_list_by_patten(os.path.join(collection_dir, INIT_BULK.bigmodel), "slurm-*")
|
|
203
|
+
del_file_list_by_patten(os.path.join(collection_dir, INIT_BULK.bigmodel, INIT_BULK.direct), "slurm-*")
|
|
141
204
|
# copy collection file to target
|
|
142
205
|
copy_dir(collection_dir, real_collection_dir)
|
|
143
206
|
if not input_param.reserve_work:
|
|
@@ -145,29 +208,6 @@ def do_collection(resource: Resource, input_param:InitBulkParam):
|
|
|
145
208
|
temp_work_dir = os.path.join(input_param.root_dir, TEMP_STRUCTURE.tmp_init_bulk_dir)
|
|
146
209
|
del_file_list([temp_work_dir])
|
|
147
210
|
|
|
148
|
-
# print the dir of pwdatas from aimd
|
|
149
|
-
if input_param.data_format == PWDATA.extxyz:
|
|
150
|
-
pwdatas = search_files(real_collection_dir, "*/{}".format(INIT_BULK.get_save_format(input_param.data_format)))
|
|
151
|
-
elif input_param.data_format == PWDATA.pwmlff_npy: # */PWdata/*.npy
|
|
152
|
-
tmp = search_files(real_collection_dir, "*/{}/*/position.npy".format(INIT_BULK.get_save_format(input_param.data_format)))
|
|
153
|
-
pwdatas = [os.path.dirname(_) for _ in tmp]
|
|
154
|
-
if len(pwdatas) > 0:
|
|
155
|
-
pwdatas = sorted(pwdatas)
|
|
156
|
-
result_lines = ["\"{}\",".format(_) for _ in pwdatas]
|
|
157
|
-
result_lines = "\n".join(result_lines)
|
|
158
|
-
# result_lines = result_lines[:-1] # Filter the last ','
|
|
159
|
-
result_save_path = os.path.join(real_collection_dir, INIT_BULK.npy_format_name)
|
|
160
|
-
write_to_file(result_save_path, result_lines, mode='w')
|
|
161
|
-
|
|
162
|
-
# print the dir of relabel_pwdatas from relabel
|
|
163
|
-
relebel_datas = search_files(real_collection_dir, "*/{}".format("scf_pwdata"))
|
|
164
|
-
if len(relebel_datas) > 0:
|
|
165
|
-
pwdatas = sorted(relebel_datas)
|
|
166
|
-
result_lines = ["\"{}\",".format(_) for _ in pwdatas]
|
|
167
|
-
result_lines = "\n".join(result_lines)
|
|
168
|
-
# result_lines = result_lines[:-1] # Filter the last ','
|
|
169
|
-
result_save_path = os.path.join(real_collection_dir, "scf_pwdata")
|
|
170
|
-
write_to_file(result_save_path, result_lines, mode='w')
|
|
171
211
|
|
|
172
212
|
def scancel_jobs(work_dir):
|
|
173
213
|
relax_job = os.path.join(work_dir, TEMP_STRUCTURE.tmp_init_bulk_dir, INIT_BULK.relax)
|
|
@@ -16,18 +16,27 @@
|
|
|
16
16
|
|
|
17
17
|
"""
|
|
18
18
|
import os
|
|
19
|
-
|
|
19
|
+
import glob
|
|
20
|
+
import json
|
|
21
|
+
import bisect
|
|
20
22
|
from pwact.active_learning.user_input.resource import Resource
|
|
21
23
|
from pwact.active_learning.user_input.init_bulk_input import InitBulkParam
|
|
22
24
|
from pwact.active_learning.init_bulk.duplicate_scale import get_config_files_with_order
|
|
23
25
|
|
|
24
|
-
from pwact.utils.constant import PWMAT, INIT_BULK, TEMP_STRUCTURE, SLURM_OUT, DFT_STYLE
|
|
26
|
+
from pwact.utils.constant import PWMAT, INIT_BULK, TEMP_STRUCTURE, SLURM_OUT, DFT_STYLE, PWDATA, VASP
|
|
25
27
|
from pwact.active_learning.slurm.slurm import SlurmJob, Mission
|
|
26
28
|
from pwact.utils.slurm_script import get_slurm_job_run_info, split_job_for_group, set_slurm_script_content
|
|
27
29
|
|
|
28
|
-
from pwact.utils.file_operation import write_to_file, link_file,
|
|
30
|
+
from pwact.utils.file_operation import write_to_file, link_file, del_dir, del_file_list_by_patten, get_random_nums
|
|
29
31
|
from pwact.utils.app_lib.common import link_pseudo_by_atom, set_input_script
|
|
30
|
-
from pwact.data_format.configop import save_config, get_atom_type, load_config
|
|
32
|
+
from pwact.data_format.configop import extract_pwdata, save_config, get_atom_type, load_config
|
|
33
|
+
|
|
34
|
+
import pandas as pd
|
|
35
|
+
from pwdata import Config
|
|
36
|
+
|
|
37
|
+
# from pwact.utils.constant import DFT_TYPE, VASP, PWDATA, AL_STRUCTURE, TEMP_STRUCTURE,\
|
|
38
|
+
# LABEL_FILE_STRUCTURE, EXPLORE_FILE_STRUCTURE, LAMMPS, SLURM_OUT, DFT_STYLE, PWMAT, INIT_BULK
|
|
39
|
+
# from pwact.utils.file_operation import write_to_file, copy_file, copy_dir, search_files, mv_file, add_postfix_dir, del_dir, del_file_list_by_patten, link_file
|
|
31
40
|
|
|
32
41
|
class Relabel(object):
|
|
33
42
|
def __init__(self, resource: Resource, input_param:InitBulkParam):
|
|
@@ -42,50 +51,104 @@ class Relabel(object):
|
|
|
42
51
|
|
|
43
52
|
self.scf_dir = os.path.join(self.input_param.root_dir, TEMP_STRUCTURE.tmp_init_bulk_dir, INIT_BULK.scf)
|
|
44
53
|
self.real_scf_dir = os.path.join(self.input_param.root_dir, INIT_BULK.scf)
|
|
45
|
-
|
|
46
|
-
def make_scf_work(self):
|
|
47
|
-
scf_paths = []
|
|
48
|
-
use_dftb = False
|
|
49
|
-
for init_config in self.init_configs:
|
|
50
|
-
if init_config.scf is False:
|
|
51
|
-
continue
|
|
52
|
-
init_config_name = "init_config_{}".format(init_config.config_index)
|
|
53
|
-
#1. read construtures from aimd dir
|
|
54
|
-
|
|
55
|
-
#2. set relabel dir
|
|
56
|
-
# read trajs from ./aimd/init_config_0/relax/0_aimd/
|
|
57
|
-
# make scf dir ./relabel/init_config_0/relax/0_aimd/10-scf/files
|
|
58
|
-
traj_list = search_files(os.path.join(self.aimd_dir, init_config_name), "*/*aimd")
|
|
59
|
-
for traj_dir in traj_list:
|
|
60
|
-
scf_dir = os.path.join(self.scf_dir, init_config_name, \
|
|
61
|
-
os.path.basename(os.path.dirname(traj_dir)),\
|
|
62
|
-
os.path.basename(traj_dir))
|
|
63
54
|
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
traj_format =DFT_STYLE.get_format_by_postfix(traj_file_name),
|
|
70
|
-
interval = self.input_param.interval,
|
|
71
|
-
target_format=DFT_STYLE.get_pwdata_format(self.input_param.scf_style, is_cp2k_coord=True),
|
|
72
|
-
input_file =init_config.scf_input_file,
|
|
73
|
-
kspacing =init_config.scf_kspacing,
|
|
74
|
-
flag_symm =init_config.scf_flag_symm,
|
|
75
|
-
is_dftb = False,
|
|
76
|
-
in_skf =None)
|
|
55
|
+
self.bigmodel_dir = os.path.join(self.input_param.root_dir, TEMP_STRUCTURE.tmp_init_bulk_dir, INIT_BULK.bigmodel)
|
|
56
|
+
self.real_bigmodel_dir = os.path.join(self.input_param.root_dir, INIT_BULK.bigmodel)
|
|
57
|
+
|
|
58
|
+
self.direct_dir = os.path.join(self.bigmodel_dir, INIT_BULK.direct)
|
|
59
|
+
self.real_direct_dir = os.path.join(self.real_bigmodel_dir, INIT_BULK.direct)
|
|
77
60
|
|
|
78
|
-
scf_paths.extend(scf_lsit)
|
|
79
|
-
# make slurm script and slurm job
|
|
80
|
-
self.make_scf_slurm_job_files(scf_paths, use_dftb)
|
|
81
|
-
|
|
82
61
|
def check_work_done(self):
|
|
83
62
|
slurm_remain, slurm_success = get_slurm_job_run_info(self.scf_dir, \
|
|
84
63
|
job_patten="*-{}".format(INIT_BULK.scf_job), \
|
|
85
64
|
tag_patten="*-{}".format(INIT_BULK.scf_tag))
|
|
86
65
|
slurm_done = True if len(slurm_remain) == 0 and len(slurm_success) > 0 else False # len(slurm_remain) > 0 exist slurm jobs need to do
|
|
87
66
|
return slurm_done
|
|
88
|
-
|
|
67
|
+
|
|
68
|
+
def make_scf_work(self):
|
|
69
|
+
def find_position_binary(prefix_sum, N):
|
|
70
|
+
idx = bisect.bisect_right(prefix_sum, N)
|
|
71
|
+
if idx == 0:
|
|
72
|
+
return 0
|
|
73
|
+
elif idx >= len(prefix_sum):
|
|
74
|
+
return (len(prefix_sum)-1)
|
|
75
|
+
else:
|
|
76
|
+
return idx
|
|
77
|
+
|
|
78
|
+
def compute_prefix_sum(arr):
|
|
79
|
+
prefix_sum = []
|
|
80
|
+
current_sum = 0
|
|
81
|
+
for num in arr:
|
|
82
|
+
current_sum += num
|
|
83
|
+
prefix_sum.append(current_sum)
|
|
84
|
+
return prefix_sum
|
|
85
|
+
|
|
86
|
+
candidate = Config(data_path=os.path.join(self.direct_dir, INIT_BULK.direct_traj), format=PWDATA.extxyz)
|
|
87
|
+
# from idx get config idx
|
|
88
|
+
candidate_idx = json.load(open(os.path.join(self.direct_dir, INIT_BULK.candidate_idx)))
|
|
89
|
+
candidate_idx_sum = compute_prefix_sum([candidate_idx[_]['num'] for _ in candidate_idx.keys()])
|
|
90
|
+
_tmp = Config(data_path=os.path.join(self.direct_dir, INIT_BULK.direct_traj), format=PWDATA.extxyz)
|
|
91
|
+
scf_dir_list = []
|
|
92
|
+
if self.input_param.dft_input.scf_max_num is not None:
|
|
93
|
+
random_list = get_random_nums(0, len(candidate.images), self.input_param.dft_input.scf_max_num, seed=2024)
|
|
94
|
+
else:
|
|
95
|
+
random_list = None
|
|
96
|
+
for index, image in enumerate(candidate.images):
|
|
97
|
+
if random_list is not None and index not in random_list:
|
|
98
|
+
continue
|
|
99
|
+
_idx = find_position_binary(candidate_idx_sum, index)
|
|
100
|
+
config_idx = candidate_idx["{}".format(_idx)]['idx']
|
|
101
|
+
scf_dir = os.path.join(self.scf_dir, "{}".format(index))
|
|
102
|
+
if not os.path.exists(scf_dir):
|
|
103
|
+
os.makedirs(scf_dir)
|
|
104
|
+
|
|
105
|
+
_tmp.images = [image]
|
|
106
|
+
_tmp.to(data_path=scf_dir, data_name=PWMAT.atom_config,
|
|
107
|
+
format=PWDATA.pwmat_config)
|
|
108
|
+
self.make_scf_file(
|
|
109
|
+
scf_dir =scf_dir,
|
|
110
|
+
traj_file =os.path.join(scf_dir, PWMAT.atom_config),
|
|
111
|
+
traj_format =PWDATA.pwmat_config,
|
|
112
|
+
target_format=DFT_STYLE.get_pwdata_format(self.input_param.dft_style, is_cp2k_coord=True),
|
|
113
|
+
input_file =self.init_configs[config_idx].scf_input_file,
|
|
114
|
+
kspacing =self.init_configs[config_idx].scf_kspacing,
|
|
115
|
+
flag_symm =self.init_configs[config_idx].scf_flag_symm,
|
|
116
|
+
is_dftb = False,
|
|
117
|
+
in_skf =None)
|
|
118
|
+
|
|
119
|
+
scf_dir_list.append(scf_dir)
|
|
120
|
+
|
|
121
|
+
self.make_scf_slurm_job_files(scf_dir_list)
|
|
122
|
+
|
|
123
|
+
def make_scf_slurm_job_files(self, scf_dir_list:list[str]):
|
|
124
|
+
del_file_list_by_patten(self.scf_dir, "*{}".format(INIT_BULK.scf_job))
|
|
125
|
+
group_list = split_job_for_group(self.resource.dft_resource.group_size, scf_dir_list, self.resource.dft_resource.parallel_num)
|
|
126
|
+
for group_index, group in enumerate(group_list):
|
|
127
|
+
if group[0] == "NONE":
|
|
128
|
+
continue
|
|
129
|
+
jobname = "scf{}".format(group_index)
|
|
130
|
+
tag_name = "{}-{}".format(group_index, INIT_BULK.scf_tag)
|
|
131
|
+
tag = os.path.join(self.scf_dir, tag_name)
|
|
132
|
+
run_cmd = self.resource.dft_resource.command
|
|
133
|
+
group_slurm_script = set_slurm_script_content(gpu_per_node=self.resource.dft_resource.gpu_per_node,
|
|
134
|
+
number_node = self.resource.dft_resource.number_node,
|
|
135
|
+
cpu_per_node = self.resource.dft_resource.cpu_per_node,
|
|
136
|
+
queue_name = self.resource.dft_resource.queue_name,
|
|
137
|
+
custom_flags = self.resource.dft_resource.custom_flags,
|
|
138
|
+
env_script = self.resource.dft_resource.env_script,
|
|
139
|
+
job_name = jobname,
|
|
140
|
+
run_cmd_template = run_cmd,
|
|
141
|
+
group = group,
|
|
142
|
+
job_tag = tag,
|
|
143
|
+
task_tag = INIT_BULK.scf_tag,
|
|
144
|
+
task_tag_faild = INIT_BULK.scf_tag_failed,
|
|
145
|
+
parallel_num=self.resource.dft_resource.parallel_num,
|
|
146
|
+
check_type=None
|
|
147
|
+
)
|
|
148
|
+
slurm_script_name = "{}-{}".format(group_index, INIT_BULK.scf_job)
|
|
149
|
+
slurm_job_file = os.path.join(self.scf_dir, slurm_script_name)
|
|
150
|
+
write_to_file(slurm_job_file, group_slurm_script, "w")
|
|
151
|
+
|
|
89
152
|
def do_scf_jobs(self):
|
|
90
153
|
mission = Mission()
|
|
91
154
|
slurm_remain, slurm_success = get_slurm_job_run_info(self.scf_dir, \
|
|
@@ -111,89 +174,59 @@ class Relabel(object):
|
|
|
111
174
|
mission.all_job_finished(error_type=SLURM_OUT.dft_out)
|
|
112
175
|
# mission.move_slurm_log_to_slurm_work_dir()
|
|
113
176
|
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
177
|
+
def make_scf_file(self,
|
|
178
|
+
scf_dir,
|
|
179
|
+
traj_file ,
|
|
180
|
+
traj_format , # the input is pwmat/config
|
|
181
|
+
target_format,
|
|
182
|
+
input_file ,
|
|
183
|
+
kspacing =None,
|
|
184
|
+
flag_symm =None,
|
|
185
|
+
is_dftb =None,
|
|
186
|
+
in_skf =None,
|
|
187
|
+
atom_names:list[str]=None):
|
|
188
|
+
if DFT_STYLE.pwmat == self.resource.dft_style:
|
|
189
|
+
target_config = traj_file
|
|
190
|
+
pass
|
|
191
|
+
else:
|
|
192
|
+
if DFT_STYLE.vasp == self.resource.dft_style: # when do scf, the vasp input file name is 'POSCAR'
|
|
193
|
+
save_name = VASP.poscar
|
|
194
|
+
else:
|
|
195
|
+
save_name="{}".format(DFT_STYLE.get_normal_config(self.resource.dft_style))# for cp2k this param will be set as coord.xzy
|
|
196
|
+
target_config = save_config(config=traj_file,
|
|
197
|
+
input_format=traj_format,
|
|
132
198
|
wrap = False,
|
|
133
199
|
direct = True,
|
|
134
200
|
sort = True,
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
201
|
+
save_name = save_name,
|
|
202
|
+
save_format=DFT_STYLE.get_pwdata_format(dft_style=self.resource.dft_style, is_cp2k_coord=True),
|
|
203
|
+
save_path=scf_dir,
|
|
204
|
+
atom_names=atom_names)
|
|
138
205
|
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
pseudo_list
|
|
144
|
-
target_dir
|
|
145
|
-
atom_order
|
|
146
|
-
dft_style
|
|
206
|
+
#2.
|
|
207
|
+
atomic_name_list, atomic_number_list = get_atom_type(traj_file, traj_format)
|
|
208
|
+
#1. set pseudo files
|
|
209
|
+
pseudo_names = link_pseudo_by_atom(
|
|
210
|
+
pseudo_list = self.input_param.dft_input.pseudo,
|
|
211
|
+
target_dir = scf_dir,
|
|
212
|
+
atom_order = atomic_name_list,
|
|
213
|
+
dft_style = self.resource.dft_style,
|
|
147
214
|
basis_set_file =self.input_param.dft_input.basis_set_file,
|
|
148
215
|
potential_file =self.input_param.dft_input.potential_file
|
|
149
216
|
)
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
pseudo_names=pseudo_names,
|
|
164
|
-
gaussian_base_param=self.input_param.dft_input.gaussian_base_param,# these for cp2k
|
|
165
|
-
)
|
|
166
|
-
scf_lsit.append(save_dir)
|
|
167
|
-
return scf_lsit
|
|
168
|
-
|
|
169
|
-
def make_scf_slurm_job_files(self, scf_dir_list:list[str],use_dftb: bool=False):
|
|
170
|
-
del_file_list_by_patten(self.scf_dir, "*{}".format(INIT_BULK.scf_job))
|
|
171
|
-
group_list = split_job_for_group(self.resource.scf_resource.group_size, scf_dir_list, self.resource.scf_resource.parallel_num)
|
|
172
|
-
for group_index, group in enumerate(group_list):
|
|
173
|
-
if group[0] == "NONE":
|
|
174
|
-
continue
|
|
175
|
-
jobname = "scf{}".format(group_index)
|
|
176
|
-
tag_name = "{}-{}".format(group_index, INIT_BULK.scf_tag)
|
|
177
|
-
tag = os.path.join(self.scf_dir, tag_name)
|
|
178
|
-
run_cmd = self.resource.scf_resource.command
|
|
179
|
-
group_slurm_script = set_slurm_script_content(gpu_per_node=self.resource.scf_resource.gpu_per_node,
|
|
180
|
-
number_node = self.resource.scf_resource.number_node,
|
|
181
|
-
cpu_per_node = self.resource.scf_resource.cpu_per_node,
|
|
182
|
-
queue_name = self.resource.scf_resource.queue_name,
|
|
183
|
-
custom_flags = self.resource.scf_resource.custom_flags,
|
|
184
|
-
env_script = self.resource.scf_resource.env_script,
|
|
185
|
-
job_name = jobname,
|
|
186
|
-
run_cmd_template = run_cmd,
|
|
187
|
-
group = group,
|
|
188
|
-
job_tag = tag,
|
|
189
|
-
task_tag = INIT_BULK.scf_tag,
|
|
190
|
-
task_tag_faild = INIT_BULK.scf_tag_failed,
|
|
191
|
-
parallel_num=self.resource.scf_resource.parallel_num,
|
|
192
|
-
check_type=self.resource.scf_style
|
|
193
|
-
)
|
|
194
|
-
slurm_script_name = "{}-{}".format(group_index, INIT_BULK.scf_job)
|
|
195
|
-
slurm_job_file = os.path.join(self.scf_dir, slurm_script_name)
|
|
196
|
-
write_to_file(slurm_job_file, group_slurm_script, "w")
|
|
217
|
+
|
|
218
|
+
#2. make etot.input file
|
|
219
|
+
set_input_script(
|
|
220
|
+
input_file=input_file,
|
|
221
|
+
config=target_config,
|
|
222
|
+
dft_style=self.resource.dft_style,
|
|
223
|
+
kspacing=kspacing,
|
|
224
|
+
flag_symm=flag_symm,
|
|
225
|
+
save_dir = scf_dir,
|
|
226
|
+
pseudo_names=pseudo_names,
|
|
227
|
+
gaussian_base_param=self.input_param.dft_input.gaussian_base_param,# these for cp2k
|
|
228
|
+
is_scf = True
|
|
229
|
+
)
|
|
197
230
|
|
|
198
231
|
def do_post_process(self):
|
|
199
232
|
if os.path.exists(self.scf_dir):
|