surface-construct 0.12.1__tar.gz → 0.12.2__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 (38) hide show
  1. {surface_construct-0.12.1/surface_construct.egg-info → surface_construct-0.12.2}/PKG-INFO +1 -1
  2. {surface_construct-0.12.1 → surface_construct-0.12.2}/setup.py +1 -1
  3. {surface_construct-0.12.1 → surface_construct-0.12.2}/surface_construct/structures/surface_grid.py +17 -39
  4. {surface_construct-0.12.1 → surface_construct-0.12.2/surface_construct.egg-info}/PKG-INFO +1 -1
  5. {surface_construct-0.12.1 → surface_construct-0.12.2}/tests/test_surface_grid.py +19 -1
  6. {surface_construct-0.12.1 → surface_construct-0.12.2}/LICENSE +0 -0
  7. {surface_construct-0.12.1 → surface_construct-0.12.2}/README.md +0 -0
  8. {surface_construct-0.12.1 → surface_construct-0.12.2}/setup.cfg +0 -0
  9. {surface_construct-0.12.1 → surface_construct-0.12.2}/surface_construct/__init__.py +0 -0
  10. {surface_construct-0.12.1 → surface_construct-0.12.2}/surface_construct/db.py +0 -0
  11. {surface_construct-0.12.1 → surface_construct-0.12.2}/surface_construct/default_parameter.py +0 -0
  12. {surface_construct-0.12.1 → surface_construct-0.12.2}/surface_construct/sg_sampler.py +0 -0
  13. {surface_construct-0.12.1 → surface_construct-0.12.2}/surface_construct/structures/__init__.py +0 -0
  14. {surface_construct-0.12.1 → surface_construct-0.12.2}/surface_construct/structures/adsorbate.py +0 -0
  15. {surface_construct-0.12.1 → surface_construct-0.12.2}/surface_construct/structures/combiner.py +0 -0
  16. {surface_construct-0.12.1 → surface_construct-0.12.2}/surface_construct/structures/pymsym_test.py +0 -0
  17. {surface_construct-0.12.1 → surface_construct-0.12.2}/surface_construct/structures/surface.py +0 -0
  18. {surface_construct-0.12.1 → surface_construct-0.12.2}/surface_construct/tasks/__init__.py +0 -0
  19. {surface_construct-0.12.1 → surface_construct-0.12.2}/surface_construct/tasks/afm.py +0 -0
  20. {surface_construct-0.12.1 → surface_construct-0.12.2}/surface_construct/tasks/sitesampling.py +0 -0
  21. {surface_construct-0.12.1 → surface_construct-0.12.2}/surface_construct/tasks/taskbase.py +0 -0
  22. {surface_construct-0.12.1 → surface_construct-0.12.2}/surface_construct/tasks/terminations.py +0 -0
  23. {surface_construct-0.12.1 → surface_construct-0.12.2}/surface_construct/utils/__init__.py +0 -0
  24. {surface_construct-0.12.1 → surface_construct-0.12.2}/surface_construct/utils/atoms.py +0 -0
  25. {surface_construct-0.12.1 → surface_construct-0.12.2}/surface_construct/utils/geometry.py +0 -0
  26. {surface_construct-0.12.1 → surface_construct-0.12.2}/surface_construct/utils/pymsym_wrapper.py +0 -0
  27. {surface_construct-0.12.1 → surface_construct-0.12.2}/surface_construct/utils/spglib_wrapper.py +0 -0
  28. {surface_construct-0.12.1 → surface_construct-0.12.2}/surface_construct/utils/weight_functions.py +0 -0
  29. {surface_construct-0.12.1 → surface_construct-0.12.2}/surface_construct.egg-info/SOURCES.txt +0 -0
  30. {surface_construct-0.12.1 → surface_construct-0.12.2}/surface_construct.egg-info/dependency_links.txt +0 -0
  31. {surface_construct-0.12.1 → surface_construct-0.12.2}/surface_construct.egg-info/requires.txt +0 -0
  32. {surface_construct-0.12.1 → surface_construct-0.12.2}/surface_construct.egg-info/top_level.txt +0 -0
  33. {surface_construct-0.12.1 → surface_construct-0.12.2}/tests/test_adsorbate.py +0 -0
  34. {surface_construct-0.12.1 → surface_construct-0.12.2}/tests/test_combiner.py +0 -0
  35. {surface_construct-0.12.1 → surface_construct-0.12.2}/tests/test_sampling1.py +0 -0
  36. {surface_construct-0.12.1 → surface_construct-0.12.2}/tests/test_sampling2.py +0 -0
  37. {surface_construct-0.12.1 → surface_construct-0.12.2}/tests/test_simple_surface.py +0 -0
  38. {surface_construct-0.12.1 → surface_construct-0.12.2}/tests/test_task.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: surface_construct
3
- Version: 0.12.1
3
+ Version: 0.12.2
4
4
  Summary: Surface construction and surface reaction sampling tools.
5
5
  Home-page: https://gitee.com/pjren/surface_construct/
6
6
  Author: ren
@@ -15,7 +15,7 @@ install_requires = [
15
15
 
16
16
  setup(
17
17
  name='surface_construct',
18
- version='0.12.1',
18
+ version='0.12.2',
19
19
  packages=find_packages(),
20
20
  url='https://gitee.com/pjren/surface_construct/',
21
21
  license='GPL',
@@ -1143,45 +1143,23 @@ def combine_sg_vector(*sg_lst):
1143
1143
  elif len(sg_lst) == 1:
1144
1144
  return sg_lst[0]._raw_vector
1145
1145
 
1146
- species_num_lst = sorted(set([s[0] for sg in sg_lst for s in sg.species]))
1147
- species_default_dct = {num: 0 for num in species_num_lst}
1148
- species_lsts = []
1149
- vlen_max = species_default_dct.copy()
1146
+ species_lst = sorted({s[0] for sg in sg_lst for s in sg.species})
1147
+ vlen = max([sg.vlen for sg in sg_lst])
1148
+ vectors_lst = []
1150
1149
  for sg in sg_lst:
1151
- species_dct = species_default_dct.copy()
1152
- species_dct.update({num: min(sg.vlen, cnt) for num, cnt in sg.species})
1153
- # 对 species_dcts 中的元素进行排序
1154
- species_lst = sorted(species_dct.items(), key=lambda x: x[0])
1155
- species_lsts.append(species_lst)
1156
- vlen_max = {num: max(vlen_max[num], vlen) for num, vlen in species_dct.items()} # 更新向量最大值
1157
- # vlen_max 进行排序
1158
-
1159
- new_vector_lst = []
1160
- for sg, species_lst in zip(sg_lst, species_lsts):
1161
- # 提取 raw_vector, 对不足的 vector 进行补齐
1162
- raw_vector = sg._raw_vector
1163
- nvector = len(raw_vector) # 总行数
1164
- pointer = 0 # 列指针
1165
- new_vector = []
1166
- for num, cnt in species_lst:
1167
- new_vlen = vlen_max[num]
1168
- new_v = np.zeros([nvector, new_vlen])
1169
- new_v += 1.0 * raw_vector.min() # 超过截断的使用最小值的三分之二,从而减小不同表面之间的结构差异
1170
- # 判断长度是不是 0
1171
- if cnt == 0:
1172
- new_vector.append(new_v)
1173
- continue
1174
- # 取出对应的 vector 列
1175
- old_v = raw_vector[:, pointer:pointer+cnt]
1176
- # 判断是不是要补齐
1177
- if cnt == new_vlen:
1178
- new_vector.append(old_v)
1179
- else:
1180
- new_v[:, :cnt] = old_v
1181
- new_vector.append(new_v)
1182
- pointer += cnt
1183
- new_vector = np.concatenate(new_vector, axis=1)
1184
- new_vector_lst.append(new_vector)
1185
- vector_combine = np.concatenate(new_vector_lst, axis=0)
1150
+ sp0 = [s[0] for s in sg.species] # 所有的物种
1151
+ if species_lst == sp0 and sg.vlen==vlen: #如果元素相同,vlen相同,直接合并
1152
+ vectors_lst.append(sg._raw_vector)
1153
+ else: # 如果元素或者vlen不同,都要重新定义 vector
1154
+ vector = np.zeros((len(sg.vector), vlen*len(species_lst)))
1155
+ for old_idx, atomnum in enumerate(sp0):
1156
+ new_idx = species_lst.index(atomnum)
1157
+ idx_up = new_idx*vlen
1158
+ idx_down = idx_up + sg.vlen
1159
+ old_idx_up, old_idx_down = old_idx*sg.vlen, (old_idx+1)*sg.vlen
1160
+ vector[:, idx_up:idx_down] = sg._raw_vector[:, old_idx_up:old_idx_down]
1161
+ vectors_lst.append(vector)
1162
+
1163
+ vector_combine = np.concatenate(vectors_lst, axis=0)
1186
1164
 
1187
1165
  return vector_combine
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: surface_construct
3
- Version: 0.12.1
3
+ Version: 0.12.2
4
4
  Summary: Surface construction and surface reaction sampling tools.
5
5
  Home-page: https://gitee.com/pjren/surface_construct/
6
6
  Author: ren
@@ -6,6 +6,8 @@ import ase
6
6
  from surface_construct import GridGenerator
7
7
  from ase.cluster.cubic import FaceCenteredCubic
8
8
  from surface_construct import SurfaceGrid
9
+ from surface_construct.structures.surface_grid import combine_sg_vector
10
+
9
11
 
10
12
  class TestSurfaceGrid:
11
13
  def test_Cu_cluster(self):
@@ -126,4 +128,20 @@ class TestSurfaceGrid:
126
128
  sg_obj.gridize(subtype='slab')
127
129
  sg_obj.vectorize()
128
130
  assert sg_obj.vector.shape==(6582, 40)
129
- pass
131
+
132
+ def test_sg_combiner(self):
133
+ atoms1 = ase.io.read('atoms_files/C4H4O_Cu.vasp')
134
+ sg_obj1 = SurfaceGrid(atoms1, interval=0.2, ads_num=6, lpca=False)
135
+ sg_obj1.gridize(subtype='slab')
136
+ sg_obj1.vectorize()
137
+ assert sg_obj1.vector.shape[1] == 40
138
+
139
+ atoms2 = ase.io.read('atoms_files/Fe28C12_115_12_POSCAR')
140
+ sg_obj2 = SurfaceGrid(atoms2, interval=0.2, ads_num=6, lpca=False, vlen=15)
141
+ sg_obj2.gridize(subtype='slab')
142
+ sg_obj2.vectorize()
143
+
144
+ assert sg_obj2.vector.shape[1] == 30
145
+
146
+ comb_vector = combine_sg_vector(sg_obj1, sg_obj2)
147
+ assert comb_vector.shape[1] == 75