surface-construct 0.12.6__tar.gz → 0.12.7__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 (39) hide show
  1. {surface_construct-0.12.6/surface_construct.egg-info → surface_construct-0.12.7}/PKG-INFO +1 -1
  2. {surface_construct-0.12.6 → surface_construct-0.12.7}/setup.py +1 -1
  3. {surface_construct-0.12.6 → surface_construct-0.12.7}/surface_construct/sg_sampler.py +12 -5
  4. {surface_construct-0.12.6 → surface_construct-0.12.7}/surface_construct/tasks/sitesampling.py +5 -0
  5. {surface_construct-0.12.6 → surface_construct-0.12.7}/surface_construct/tasks/vipsitetask.py +29 -25
  6. {surface_construct-0.12.6 → surface_construct-0.12.7/surface_construct.egg-info}/PKG-INFO +1 -1
  7. {surface_construct-0.12.6 → surface_construct-0.12.7}/LICENSE +0 -0
  8. {surface_construct-0.12.6 → surface_construct-0.12.7}/README.md +0 -0
  9. {surface_construct-0.12.6 → surface_construct-0.12.7}/setup.cfg +0 -0
  10. {surface_construct-0.12.6 → surface_construct-0.12.7}/surface_construct/__init__.py +0 -0
  11. {surface_construct-0.12.6 → surface_construct-0.12.7}/surface_construct/db.py +0 -0
  12. {surface_construct-0.12.6 → surface_construct-0.12.7}/surface_construct/default_parameter.py +0 -0
  13. {surface_construct-0.12.6 → surface_construct-0.12.7}/surface_construct/structures/__init__.py +0 -0
  14. {surface_construct-0.12.6 → surface_construct-0.12.7}/surface_construct/structures/adsorbate.py +0 -0
  15. {surface_construct-0.12.6 → surface_construct-0.12.7}/surface_construct/structures/combiner.py +0 -0
  16. {surface_construct-0.12.6 → surface_construct-0.12.7}/surface_construct/structures/pymsym_test.py +0 -0
  17. {surface_construct-0.12.6 → surface_construct-0.12.7}/surface_construct/structures/surface.py +0 -0
  18. {surface_construct-0.12.6 → surface_construct-0.12.7}/surface_construct/structures/surface_grid.py +0 -0
  19. {surface_construct-0.12.6 → surface_construct-0.12.7}/surface_construct/tasks/__init__.py +0 -0
  20. {surface_construct-0.12.6 → surface_construct-0.12.7}/surface_construct/tasks/afm.py +0 -0
  21. {surface_construct-0.12.6 → surface_construct-0.12.7}/surface_construct/tasks/taskbase.py +0 -0
  22. {surface_construct-0.12.6 → surface_construct-0.12.7}/surface_construct/tasks/terminations.py +0 -0
  23. {surface_construct-0.12.6 → surface_construct-0.12.7}/surface_construct/utils/__init__.py +0 -0
  24. {surface_construct-0.12.6 → surface_construct-0.12.7}/surface_construct/utils/atoms.py +0 -0
  25. {surface_construct-0.12.6 → surface_construct-0.12.7}/surface_construct/utils/geometry.py +0 -0
  26. {surface_construct-0.12.6 → surface_construct-0.12.7}/surface_construct/utils/pymsym_wrapper.py +0 -0
  27. {surface_construct-0.12.6 → surface_construct-0.12.7}/surface_construct/utils/spglib_wrapper.py +0 -0
  28. {surface_construct-0.12.6 → surface_construct-0.12.7}/surface_construct/utils/weight_functions.py +0 -0
  29. {surface_construct-0.12.6 → surface_construct-0.12.7}/surface_construct.egg-info/SOURCES.txt +0 -0
  30. {surface_construct-0.12.6 → surface_construct-0.12.7}/surface_construct.egg-info/dependency_links.txt +0 -0
  31. {surface_construct-0.12.6 → surface_construct-0.12.7}/surface_construct.egg-info/requires.txt +0 -0
  32. {surface_construct-0.12.6 → surface_construct-0.12.7}/surface_construct.egg-info/top_level.txt +0 -0
  33. {surface_construct-0.12.6 → surface_construct-0.12.7}/tests/test_adsorbate.py +0 -0
  34. {surface_construct-0.12.6 → surface_construct-0.12.7}/tests/test_combiner.py +0 -0
  35. {surface_construct-0.12.6 → surface_construct-0.12.7}/tests/test_sampling1.py +0 -0
  36. {surface_construct-0.12.6 → surface_construct-0.12.7}/tests/test_sampling2.py +0 -0
  37. {surface_construct-0.12.6 → surface_construct-0.12.7}/tests/test_simple_surface.py +0 -0
  38. {surface_construct-0.12.6 → surface_construct-0.12.7}/tests/test_surface_grid.py +0 -0
  39. {surface_construct-0.12.6 → surface_construct-0.12.7}/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.6
3
+ Version: 0.12.7
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.6',
18
+ version='0.12.7',
19
19
  packages=find_packages(),
20
20
  url='https://gitee.com/pjren/surface_construct/',
21
21
  license='GPL',
@@ -174,10 +174,12 @@ class MaxSigmaSGSampler(SGSamplerBase):
174
174
  else:
175
175
  delta = 0.01
176
176
  idx_list = []
177
- while len(idx_list) >= size:
177
+ while len(idx_list) < size:
178
178
  idx_list = np.argwhere(sigma_array > sigma0-delta).flatten().tolist()
179
+ # 排除掉已经采过的点
180
+ idx_list = [i for i in idx_list if i not in self.sg_obj.calculated_sample]
179
181
  delta += 0.01
180
- idx = random.sample(idx_list, size)
182
+ idx = random.sample(idx_list, min(size, len(idx_list)))
181
183
  return idx
182
184
  else:
183
185
  raise "No energy for all population, pls do initial sampling first!"
@@ -194,10 +196,15 @@ class MinEnergySGSampler(SGSamplerBase):
194
196
  raise ValueError("Number of points should greater than sample!")
195
197
  elif len(E_array) == size:
196
198
  return np.asarray(range(len(E_array)))
197
- # 如果已经读入了一些能量,则返回能量最低的点 (<0.1eV 以内,然后随机选一个)
198
199
  E0 = E_array.min()
199
- idx_list = np.argwhere(E_array <= E0+0.1).flatten().tolist()
200
- idx = random.sample(idx_list, size)
200
+ delta = 0.1
201
+ idx_list = []
202
+ while len(idx_list) < size:
203
+ # 如果已经读入了一些能量,则返回能量最低的点 (<delta eV 以内,然后随机选一个)
204
+ idx_list = np.argwhere(E_array <= E0+0.1).flatten().tolist()
205
+ idx_list = [i for i in idx_list if i not in self.sg_obj.calculated_sample]
206
+ delta += 0.1
207
+ idx = random.sample(idx_list, min(size, len(idx_list)))
201
208
  return idx
202
209
  else:
203
210
  raise "No energy for all population, pls do initial sampling first!"
@@ -171,6 +171,11 @@ class SurfaceSiteSampleTask(TaskBase):
171
171
  self.sg_obj.del_sample(grid_idx)
172
172
 
173
173
  def run(self):
174
+ # 在新的采样之前先进行已经采到但是未计算的点
175
+ uncalc_samples = [idx for idx in self.sg_obj.sample_idx if not self.sg_obj.sample_dct[idx]['calculated']]
176
+ for grid_idx in uncalc_samples:
177
+ self.irun(grid_idx, fit=False)
178
+
174
179
  for isampler in self.sampler:
175
180
  size = isampler.get("size", 1)
176
181
  sg_sampler = isampler.get("surface")
@@ -1,3 +1,5 @@
1
+ import os
2
+
1
3
  from matplotlib import pyplot as plt
2
4
  from matplotlib.patches import Circle
3
5
 
@@ -6,41 +8,43 @@ from .sitesampling import SurfaceSiteSampleTask
6
8
  class VIPSiteTask(SurfaceSiteSampleTask):
7
9
  def __init__(self, exclude=None, include=None, **kwargs):
8
10
  super().__init__(**kwargs)
11
+ if not os.path.isfile(self.hist_pkl):
12
+ vip_id = self.sg_obj.vip_id
13
+ grid_site_type, site_type_dict = self.sg_obj.get_grid_site_type()
14
+ if exclude is None and include is None:
15
+ msg = [f"Either exclude or include must be specified"]
16
+ msg += [f"Possible site types are {len(site_type_dict)} in total:"]
17
+ msg += [f"{k}: {v}" for k,v in site_type_dict.items() if type(k) in (int,)]
18
+ raise ValueError('\n'.join(msg))
19
+ elif exclude is not None and include is not None:
20
+ raise ValueError("Can not specified exclude and include at the same time")
21
+ elif exclude is not None and include is None:
22
+ filtered = [i for i in vip_id if site_type_dict[grid_site_type[i]] not in exclude]
23
+ else:
24
+ filtered = [i for i in vip_id if site_type_dict[grid_site_type[i]] in include]
9
25
 
10
- vip_id = self.sg_obj.vip_id
11
- grid_site_type, site_type_dict = self.sg_obj.get_grid_site_type()
12
- if exclude is None and include is None:
13
- msg = [f"Either exclude or include must be specified"]
14
- msg += [f"Possible site types are {len(site_type_dict)} in total:"]
15
- msg += [f"{k}: {v}" for k,v in site_type_dict.items() if type(k) in (int,)]
16
- raise ValueError('\n'.join(msg))
17
- elif exclude is not None and include is not None:
18
- raise ValueError("Can not specified exclude and include at the same time")
19
- elif exclude is not None and include is None:
20
- filtered = [i for i in vip_id if site_type_dict[grid_site_type[i]] not in exclude]
21
- else:
22
- filtered = [i for i in vip_id if site_type_dict[grid_site_type[i]] in include]
23
-
24
- points = self.sg_obj.points[filtered]
25
- vector = self.sg_obj.vector[filtered]
26
- raw_vector = self.sg_obj._raw_vector[filtered]
27
- _ = self.sg_obj.vector_interval # 此处call 一下,用于后面的 fit 中的参数
28
- self.sg_obj.points = points
29
- self.sg_obj.vector = vector
30
- self.sg_obj._raw_vector = raw_vector
31
- self.sg_obj.vectorgen = None
26
+ points = self.sg_obj.points[filtered]
27
+ vector = self.sg_obj.vector[filtered]
28
+ raw_vector = self.sg_obj._raw_vector[filtered]
29
+ _ = self.sg_obj.vector_interval # 此处call 一下,用于后面的 fit 中的参数
30
+ self.sg_obj.points = points
31
+ self.sg_obj.vector = vector
32
+ self.sg_obj._raw_vector = raw_vector
33
+ self.sg_obj.vectorgen = None
32
34
 
33
- sampler_size = 0
35
+ sampler_size = len(self.sg_obj.calculated_sample)
34
36
  new_sampler = []
35
37
  for isampler in self.sampler: # 不需要初始采样和key 点采样
36
38
  if isampler['surface'] not in ('InitialSGSampler', 'KeyPointSGSampler'):
37
39
  sampler_size += isampler.get('size', 0)
38
40
  new_sampler.append(isampler)
41
+ else:
42
+ print("Warning: InitialSGSampler or KeyPointSGSampler should not applied in VIP sampling.")
39
43
 
40
44
  # 如果 filter 之后的点小于等于 self.sampler['size'], 重新定义sampler
41
- if sampler_size >= len(points):
45
+ if sampler_size >= len(self.sg_obj.points):
42
46
  self.sampler = [{
43
- 'size': len(points), # 采样大小
47
+ 'size': len(self.sg_obj.points)-len(self.sg_obj.calculated_sample), # 采样大小
44
48
  'surface': "RandomSGSampler", # 表面采样方法
45
49
  }]
46
50
  else:
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: surface_construct
3
- Version: 0.12.6
3
+ Version: 0.12.7
4
4
  Summary: Surface construction and surface reaction sampling tools.
5
5
  Home-page: https://gitee.com/pjren/surface_construct/
6
6
  Author: ren