surface-construct 0.10.1__tar.gz → 0.10.3__tar.gz

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.
Files changed (30) hide show
  1. {surface_construct-0.10.1/surface_construct.egg-info → surface_construct-0.10.3}/PKG-INFO +5 -7
  2. {surface_construct-0.10.1 → surface_construct-0.10.3}/README.md +4 -6
  3. {surface_construct-0.10.1 → surface_construct-0.10.3}/setup.py +1 -1
  4. {surface_construct-0.10.1 → surface_construct-0.10.3}/surface_construct/structures/surface_grid.py +37 -21
  5. {surface_construct-0.10.1 → surface_construct-0.10.3}/surface_construct/utils/__init__.py +1 -1
  6. {surface_construct-0.10.1 → surface_construct-0.10.3/surface_construct.egg-info}/PKG-INFO +5 -7
  7. {surface_construct-0.10.1 → surface_construct-0.10.3}/tests/test_simple_surface.py +1 -1
  8. {surface_construct-0.10.1 → surface_construct-0.10.3}/LICENSE +0 -0
  9. {surface_construct-0.10.1 → surface_construct-0.10.3}/setup.cfg +0 -0
  10. {surface_construct-0.10.1 → surface_construct-0.10.3}/surface_construct/__init__.py +0 -0
  11. {surface_construct-0.10.1 → surface_construct-0.10.3}/surface_construct/db.py +0 -0
  12. {surface_construct-0.10.1 → surface_construct-0.10.3}/surface_construct/default_parameter.py +0 -0
  13. {surface_construct-0.10.1 → surface_construct-0.10.3}/surface_construct/sg_sampler.py +0 -0
  14. {surface_construct-0.10.1 → surface_construct-0.10.3}/surface_construct/structures/__init__.py +0 -0
  15. {surface_construct-0.10.1 → surface_construct-0.10.3}/surface_construct/structures/adsorbate.py +0 -0
  16. {surface_construct-0.10.1 → surface_construct-0.10.3}/surface_construct/structures/surface.py +0 -0
  17. {surface_construct-0.10.1 → surface_construct-0.10.3}/surface_construct/tasks/__init__.py +0 -0
  18. {surface_construct-0.10.1 → surface_construct-0.10.3}/surface_construct/tasks/sitesampling.py +0 -0
  19. {surface_construct-0.10.1 → surface_construct-0.10.3}/surface_construct/tasks/taskbase.py +0 -0
  20. {surface_construct-0.10.1 → surface_construct-0.10.3}/surface_construct/tasks/terminations.py +0 -0
  21. {surface_construct-0.10.1 → surface_construct-0.10.3}/surface_construct/utils/atoms.py +0 -0
  22. {surface_construct-0.10.1 → surface_construct-0.10.3}/surface_construct/utils/weight_functions.py +0 -0
  23. {surface_construct-0.10.1 → surface_construct-0.10.3}/surface_construct.egg-info/SOURCES.txt +0 -0
  24. {surface_construct-0.10.1 → surface_construct-0.10.3}/surface_construct.egg-info/dependency_links.txt +0 -0
  25. {surface_construct-0.10.1 → surface_construct-0.10.3}/surface_construct.egg-info/requires.txt +0 -0
  26. {surface_construct-0.10.1 → surface_construct-0.10.3}/surface_construct.egg-info/top_level.txt +0 -0
  27. {surface_construct-0.10.1 → surface_construct-0.10.3}/tests/test_sampling1.py +0 -0
  28. {surface_construct-0.10.1 → surface_construct-0.10.3}/tests/test_sampling2.py +0 -0
  29. {surface_construct-0.10.1 → surface_construct-0.10.3}/tests/test_surface_grid.py +0 -0
  30. {surface_construct-0.10.1 → surface_construct-0.10.3}/tests/test_task.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: surface_construct
3
- Version: 0.10.1
3
+ Version: 0.10.3
4
4
  Summary: Surface termination construction especially for complex model, such as oxides or carbides.
5
5
  Home-page: https://gitee.com/pjren/surface_construct/
6
6
  Author: ren
@@ -34,16 +34,10 @@ Dynamic: summary
34
34
 
35
35
  本软件同时进行表面位点的构建、采样、计算、分析,和反应过程的分析采样,即过渡态和分子构象,由此可以实现分子在表面反应的全过程采样。其中的技术关键是采样的效率,我们针对性地使用综合使用了多样化的采样策略,保证表面各类型位点和关键位点的充分采样。
36
36
 
37
-
38
-
39
37
  <img src="docs/birds_view.png" alt="表面位点全局分析" style="zoom:50%;" />
40
38
 
41
-
42
-
43
39
  ## 程序流程图 Program Workflow
44
40
 
45
-
46
-
47
41
  ![flowchart](docs/modules-计算流程.jpg)
48
42
 
49
43
  ## 重要的概念 Glossary
@@ -155,11 +149,14 @@ $$
155
149
  * v 0.8: 孔材料体系格点构造
156
150
  * v 0.9: 重新梳理软件的模块,优化软件使用逻辑
157
151
  * v 0.9.2: debug 支持三斜晶系的表面格点化
152
+ * v 0.9.3: debug GridGenerator
153
+ * v 0.10: 表面终结生成完整并入
158
154
 
159
155
  **TODO**
160
156
 
161
157
  * 计算位点 SALI (Structure-Activity Landscape Index),量化 activity cliffs,SALI = |ΔActivity| / (1 − Similarity)
162
158
  * 新增 PathSampler,用于在相邻的关键格点之间的扩散路径进行采样,使用 ase.neb.idpp 方法进行采样,使用 Delaunay 剖分找到相邻位点的路径。
159
+ * Low-Energy Region Explorer 方法借鉴[^LoreX]: 划分能量区域, 进行 Delaunay 划分,合并较小的区域为较大的区域。然后针对低能的区域进行额外采样。也可以适用不同的方法,低精度进行低能高能区域识别,然后高精度方法加强。
163
160
  * 表面位点数据库
164
161
  * 多原子体系(内坐标受限体系)
165
162
  * 完善用户界面、例子、教程
@@ -171,4 +168,5 @@ $$
171
168
  [^BASC]: Shane Carr, Roman Garnett, Cynthia LoBASC: Applying Bayesian Optimization to the Search for Global Minima on Potential Energy Surfaces.
172
169
 
173
170
  [^向量空间转化]: 计算实空间和向量空间的相邻格点距离的映射系数,根据此系数将实空间的距离转化为向量空间距离。
171
+ [^LoreX]: Chuan-Nan Li, Han-Pu Liang, Siyuan Xu, Haochen Wang, Bai-Qing Zhao, Jingxiu Yang, Xie Zhang, Zijing Lin, Su-Huai Wei, LoreX: A Low-Energy Region Explorer Boosts Efficient Crystal Structure Prediction, J. Am. Chem. Soc. 2025, 147, 11, 9544–9555.
174
172
 
@@ -4,16 +4,10 @@
4
4
 
5
5
  本软件同时进行表面位点的构建、采样、计算、分析,和反应过程的分析采样,即过渡态和分子构象,由此可以实现分子在表面反应的全过程采样。其中的技术关键是采样的效率,我们针对性地使用综合使用了多样化的采样策略,保证表面各类型位点和关键位点的充分采样。
6
6
 
7
-
8
-
9
7
  <img src="docs/birds_view.png" alt="表面位点全局分析" style="zoom:50%;" />
10
8
 
11
-
12
-
13
9
  ## 程序流程图 Program Workflow
14
10
 
15
-
16
-
17
11
  ![flowchart](docs/modules-计算流程.jpg)
18
12
 
19
13
  ## 重要的概念 Glossary
@@ -125,11 +119,14 @@ $$
125
119
  * v 0.8: 孔材料体系格点构造
126
120
  * v 0.9: 重新梳理软件的模块,优化软件使用逻辑
127
121
  * v 0.9.2: debug 支持三斜晶系的表面格点化
122
+ * v 0.9.3: debug GridGenerator
123
+ * v 0.10: 表面终结生成完整并入
128
124
 
129
125
  **TODO**
130
126
 
131
127
  * 计算位点 SALI (Structure-Activity Landscape Index),量化 activity cliffs,SALI = |ΔActivity| / (1 − Similarity)
132
128
  * 新增 PathSampler,用于在相邻的关键格点之间的扩散路径进行采样,使用 ase.neb.idpp 方法进行采样,使用 Delaunay 剖分找到相邻位点的路径。
129
+ * Low-Energy Region Explorer 方法借鉴[^LoreX]: 划分能量区域, 进行 Delaunay 划分,合并较小的区域为较大的区域。然后针对低能的区域进行额外采样。也可以适用不同的方法,低精度进行低能高能区域识别,然后高精度方法加强。
133
130
  * 表面位点数据库
134
131
  * 多原子体系(内坐标受限体系)
135
132
  * 完善用户界面、例子、教程
@@ -141,4 +138,5 @@ $$
141
138
  [^BASC]: Shane Carr, Roman Garnett, Cynthia LoBASC: Applying Bayesian Optimization to the Search for Global Minima on Potential Energy Surfaces.
142
139
 
143
140
  [^向量空间转化]: 计算实空间和向量空间的相邻格点距离的映射系数,根据此系数将实空间的距离转化为向量空间距离。
141
+ [^LoreX]: Chuan-Nan Li, Han-Pu Liang, Siyuan Xu, Haochen Wang, Bai-Qing Zhao, Jingxiu Yang, Xie Zhang, Zijing Lin, Su-Huai Wei, LoreX: A Low-Energy Region Explorer Boosts Efficient Crystal Structure Prediction, J. Am. Chem. Soc. 2025, 147, 11, 9544–9555.
144
142
 
@@ -15,7 +15,7 @@ install_requires = [
15
15
 
16
16
  setup(
17
17
  name='surface_construct',
18
- version='0.10.1',
18
+ version='0.10.3',
19
19
  packages=find_packages(),
20
20
  url='https://gitee.com/pjren/surface_construct/',
21
21
  license='GPL',
@@ -5,30 +5,17 @@ TODO: 双结合位点情况。表面位点采样[(x1, y1, z1), (x2, y2, z2)]。
5
5
  TODO: 构效关系建立。将不同的位点向量合并,然后进行性能分布的关联,投影到二维平面(PCA)。
6
6
  """
7
7
  import itertools
8
- import pickle
9
-
10
8
  import ase
11
- import matplotlib.tri as mtri
12
9
  import networkx as nx
13
10
  import numpy as np
14
11
  from ase.data import covalent_radii, vdw_radii, chemical_symbols
15
- from ase.geometry import find_mic
16
12
  from ase.neighborlist import natural_cutoffs, primitive_neighbor_list
17
- from ase.visualize import view
18
- from matplotlib import pyplot as plt
19
- from scipy.interpolate import griddata
20
13
  from scipy.sparse import coo_matrix
21
14
  from scipy.spatial import cKDTree
22
15
  from scipy.spatial.distance import euclidean
23
16
  from sklearn.decomposition import PCA
24
- from sklearn.gaussian_process import GaussianProcessRegressor
25
- from sklearn.gaussian_process.kernels import RBF, ConstantKernel, WhiteKernel
26
- from sklearn.preprocessing import StandardScaler
27
-
28
- from surface_construct.sg_sampler import InitialSGSampler, addition_samples
29
17
  from surface_construct.utils import get_calc_info, get_distances, get_graph_core, wrap_grid, \
30
18
  filter_index_label, rattle, iso_surface, extended_points
31
- from surface_construct.utils.weight_functions import vb_weight
32
19
 
33
20
 
34
21
  class DoNothing:
@@ -353,6 +340,8 @@ class GridGenerator:
353
340
  return self._grid
354
341
 
355
342
  def view(self, tag=None):
343
+ from ase.visualize import view
344
+
356
345
  if len(self.grid) > 10000:
357
346
  print("Too much grid number, it will be very slow.")
358
347
  atoms = ase.Atoms(symbols=['X'] * len(self.grid), positions=self.grid)
@@ -410,13 +399,6 @@ class SurfaceGrid:
410
399
 
411
400
  self.atoms = atoms
412
401
  self.subtype = subtype
413
- if self.subtype == 'slab':
414
- self.pbc = [True, True, False]
415
- elif self.subtype == 'cluster':
416
- self.pbc = [False, False, False]
417
- else:
418
- self.pbc = self.atoms.pbc
419
-
420
402
  num_set = set(self.atoms.numbers)
421
403
  num_list = list(self.atoms.numbers)
422
404
  self.species = sorted([(num, num_list.count(num)) for num in num_set], key=lambda x: x[0])
@@ -484,6 +466,15 @@ class SurfaceGrid:
484
466
  # 格点向量化
485
467
  self.vectorize()
486
468
 
469
+ @property
470
+ def pbc(self):
471
+ if self.subtype == 'slab':
472
+ return [True, True, False]
473
+ elif self.subtype == 'cluster':
474
+ return [False, False, False]
475
+ else:
476
+ return self.atoms.pbc
477
+
487
478
  def gridize(self, **kwargs):
488
479
  """
489
480
  格点化。
@@ -496,6 +487,7 @@ class SurfaceGrid:
496
487
  if subtype is None:
497
488
  subtype = 'slab' # default is slab
498
489
  self.subtype = subtype
490
+
499
491
  gridgen = GridGenerator(self.atoms,
500
492
  interval=self.interval, subtype=subtype, rads=self.rads, rsub=self.rsub)
501
493
  self._gridgen = gridgen
@@ -696,12 +688,16 @@ class SurfaceGrid:
696
688
  :param grid_idx:
697
689
  :return:
698
690
  """
691
+ from ase.geometry import find_mic
692
+
699
693
  order = np.argsort(self._Dga[grid_idx])
700
694
  p1, p2 = self.atoms.positions[order[0:2]]
701
695
  v, _ = find_mic(p2-p1, cell=self.atoms.cell, pbc=self.atoms.pbc)
702
696
  return v
703
697
 
704
698
  def view_grid(self, tag=None):
699
+ from ase.visualize import view
700
+
705
701
  if len(self.points) > 10000:
706
702
  print("Too much grid number, it will be very slow.")
707
703
 
@@ -719,7 +715,7 @@ class SurfaceGrid:
719
715
  else:
720
716
  return None
721
717
 
722
- def vectorize(self, wf=vb_weight, pca_ratio=0.9, **kwargs):
718
+ def vectorize(self, wf=None, pca_ratio=0.9, **kwargs):
723
719
  """
724
720
  TODO: 使用 DScribe 来进行向量化,并进行测试。如何测试?测试什么内容?
725
721
  TODO: 产生 cluster_mesh, 生成 cluster_mesh_id 与 point_id 之间的正反向 dict
@@ -728,6 +724,10 @@ class SurfaceGrid:
728
724
  :param kwargs:
729
725
  :return:
730
726
  """
727
+ if wf is None:
728
+ from surface_construct.utils.weight_functions import vb_weight
729
+ wf = vb_weight
730
+
731
731
  kwargs['pbc'] = kwargs.get('pbc',self.pbc)
732
732
  kwargs['r0_dict'] = kwargs.get('r0_dict', {atomnum:self.rads+r
733
733
  for atomnum,r in zip(self.atoms.numbers, self.rsub)})
@@ -799,6 +799,8 @@ class SurfaceGrid:
799
799
  :param figname:
800
800
  :return:
801
801
  """
802
+ from matplotlib import pyplot as plt
803
+
802
804
  if figname is None:
803
805
  figname = 'site_cluster.png'
804
806
  print("Plot the site verctor and cluster ...")
@@ -873,6 +875,10 @@ class SurfaceGrid:
873
875
  self.sample_dct[idx]['calculated'] = True
874
876
 
875
877
  def fit(self, key='energy'):
878
+ from sklearn.gaussian_process import GaussianProcessRegressor
879
+ from sklearn.gaussian_process.kernels import RBF, ConstantKernel, WhiteKernel
880
+ from sklearn.preprocessing import StandardScaler
881
+
876
882
  # Standardization of y
877
883
  scaler = StandardScaler()
878
884
  y = np.atleast_2d([self.sample_dct[idx][key] for idx in self.calculated_sample]).T
@@ -958,6 +964,8 @@ class SurfaceGrid:
958
964
  :param key:
959
965
  :return:
960
966
  """
967
+ from scipy.interpolate import griddata
968
+
961
969
  if key not in self.grid_property:
962
970
  raise KeyError
963
971
  if len(path) < 2:
@@ -995,6 +1003,9 @@ class SurfaceGrid:
995
1003
  :param vmin: colorbar 最小值,默认自动
996
1004
  :return:
997
1005
  """
1006
+ from matplotlib import pyplot as plt
1007
+ import matplotlib.tri as mtri
1008
+
998
1009
  assert key in self.grid_property
999
1010
  fig, ax = plt.subplots()
1000
1011
  ax.set_aspect('equal')
@@ -1027,6 +1038,9 @@ class SurfaceGrid:
1027
1038
 
1028
1039
  def plot_sigma(self, key='energy', figname=None, vmax=None, vmin=None):
1029
1040
  # TODO: 支持 cluster 作图。保存原始 meshgrid 和 id?或者重新插值?
1041
+ from matplotlib import pyplot as plt
1042
+ import matplotlib.tri as mtri
1043
+
1030
1044
  assert key in self.grid_property_sigma
1031
1045
  fig, ax = plt.subplots()
1032
1046
  ax.set_aspect('equal')
@@ -1067,6 +1081,7 @@ class SurfaceGrid:
1067
1081
  return None
1068
1082
 
1069
1083
  def to_pkl(self, pkl_file="surface_grid.pkl"):
1084
+ import pickle
1070
1085
  file_pi = open(pkl_file, 'wb')
1071
1086
  pickle.dump(self, file_pi)
1072
1087
  file_pi.close()
@@ -1084,6 +1099,7 @@ class SurfaceGrid:
1084
1099
 
1085
1100
  @classmethod
1086
1101
  def from_pkl(cls, pkl_file="surface_grid.pkl"):
1102
+ import pickle
1087
1103
  filehandler = open(pkl_file, 'rb')
1088
1104
  obj = pickle.load(filehandler)
1089
1105
  filehandler.close()
@@ -88,7 +88,7 @@ def get_distances(p1, p2=None, cutoff=10.0, cell=None, ncell=None, pbc=None, use
88
88
  """
89
89
  if not use_ase:
90
90
  if ncell is None:
91
- ncell = np.floor((cutoff * 2) / cell.lengths())
91
+ ncell = [max([i,1]) for i in np.floor((cutoff * 2) / cell.lengths())] # 至少拓展+1,-1, 保证边缘周期性
92
92
  for ip,p in enumerate(pbc):
93
93
  if not p: # 如果不是周期性的,则不要重复
94
94
  ncell[ip] = 0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: surface_construct
3
- Version: 0.10.1
3
+ Version: 0.10.3
4
4
  Summary: Surface termination construction especially for complex model, such as oxides or carbides.
5
5
  Home-page: https://gitee.com/pjren/surface_construct/
6
6
  Author: ren
@@ -34,16 +34,10 @@ Dynamic: summary
34
34
 
35
35
  本软件同时进行表面位点的构建、采样、计算、分析,和反应过程的分析采样,即过渡态和分子构象,由此可以实现分子在表面反应的全过程采样。其中的技术关键是采样的效率,我们针对性地使用综合使用了多样化的采样策略,保证表面各类型位点和关键位点的充分采样。
36
36
 
37
-
38
-
39
37
  <img src="docs/birds_view.png" alt="表面位点全局分析" style="zoom:50%;" />
40
38
 
41
-
42
-
43
39
  ## 程序流程图 Program Workflow
44
40
 
45
-
46
-
47
41
  ![flowchart](docs/modules-计算流程.jpg)
48
42
 
49
43
  ## 重要的概念 Glossary
@@ -155,11 +149,14 @@ $$
155
149
  * v 0.8: 孔材料体系格点构造
156
150
  * v 0.9: 重新梳理软件的模块,优化软件使用逻辑
157
151
  * v 0.9.2: debug 支持三斜晶系的表面格点化
152
+ * v 0.9.3: debug GridGenerator
153
+ * v 0.10: 表面终结生成完整并入
158
154
 
159
155
  **TODO**
160
156
 
161
157
  * 计算位点 SALI (Structure-Activity Landscape Index),量化 activity cliffs,SALI = |ΔActivity| / (1 − Similarity)
162
158
  * 新增 PathSampler,用于在相邻的关键格点之间的扩散路径进行采样,使用 ase.neb.idpp 方法进行采样,使用 Delaunay 剖分找到相邻位点的路径。
159
+ * Low-Energy Region Explorer 方法借鉴[^LoreX]: 划分能量区域, 进行 Delaunay 划分,合并较小的区域为较大的区域。然后针对低能的区域进行额外采样。也可以适用不同的方法,低精度进行低能高能区域识别,然后高精度方法加强。
163
160
  * 表面位点数据库
164
161
  * 多原子体系(内坐标受限体系)
165
162
  * 完善用户界面、例子、教程
@@ -171,4 +168,5 @@ $$
171
168
  [^BASC]: Shane Carr, Roman Garnett, Cynthia LoBASC: Applying Bayesian Optimization to the Search for Global Minima on Potential Energy Surfaces.
172
169
 
173
170
  [^向量空间转化]: 计算实空间和向量空间的相邻格点距离的映射系数,根据此系数将实空间的距离转化为向量空间距离。
171
+ [^LoreX]: Chuan-Nan Li, Han-Pu Liang, Siyuan Xu, Haochen Wang, Bai-Qing Zhao, Jingxiu Yang, Xie Zhang, Zijing Lin, Su-Huai Wei, LoreX: A Low-Energy Region Explorer Boosts Efficient Crystal Structure Prediction, J. Am. Chem. Soc. 2025, 147, 11, 9544–9555.
174
172
 
@@ -11,7 +11,7 @@ class TestSimpleSurface:
11
11
  slab1 = Slab(s)
12
12
  superslab1 = slab1.supercell((3,3))
13
13
  terms = superslab1.get_all_terminations(unique=True)
14
- atoms_list = [t.atoms for t in terms]
14
+ atoms_list = [t.atoms for t in terms.values]
15
15
 
16
16
  slab2 = Slab(s, from_last=True)
17
17
  superslab2 = slab2.supercell((3,3))