pwact 0.1.25__py3-none-any.whl → 0.1.27__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.
@@ -26,6 +26,7 @@ from pwact.utils.constant import AL_STRUCTURE, TEMP_STRUCTURE, EXPLORE_FILE_STRU
26
26
  from pwact.utils.format_input_output import get_iter_from_iter_name, get_sub_md_sys_template_name,\
27
27
  make_md_sys_name, get_md_sys_template_name, make_temp_press_name, make_temp_name, make_train_name
28
28
  from pwact.utils.file_operation import write_to_file, add_postfix_dir, link_file, read_data, search_files, copy_dir, copy_file, del_file, del_dir, del_file_list, del_file_list_by_patten, mv_file
29
+ from pwact.utils.draw.hist_model_devi import draw_hist_list
29
30
  from pwact.utils.app_lib.lammps import make_lammps_input
30
31
  from pwact.data_format.configop import save_config, get_atom_type
31
32
 
@@ -288,7 +289,16 @@ class Explore(object):
288
289
  '''
289
290
  def post_process_md(self):
290
291
  md_sys_dir_list = search_files(self.md_dir, get_md_sys_template_name())
292
+ # draw model deviation
291
293
  is_kpu = self.input_param.strategy.uncertainty.upper() == UNCERTAINTY.kpu.upper()
294
+ if is_kpu is False:
295
+ for md_sys_dir in md_sys_dir_list:
296
+ draw_hist_list(file_path=[md_sys_dir],
297
+ legend_label=["{}-{}".format(self.itername, os.path.basename(md_sys_dir))],
298
+ save_path = os.path.join(md_sys_dir, "model_devi_distribution.png"),
299
+ low=self.input_param.strategy.lower_model_deiv_f,
300
+ high=self.input_param.strategy.upper_model_deiv_f)
301
+
292
302
  for md_sys_dir in md_sys_dir_list:
293
303
  sub_md_sys_dir_list =search_files(md_sys_dir, get_md_sys_template_name())
294
304
  for sub_md_sys in sub_md_sys_dir_list:
@@ -313,6 +323,13 @@ class Explore(object):
313
323
  copy_file(file, os.path.join(self.real_md_dir, os.path.basename(file)))
314
324
  for file in md_slurm_scripts:
315
325
  copy_file(file, os.path.join(self.real_md_dir, os.path.basename(file)))
326
+ if os.path.exists(os.path.join(md_sys_dir, "model_devi_distribution.png")):
327
+ copy_file(os.path.join(md_sys_dir, "model_devi_distribution.png"),
328
+ os.path.join(self.real_md_dir, os.path.basename(md_sys_dir), "model_devi_distribution.png"))
329
+ link_file(
330
+ os.path.join(self.real_md_dir, os.path.basename(md_sys_dir), "model_devi_distribution.png"),
331
+ os.path.join(self.select_dir, "model_devi_distribution-{}.png".format(os.path.basename(md_sys_dir)))
332
+ )
316
333
  copy_dir(self.select_dir, self.real_select_dir)
317
334
 
318
335
  '''
@@ -25,7 +25,7 @@ def cmd_infos(cmd_type=None):
25
25
  cmd_info += "you could use this method to extract pwdatas after active learing done.\nFor more detail for this command, you could use 'pwact gather_pwdata -h'\n\n"
26
26
 
27
27
  cmd_info += "filter" + "\n"
28
- cmd_info += "you could use this method to test the selection results corresponding to the upper and lower limit settings, you could use 'pwact filter -h'\n"
28
+ cmd_info += "you could use this method to test the selection results corresponding to the upper and lower limit settings, you could use 'pwact filter -h'\n\n"
29
29
 
30
30
  cmd_info += "to_pwdata".lower() + "\n"
31
31
  cmd_info += "(This method has been abandoned, new conversion methods refer to the pwdata documentation http://doc.lonxun.com/PWMLFF/Appendix-2/)\n\n"
File without changes
@@ -0,0 +1,132 @@
1
+ import os
2
+ import numpy as np
3
+
4
+ # import numpy as np
5
+ import matplotlib.pyplot as plt
6
+
7
+ mark_list = ["o", "^", "v", "X", "|", "*", "v", "+", '*', ' ']
8
+ color_list = ["#006400", "#FF8C00", "#B22222", "#FF8C00" ,"#ff0099" ,\
9
+ "#000000" , "#BDB76B", "#999900" ,"#009999" ,"#000099" ,"#990099", "#ff9900" ]
10
+ linestyle_list = ["--", "--", "--", "-", "-", "-"]
11
+
12
+ def draw_hists_2(data, save_path, min, max, legend_label):
13
+ bins = np.linspace(0, max, 100) # 根据需要调整bin的数量和范围
14
+ alpha = 0.5 # 透明度设置
15
+ plt.figure(figsize=(10, 6)) # 设置图形的大小
16
+
17
+ for i, _data in enumerate(data):
18
+ plt.hist(_data, bins=bins, alpha=alpha, label=legend_label[i], density=True)
19
+
20
+ # 设置坐标轴范围
21
+ plt.xlim(min, max)
22
+
23
+ # 添加标题、标签、图例
24
+ plt.title('Distribution of model deviation', fontsize=18, fontweight='bold', family='serif')
25
+ plt.xlabel('Model Deviation', fontsize=14, fontweight='bold', family='serif')
26
+ plt.ylabel('Frequency', fontsize=14, fontweight='bold', family='serif')
27
+
28
+ # 设置图例
29
+ plt.legend(loc='upper right', fontsize=15, title_fontsize='large')
30
+
31
+ # 调整坐标轴的字体大小
32
+ plt.tick_params(axis='both', labelsize=15)
33
+
34
+ # 添加网格
35
+ plt.grid(True, linestyle='--', alpha=0.7)
36
+
37
+ # 保存图像
38
+ plt.savefig(save_path, dpi=300, bbox_inches='tight')
39
+ plt.close()
40
+
41
+ def read_model_devi(file_path, low=None, high=None):
42
+ devi_files = []
43
+ for path, dirList, fileList in os.walk(file_path):
44
+ for _ in fileList:
45
+ if "model_devi.out" in _:
46
+ devi_files.append(os.path.join(path, _))
47
+ data = []
48
+ for file in devi_files:
49
+ _data = np.loadtxt(file, skiprows=0)
50
+ if _data.shape[0] > 1:
51
+ data.extend(list(_data[:, 1])) # force
52
+
53
+ right = 0
54
+ mid = 0
55
+ error = 0
56
+ if low is not None:
57
+ for d in data:
58
+ if d <= low:
59
+ right += 1
60
+ elif d > low and d <= high:
61
+ mid += 1
62
+ else:
63
+ error += 1
64
+ return data, devi_files, right, mid, error
65
+
66
+ def draw_hist_list(file_path:list[str], legend_label, save_path:str, low=None, high=None) :
67
+ data = []
68
+ min = None
69
+ max = None
70
+ abs_mean = []
71
+ abs_max = []
72
+ mid = 0
73
+ error = 0
74
+ right = 0
75
+ for file in file_path:
76
+ _data, devi_files, _right, _mid, _error = read_model_devi(file, low, high)
77
+ right += _right
78
+ mid += _mid
79
+ error += _error
80
+ _min = np.min(_data)
81
+ _max = np.max(_data)
82
+ min = _min if (min is None or _min < min) else min
83
+ max = _max if (max is None or _max > max) else max
84
+ data.append(_data)
85
+ abs_mean.append(np.mean(_data))
86
+ abs_max.append(np.max(_data))
87
+
88
+ for i in range(0, len(legend_label)):
89
+ if low is not None:
90
+ legend_label[i] = "{}\nmean {} max {} right {} candidate {} error {}".format(legend_label[i], round(abs_mean[i], 3), round(abs_max[i], 3), right, mid, error)
91
+ else:
92
+ legend_label[i] = "{}\nmean {} max {}".format(legend_label[i], round(abs_mean[i], 5), round(abs_max[i], 5))
93
+ # print(legend_label)
94
+ new_data = []
95
+ for id, d in enumerate(data):
96
+ tmp = []
97
+ for _d in d:
98
+ if _d > 1.0:
99
+ tmp.append(1.0)
100
+ else:
101
+ tmp.append(_d)
102
+ new_data.append(tmp)
103
+ max = 1.0 if max > 1.0 else max
104
+ draw_hists_2(new_data, save_path, min, max, legend_label)
105
+
106
+
107
+
108
+
109
+ if __name__ == "__main__":
110
+ legend_label = ["iter.0006/md/md.000.sys.000"]
111
+ save_dir = "/data/home/wuxingxing/datas/al_dir/djp/iter.0006/explore/md/md.000.sys.002"
112
+ draw_hist_list([
113
+ "/data/home/wuxingxing/datas/al_dir/djp/iter.0006/explore/md/md.000.sys.002"
114
+ ], legend_label, save_path=os.path.join(save_dir, "hist_mode_deiv_md.000.sys.002.png"))
115
+
116
+ legend_label = ["iter.0006/md/md.000.sys.001"]
117
+ save_dir = "/data/home/wuxingxing/datas/al_dir/djp/iter.0006/explore/md/md.000.sys.000"
118
+ draw_hist_list([
119
+ "/data/home/wuxingxing/datas/al_dir/djp/iter.0006/explore/md/md.000.sys.000"
120
+ ], legend_label, save_path=os.path.join(save_dir, "hist_mode_deiv_md.000.sys.000.png"))
121
+
122
+ legend_label = ["iter.0006/md/md.000.sys.002"]
123
+ save_dir = "/data/home/wuxingxing/datas/al_dir/djp/iter.0006/explore/md/md.000.sys.001"
124
+ draw_hist_list([
125
+ "/data/home/wuxingxing/datas/al_dir/djp/iter.0006/explore/md/md.000.sys.001"
126
+ ], legend_label, save_path=os.path.join(save_dir, "hist_mode_deiv_md.000.sys.001.png"))
127
+
128
+ legend_label = ["iter.0006/md/md.000.sys.003"]
129
+ save_dir = "/data/home/wuxingxing/datas/al_dir/djp/iter.0006/explore/md/md.000.sys.003"
130
+ draw_hist_list([
131
+ "/data/home/wuxingxing/datas/al_dir/djp/iter.0006/explore/md/md.000.sys.003"
132
+ ], legend_label, save_path=os.path.join(save_dir, "hist_mode_deiv_md.000.sys.003.png"), low=0.1, high=0.2)
@@ -65,7 +65,12 @@ def file_read_lines(file_path, data_type="float"):
65
65
 
66
66
  '''
67
67
  description:
68
- load txt data
68
+ load txt data: the content as :
69
+ # step avg_devi_f min_devi_f max_devi_f avg_devi_e min_devi_e max_devi_e
70
+ 0 0.016176053 0.000004773 0.023921006 0.494110683 0.007786004 0.680908664
71
+ 10 0.020843630 0.000576891 0.033193308 0.481147298 0.001424875 0.696843965
72
+ 20 0.020738273 0.001127881 0.031809715 0.478043120 0.001433802 0.703810561
73
+ ...
69
74
  param {str} file_path
70
75
  param {*} skiprows
71
76
  return {*}
pwact/utils/tmp.py CHANGED
@@ -2,8 +2,8 @@ from pwdata import Config
2
2
  import os, sys, glob
3
3
  import numpy as np
4
4
 
5
- def count_pwdata():
6
- work_dir = "/data/home/wuxingxing/datas/debugs/dengjiapei/run_iter/mlmd_pwdata"
5
+ def count_pwdata(work_dir):
6
+
7
7
  dir_list = glob.glob(os.path.join(work_dir, "*"))
8
8
  res = []
9
9
  for dir in dir_list:
@@ -58,6 +58,6 @@ def save_mlmd():
58
58
 
59
59
 
60
60
  if __name__=="__main__":
61
- count_pwdata()
61
+ count_pwdata(work_dir = "/data/home/wuxingxing/datas/debugs/dengjiapei/run_iter/mlmd_pwdata")
62
62
  # count_outmlmd()
63
63
  # save_mlmd()
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: pwact
3
- Version: 0.1.25
3
+ Version: 0.1.27
4
4
  Summary: PWACT is an open-source automated active learning platform based on PWMLFF for efficient data sampling.
5
5
  Home-page: https://github.com/LonxunQuantum/PWact
6
6
  Author: LonxunQuantum
@@ -3,7 +3,7 @@ pwact/main.py,sha256=EKFcwo_gk9BWhg3zU36RW7NXMLDfyhzrtjtvcv4h5dQ,17036
3
3
  pwact/active_learning/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
4
4
  pwact/active_learning/environment.py,sha256=KvyMaOXrM-HMMma4SnoOQFO6fZxDsk0Fsyyy7xqfGCo,684
5
5
  pwact/active_learning/explore/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
6
- pwact/active_learning/explore/run_model_md.py,sha256=uSW-ZaXH7NHexnMDm3Qb7ny4rRhk9KZ3dds2D9AVDeo,19891
6
+ pwact/active_learning/explore/run_model_md.py,sha256=opflniIxbT8SSPNwkGXcd8j_GVpWvDexhFhxYXXO8Yk,21053
7
7
  pwact/active_learning/explore/select_image.py,sha256=dmsMoxFwQ7JDPHK2vRFzUfXeEovT86cmUnmEm-qrfwE,12665
8
8
  pwact/active_learning/init_bulk/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
9
9
  pwact/active_learning/init_bulk/aimd.py,sha256=XzDlX2vylaljQKoUnv6nrI2NfiOdHZpq8qr3DenA1F4,10465
@@ -22,7 +22,7 @@ pwact/active_learning/train/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMp
22
22
  pwact/active_learning/train/dp_kpu.py,sha256=GkGKEGhLmOvPERqgTkf_0_vD9zOEPlBX2N7vuSQG_-c,9317
23
23
  pwact/active_learning/train/train_model.py,sha256=NXqTKrl7Lb_UGt2-Lq_gLM9iZDAZFY09nxP_aGtBdrE,10525
24
24
  pwact/active_learning/user_input/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
25
- pwact/active_learning/user_input/cmd_infos.py,sha256=3oWe9AhCxM9rWcRs3bezD7pb1TC5o0bCcvg-k36xEPY,3726
25
+ pwact/active_learning/user_input/cmd_infos.py,sha256=g1QW5Wi3JvmC5xEY4F-7AO1xBuJSjHG8IhZjom8haxQ,3728
26
26
  pwact/active_learning/user_input/init_bulk_input.py,sha256=NCUAB1xpa67MXHRRWAkmWZjkQbTibE4EjmtlOmr0HdQ,6762
27
27
  pwact/active_learning/user_input/iter_input.py,sha256=zwFCI6dDFIEVWitEqBBZP7TtrSvxMbmSUEPiM0Z8ZOk,10732
28
28
  pwact/active_learning/user_input/resource.py,sha256=bg1rkdjIzuj7pDUvp6h1yMWFT0PqYzH4BfX5tJ7MZzc,6812
@@ -40,22 +40,24 @@ pwact/data_format/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU
40
40
  pwact/data_format/configop.py,sha256=S2WaES4-9_FX_o6fLaBMw2uSIF1cUMLGj9APRRASy6Q,11984
41
41
  pwact/utils/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
42
42
  pwact/utils/constant.py,sha256=ZM43rI0JNHA_nVKdRW1YvPGCEkomRNgdmA3_L8hAVSY,18379
43
- pwact/utils/file_operation.py,sha256=O26X-qUQuSkVRSVnJx4BPDrPtueVW7sfNvdJ_Y-PN2Q,8554
43
+ pwact/utils/file_operation.py,sha256=LFQ247afF_nUhxagZTYqIYs9GrJCwsiI2EuDhoxWIKQ,9032
44
44
  pwact/utils/format_input_output.py,sha256=oYFydQy3-btXzieO2O2LbHFoeRyhPnLVE4c5TNgS-IQ,1798
45
45
  pwact/utils/json_operation.py,sha256=BqBsnIjk1URoMW_s2yu7Gk8IBxlir-oo6ivt8P3RIqg,1794
46
46
  pwact/utils/pre_al_data_util.py,sha256=QE-axnVYUIyORFiVs-WK9-UaJlMUFY816_rSyYOOJc8,2542
47
47
  pwact/utils/process_tool.py,sha256=trzp6GbP_SYFiS_vheobV_FI4PSWVJvX3xHsFQ6DWME,478
48
48
  pwact/utils/slurm_script.py,sha256=mgueOrhYteg6XXvJitdjmbV4lzxMujuna9Jxr3wgC7Q,8237
49
- pwact/utils/tmp.py,sha256=SFzYEcNz-5rB0k2Os2tScBqiW3DMCepkuTqcsSE7RrQ,2277
49
+ pwact/utils/tmp.py,sha256=en_GltoNwfA40vSHttMRi9cEg-8xnPZlvnnBq1_vHfw,2285
50
50
  pwact/utils/app_lib/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
51
51
  pwact/utils/app_lib/common.py,sha256=lQmI-9Qumq62MNjr-eVlLL88ISDHBOb6vAfYYFcDIgM,6040
52
52
  pwact/utils/app_lib/cp2k.py,sha256=ljhCCHmZ2kfoXEXn5O7-D56EgTLn2a7H3y_TIkHiasY,13157
53
53
  pwact/utils/app_lib/cp2k_dp.py,sha256=VP4gyPGhLcMAqAjrqCQSUiiGlESNlyYz7Gs3Q4QoUHo,6912
54
54
  pwact/utils/app_lib/lammps.py,sha256=2oxHJHdDxfDDWWmnjo0gMNwgGvxABwuDgDlb8kbhgfk,8037
55
55
  pwact/utils/app_lib/pwmat.py,sha256=PTRPkG_d00ibGhpCe2-4M7MW3dx2ZuAyb9hT2jl_LAs,18047
56
- pwact-0.1.25.dist-info/LICENSE,sha256=OXLcl0T2SZ8Pmy2_dmlvKuetivmyPd5m1q-Gyd-zaYY,35149
57
- pwact-0.1.25.dist-info/METADATA,sha256=zcuKIBxeaicBdKupPFrFCKBd5x04ErxG4lhPX_7uTJQ,3659
58
- pwact-0.1.25.dist-info/WHEEL,sha256=2wepM1nk4DS4eFpYrW1TTqPcoGNfHhhO_i5m4cOimbo,92
59
- pwact-0.1.25.dist-info/entry_points.txt,sha256=p61auAnpbn8E2WjvHNBA7rb9_NRAOCew4zdcCj33cGc,42
60
- pwact-0.1.25.dist-info/top_level.txt,sha256=fY1_7sH5Lke4dC9L8MbYM4fT5aat5eCkAmpkIzY1SlM,6
61
- pwact-0.1.25.dist-info/RECORD,,
56
+ pwact/utils/draw/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
57
+ pwact/utils/draw/hist_model_devi.py,sha256=o1Try-ekith2A7S6u1mt3zuTqaQwyw5tdURReh8BeLY,4945
58
+ pwact-0.1.27.dist-info/LICENSE,sha256=OXLcl0T2SZ8Pmy2_dmlvKuetivmyPd5m1q-Gyd-zaYY,35149
59
+ pwact-0.1.27.dist-info/METADATA,sha256=Kk2-JzZqYkUYiqFRbvXMFLiJBj5hV-jIITIG1U2G8q0,3659
60
+ pwact-0.1.27.dist-info/WHEEL,sha256=2wepM1nk4DS4eFpYrW1TTqPcoGNfHhhO_i5m4cOimbo,92
61
+ pwact-0.1.27.dist-info/entry_points.txt,sha256=p61auAnpbn8E2WjvHNBA7rb9_NRAOCew4zdcCj33cGc,42
62
+ pwact-0.1.27.dist-info/top_level.txt,sha256=fY1_7sH5Lke4dC9L8MbYM4fT5aat5eCkAmpkIzY1SlM,6
63
+ pwact-0.1.27.dist-info/RECORD,,
File without changes