rsspolymlp 0.4.5__tar.gz → 0.4.6__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.
- {rsspolymlp-0.4.5/src/rsspolymlp.egg-info → rsspolymlp-0.4.6}/PKG-INFO +1 -1
- {rsspolymlp-0.4.5 → rsspolymlp-0.4.6}/pyproject.toml +1 -1
- {rsspolymlp-0.4.5 → rsspolymlp-0.4.6}/src/rsspolymlp/analysis/rss_summarize.py +5 -5
- {rsspolymlp-0.4.5 → rsspolymlp-0.4.6}/src/rsspolymlp/analysis/struct_matcher/gen_struct_rep.py +28 -22
- {rsspolymlp-0.4.5 → rsspolymlp-0.4.6}/src/rsspolymlp/analysis/struct_matcher/identify_uniqstr.py +13 -7
- rsspolymlp-0.4.6/src/rsspolymlp/analysis/struct_matcher/niggli_reduce.py +203 -0
- {rsspolymlp-0.4.5 → rsspolymlp-0.4.6}/src/rsspolymlp/analysis/struct_matcher/primitive_transform.py +27 -42
- {rsspolymlp-0.4.5 → rsspolymlp-0.4.6}/src/rsspolymlp/analysis/struct_matcher/redrep_position.py +104 -22
- {rsspolymlp-0.4.5 → rsspolymlp-0.4.6}/src/rsspolymlp/analysis/struct_matcher/struct_match.py +5 -5
- {rsspolymlp-0.4.5 → rsspolymlp-0.4.6}/src/rsspolymlp/api/cli_rsspolymlp_utils.py +5 -12
- {rsspolymlp-0.4.5 → rsspolymlp-0.4.6}/src/rsspolymlp/api/rsspolymlp.py +2 -2
- {rsspolymlp-0.4.5 → rsspolymlp-0.4.6}/src/rsspolymlp/api/rsspolymlp_utils.py +12 -12
- {rsspolymlp-0.4.5 → rsspolymlp-0.4.6}/src/rsspolymlp/common/interface_vasp.py +39 -0
- {rsspolymlp-0.4.5 → rsspolymlp-0.4.6}/src/rsspolymlp/rss/load_logfile.py +5 -0
- {rsspolymlp-0.4.5 → rsspolymlp-0.4.6}/src/rsspolymlp/rss/optimization_mlp.py +71 -97
- {rsspolymlp-0.4.5 → rsspolymlp-0.4.6}/src/rsspolymlp/rss/random_struct.py +7 -2
- {rsspolymlp-0.4.5 → rsspolymlp-0.4.6/src/rsspolymlp.egg-info}/PKG-INFO +1 -1
- {rsspolymlp-0.4.5 → rsspolymlp-0.4.6}/src/rsspolymlp.egg-info/SOURCES.txt +1 -2
- rsspolymlp-0.4.5/src/rsspolymlp/analysis/struct_matcher/redrep_lattice.py +0 -143
- rsspolymlp-0.4.5/src/rsspolymlp/utils/vasp_util/write_poscar.py +0 -49
- {rsspolymlp-0.4.5 → rsspolymlp-0.4.6}/LICENSE +0 -0
- {rsspolymlp-0.4.5 → rsspolymlp-0.4.6}/README.md +0 -0
- {rsspolymlp-0.4.5 → rsspolymlp-0.4.6}/setup.cfg +0 -0
- {rsspolymlp-0.4.5 → rsspolymlp-0.4.6}/src/rsspolymlp/__init__.py +0 -0
- {rsspolymlp-0.4.5 → rsspolymlp-0.4.6}/src/rsspolymlp/analysis/__init__.py +0 -0
- {rsspolymlp-0.4.5 → rsspolymlp-0.4.6}/src/rsspolymlp/analysis/eos.py +0 -0
- {rsspolymlp-0.4.5 → rsspolymlp-0.4.6}/src/rsspolymlp/analysis/ghost_minima.py +0 -0
- {rsspolymlp-0.4.5 → rsspolymlp-0.4.6}/src/rsspolymlp/analysis/phase_analysis.py +0 -0
- {rsspolymlp-0.4.5 → rsspolymlp-0.4.6}/src/rsspolymlp/analysis/struct_matcher/__init__.py +0 -0
- {rsspolymlp-0.4.5 → rsspolymlp-0.4.6}/src/rsspolymlp/analysis/struct_matcher/assignment_algo.py +0 -0
- {rsspolymlp-0.4.5 → rsspolymlp-0.4.6}/src/rsspolymlp/analysis/struct_matcher/chiral_spg.py +0 -0
- {rsspolymlp-0.4.5 → rsspolymlp-0.4.6}/src/rsspolymlp/analysis/struct_matcher/test/gen_lattice.py +0 -0
- {rsspolymlp-0.4.5 → rsspolymlp-0.4.6}/src/rsspolymlp/analysis/utils/convert_data_format.py +0 -0
- {rsspolymlp-0.4.5 → rsspolymlp-0.4.6}/src/rsspolymlp/api/__init__.py +0 -0
- {rsspolymlp-0.4.5 → rsspolymlp-0.4.6}/src/rsspolymlp/api/cli_rsspolymlp.py +0 -0
- {rsspolymlp-0.4.5 → rsspolymlp-0.4.6}/src/rsspolymlp/api/cli_rsspolymlp_devkit.py +0 -0
- {rsspolymlp-0.4.5 → rsspolymlp-0.4.6}/src/rsspolymlp/api/cli_rsspolymlp_plot.py +0 -0
- {rsspolymlp-0.4.5 → rsspolymlp-0.4.6}/src/rsspolymlp/api/rsspolymlp_devkit.py +0 -0
- {rsspolymlp-0.4.5 → rsspolymlp-0.4.6}/src/rsspolymlp/api/rsspolymlp_plot.py +0 -0
- {rsspolymlp-0.4.5 → rsspolymlp-0.4.6}/src/rsspolymlp/common/__init__.py +0 -0
- {rsspolymlp-0.4.5 → rsspolymlp-0.4.6}/src/rsspolymlp/common/atomic_energy.py +0 -0
- {rsspolymlp-0.4.5 → rsspolymlp-0.4.6}/src/rsspolymlp/common/composition.py +0 -0
- {rsspolymlp-0.4.5 → rsspolymlp-0.4.6}/src/rsspolymlp/common/interface_pypolymlp.py +0 -0
- {rsspolymlp-0.4.5 → rsspolymlp-0.4.6}/src/rsspolymlp/common/interface_spglib.py +0 -0
- {rsspolymlp-0.4.5 → rsspolymlp-0.4.6}/src/rsspolymlp/common/property.py +0 -0
- {rsspolymlp-0.4.5 → rsspolymlp-0.4.6}/src/rsspolymlp/mlp_dev/dataset/compress_vasprun.py +0 -0
- {rsspolymlp-0.4.5 → rsspolymlp-0.4.6}/src/rsspolymlp/mlp_dev/dataset/gen_mlp_dataset.py +0 -0
- {rsspolymlp-0.4.5 → rsspolymlp-0.4.6}/src/rsspolymlp/mlp_dev/dataset/split_dataset.py +0 -0
- {rsspolymlp-0.4.5 → rsspolymlp-0.4.6}/src/rsspolymlp/mlp_dev/estimate_cost.py +0 -0
- {rsspolymlp-0.4.5 → rsspolymlp-0.4.6}/src/rsspolymlp/mlp_dev/model_selection/binary/gen_single_model.py +0 -0
- {rsspolymlp-0.4.5 → rsspolymlp-0.4.6}/src/rsspolymlp/mlp_dev/model_selection/elemental/gen_hybrid_model.py +0 -0
- {rsspolymlp-0.4.5 → rsspolymlp-0.4.6}/src/rsspolymlp/mlp_dev/model_selection/elemental/gen_single_model.py +0 -0
- {rsspolymlp-0.4.5 → rsspolymlp-0.4.6}/src/rsspolymlp/mlp_dev/model_selection/n_feature.py +0 -0
- {rsspolymlp-0.4.5 → rsspolymlp-0.4.6}/src/rsspolymlp/mlp_dev/model_selection/pypolymlp_gridsearch.py +0 -0
- {rsspolymlp-0.4.5 → rsspolymlp-0.4.6}/src/rsspolymlp/mlp_dev/model_selection/reduce_grid.py +0 -0
- {rsspolymlp-0.4.5 → rsspolymlp-0.4.6}/src/rsspolymlp/mlp_dev/pareto_opt_mlp.py +0 -0
- {rsspolymlp-0.4.5 → rsspolymlp-0.4.6}/src/rsspolymlp/mlp_dev/polymlp_dev.py +0 -0
- {rsspolymlp-0.4.5 → rsspolymlp-0.4.6}/src/rsspolymlp/rss/__init__.py +0 -0
- {rsspolymlp-0.4.5 → rsspolymlp-0.4.6}/src/rsspolymlp/rss/eliminate_duplicates.py +0 -0
- {rsspolymlp-0.4.5 → rsspolymlp-0.4.6}/src/rsspolymlp/utils/__init__.py +0 -0
- {rsspolymlp-0.4.5 → rsspolymlp-0.4.6}/src/rsspolymlp/utils/lammps_utils.py +0 -0
- {rsspolymlp-0.4.5 → rsspolymlp-0.4.6}/src/rsspolymlp/utils/matplot_util/__init__.py +0 -0
- {rsspolymlp-0.4.5 → rsspolymlp-0.4.6}/src/rsspolymlp/utils/matplot_util/custom_plt.py +0 -0
- {rsspolymlp-0.4.5 → rsspolymlp-0.4.6}/src/rsspolymlp/utils/matplot_util/examples/__init__.py +0 -0
- {rsspolymlp-0.4.5 → rsspolymlp-0.4.6}/src/rsspolymlp/utils/matplot_util/examples/example.py +0 -0
- {rsspolymlp-0.4.5 → rsspolymlp-0.4.6}/src/rsspolymlp/utils/matplot_util/examples/template.py +0 -0
- {rsspolymlp-0.4.5 → rsspolymlp-0.4.6}/src/rsspolymlp/utils/matplot_util/make_plot.py +0 -0
- {rsspolymlp-0.4.5 → rsspolymlp-0.4.6}/src/rsspolymlp/utils/opt_sscha/opt_geometry_sscha.py +0 -0
- {rsspolymlp-0.4.5 → rsspolymlp-0.4.6}/src/rsspolymlp/utils/opt_sscha/opt_position_sscha.py +0 -0
- {rsspolymlp-0.4.5 → rsspolymlp-0.4.6}/src/rsspolymlp/utils/opt_sscha/run_opt_sscha.py +0 -0
- {rsspolymlp-0.4.5 → rsspolymlp-0.4.6}/src/rsspolymlp/utils/opt_sscha/sscha_property.py +0 -0
- {rsspolymlp-0.4.5 → rsspolymlp-0.4.6}/src/rsspolymlp/utils/pymatgen_utils.py +0 -0
- {rsspolymlp-0.4.5 → rsspolymlp-0.4.6}/src/rsspolymlp/utils/vasp_util/__init__.py +0 -0
- {rsspolymlp-0.4.5 → rsspolymlp-0.4.6}/src/rsspolymlp/utils/vasp_util/api.py +0 -0
- {rsspolymlp-0.4.5 → rsspolymlp-0.4.6}/src/rsspolymlp/utils/vasp_util/gen_incar.py +0 -0
- {rsspolymlp-0.4.5 → rsspolymlp-0.4.6}/src/rsspolymlp/utils/vasp_util/gen_script.py +0 -0
- {rsspolymlp-0.4.5 → rsspolymlp-0.4.6}/src/rsspolymlp.egg-info/dependency_links.txt +0 -0
- {rsspolymlp-0.4.5 → rsspolymlp-0.4.6}/src/rsspolymlp.egg-info/entry_points.txt +0 -0
- {rsspolymlp-0.4.5 → rsspolymlp-0.4.6}/src/rsspolymlp.egg-info/requires.txt +0 -0
- {rsspolymlp-0.4.5 → rsspolymlp-0.4.6}/src/rsspolymlp.egg-info/top_level.txt +0 -0
- {rsspolymlp-0.4.5 → rsspolymlp-0.4.6}/tests/test_cli_help.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: rsspolymlp
|
|
3
|
-
Version: 0.4.
|
|
3
|
+
Version: 0.4.6
|
|
4
4
|
Summary: A framework for random structure search using polynomial MLPs
|
|
5
5
|
Author-email: Hayato Wakai <wakai@cms.mtl.kyoto-u.ac.jp>
|
|
6
6
|
Maintainer-email: Hayato Wakai <wakai@cms.mtl.kyoto-u.ac.jp>
|
|
@@ -38,7 +38,7 @@ class RSSResultSummarizer:
|
|
|
38
38
|
num_process: int = -1,
|
|
39
39
|
backend: str = "loky",
|
|
40
40
|
assign_method: Literal["redrep", "greedy", "HK", "pymatgen"] = "redrep",
|
|
41
|
-
|
|
41
|
+
tol_sm: list[float] = [1e-2],
|
|
42
42
|
output_poscar: bool = False,
|
|
43
43
|
thresholds: list[float] = None,
|
|
44
44
|
parse_vasp: bool = False,
|
|
@@ -52,7 +52,7 @@ class RSSResultSummarizer:
|
|
|
52
52
|
self.num_process = num_process
|
|
53
53
|
self.backend = backend
|
|
54
54
|
self.assign_method = assign_method
|
|
55
|
-
self.
|
|
55
|
+
self.tol_sm = tol_sm
|
|
56
56
|
self.output_poscar = output_poscar
|
|
57
57
|
self.thresholds = thresholds
|
|
58
58
|
self.parse_vasp = parse_vasp
|
|
@@ -124,7 +124,7 @@ class RSSResultSummarizer:
|
|
|
124
124
|
axis_tol=axis_tol,
|
|
125
125
|
pos_tol=pos_tol,
|
|
126
126
|
assign_method=self.assign_method,
|
|
127
|
-
|
|
127
|
+
tol_sm=self.tol_sm,
|
|
128
128
|
num_process=self.num_process,
|
|
129
129
|
pre_analyzer=self.analyzer,
|
|
130
130
|
)
|
|
@@ -220,7 +220,7 @@ class RSSResultSummarizer:
|
|
|
220
220
|
axis_tol=axis_tol,
|
|
221
221
|
pos_tol=pos_tol,
|
|
222
222
|
assign_method=self.assign_method,
|
|
223
|
-
|
|
223
|
+
tol_sm=self.tol_sm,
|
|
224
224
|
num_process=self.num_process,
|
|
225
225
|
pre_analyzer=self.analyzer,
|
|
226
226
|
)
|
|
@@ -281,7 +281,7 @@ class RSSResultSummarizer:
|
|
|
281
281
|
|
|
282
282
|
print(" - Converting reduced crystal structure representation...")
|
|
283
283
|
generator = StructRepGenerator(
|
|
284
|
-
|
|
284
|
+
tol_sm=self.tol_sm,
|
|
285
285
|
)
|
|
286
286
|
struct_reps_list = generator.generate_struct_reps_parallel(
|
|
287
287
|
rss_results,
|
{rsspolymlp-0.4.5 → rsspolymlp-0.4.6}/src/rsspolymlp/analysis/struct_matcher/gen_struct_rep.py
RENAMED
|
@@ -7,6 +7,7 @@ from typing import Optional
|
|
|
7
7
|
import joblib
|
|
8
8
|
import numpy as np
|
|
9
9
|
|
|
10
|
+
from rsspolymlp.analysis.struct_matcher.niggli_reduce import niggli_reduce
|
|
10
11
|
from rsspolymlp.analysis.struct_matcher.primitive_transform import (
|
|
11
12
|
PrimitiveCell,
|
|
12
13
|
get_primitive_cell,
|
|
@@ -32,8 +33,8 @@ class StructReps:
|
|
|
32
33
|
original_positions: np.ndarray
|
|
33
34
|
original_elements: np.ndarray
|
|
34
35
|
spg_list: list[str]
|
|
35
|
-
|
|
36
|
-
|
|
36
|
+
tol_sm: list[float]
|
|
37
|
+
tol_redpos: list[float]
|
|
37
38
|
normalize_axis: bool
|
|
38
39
|
struct_path: Optional[str]
|
|
39
40
|
struct_tag: Optional[int]
|
|
@@ -44,13 +45,13 @@ class StructRepGenerator:
|
|
|
44
45
|
|
|
45
46
|
def __init__(
|
|
46
47
|
self,
|
|
47
|
-
|
|
48
|
-
|
|
48
|
+
tol_sm: list[float] = [1e-2],
|
|
49
|
+
tol_redpos: list[float] = [1e-4, 1e-2, 1e-1],
|
|
49
50
|
normalize_axis: bool = False,
|
|
50
51
|
verbose: bool = False,
|
|
51
52
|
):
|
|
52
|
-
self.
|
|
53
|
-
self.
|
|
53
|
+
self.tol_sm = tol_sm
|
|
54
|
+
self.tol_redpos = tol_redpos
|
|
54
55
|
self.normalize_axis = normalize_axis
|
|
55
56
|
self.verbose = verbose
|
|
56
57
|
|
|
@@ -101,8 +102,8 @@ class StructRepGenerator:
|
|
|
101
102
|
|
|
102
103
|
struct_rep_list = []
|
|
103
104
|
for i, primitive_st in enumerate(primitive_st_set):
|
|
104
|
-
|
|
105
|
-
self.
|
|
105
|
+
tol_redpos = sorted(
|
|
106
|
+
self.tol_redpos,
|
|
106
107
|
key=lambda x: x if isinstance(x, (int, float)) else sum(x) / len(x),
|
|
107
108
|
)
|
|
108
109
|
struct_rep, log_redrep = self.generate_struct_rep(
|
|
@@ -129,8 +130,8 @@ class StructRepGenerator:
|
|
|
129
130
|
original_positions=positions,
|
|
130
131
|
original_elements=np.asarray(elements, dtype=str),
|
|
131
132
|
spg_list=spg_list,
|
|
132
|
-
|
|
133
|
-
|
|
133
|
+
tol_sm=self.tol_sm,
|
|
134
|
+
tol_redpos=tol_redpos,
|
|
134
135
|
normalize_axis=self.normalize_axis,
|
|
135
136
|
struct_path=struct_path,
|
|
136
137
|
struct_tag=struct_tag,
|
|
@@ -150,16 +151,16 @@ class StructRepGenerator:
|
|
|
150
151
|
spg_number_set = []
|
|
151
152
|
iter_refine = 0
|
|
152
153
|
time_refine = 0
|
|
153
|
-
for
|
|
154
|
+
for tol in self.tol_sm:
|
|
154
155
|
t_start = time.time()
|
|
155
156
|
primitive_cell = get_primitive_cell(
|
|
156
|
-
axis=axis, positions=positions, elements=elements, tol=
|
|
157
|
+
axis=axis, positions=positions, elements=elements, tol=tol
|
|
157
158
|
)
|
|
158
159
|
symutil = SymCell(
|
|
159
160
|
primitive_cell.axis,
|
|
160
161
|
primitive_cell.positions,
|
|
161
162
|
primitive_cell.elements,
|
|
162
|
-
symprec=
|
|
163
|
+
symprec=tol,
|
|
163
164
|
)
|
|
164
165
|
spg_str = symutil.get_spacegroup()
|
|
165
166
|
if spg_str is None:
|
|
@@ -167,8 +168,15 @@ class StructRepGenerator:
|
|
|
167
168
|
else:
|
|
168
169
|
spg_number = int(re.search(r"\((\d+)\)", spg_str).group(1))
|
|
169
170
|
|
|
171
|
+
axis_niggli, positions_niggli = niggli_reduce(
|
|
172
|
+
axis=primitive_cell.axis, positions=primitive_cell.positions, tol=tol
|
|
173
|
+
)
|
|
174
|
+
primitive_cell.axis = axis_niggli
|
|
175
|
+
primitive_cell.positions = positions_niggli
|
|
176
|
+
|
|
170
177
|
primitive_st_set.append(primitive_cell)
|
|
171
178
|
spg_number_set.append(spg_number)
|
|
179
|
+
|
|
172
180
|
iter_refine += 1
|
|
173
181
|
time_refine += time.time() - t_start
|
|
174
182
|
|
|
@@ -189,28 +197,26 @@ class StructRepGenerator:
|
|
|
189
197
|
"metric_tensors": [],
|
|
190
198
|
"axis_abc": [],
|
|
191
199
|
"positions": [],
|
|
192
|
-
"
|
|
200
|
+
"tol": [],
|
|
193
201
|
}
|
|
194
202
|
all_reps = {
|
|
195
203
|
"metric_tensors": [],
|
|
196
204
|
"axis_abc": [],
|
|
197
205
|
"positions": [],
|
|
198
|
-
"
|
|
206
|
+
"tol": [],
|
|
199
207
|
}
|
|
200
208
|
iter_redrep = 0
|
|
201
209
|
time_redrep = 0
|
|
202
210
|
|
|
203
|
-
|
|
204
|
-
for
|
|
205
|
-
if isinstance(symprec, float):
|
|
206
|
-
input_symprec = [symprec] * 3
|
|
211
|
+
tol_set = self.tol_redpos
|
|
212
|
+
for tol in tol_set:
|
|
207
213
|
t_start = time.time()
|
|
208
214
|
reducer = PositionRepReducer(
|
|
209
215
|
axis,
|
|
210
216
|
positions,
|
|
211
217
|
elements,
|
|
212
218
|
spg_number,
|
|
213
|
-
|
|
219
|
+
tol=tol,
|
|
214
220
|
normalize_axis=self.normalize_axis,
|
|
215
221
|
verbose=self.verbose,
|
|
216
222
|
)
|
|
@@ -241,12 +247,12 @@ class StructRepGenerator:
|
|
|
241
247
|
all_reps["metric_tensors"].append(metric_tensor)
|
|
242
248
|
all_reps["axis_abc"].append(axis_abc)
|
|
243
249
|
all_reps["positions"].append(all_posrep)
|
|
244
|
-
all_reps["
|
|
250
|
+
all_reps["tol"].append(tol)
|
|
245
251
|
if unique_metric or unique_pos:
|
|
246
252
|
reduced_reps["metric_tensors"].append(metric_tensor)
|
|
247
253
|
reduced_reps["axis_abc"].append(axis_abc)
|
|
248
254
|
reduced_reps["positions"].append(red_posrep)
|
|
249
|
-
reduced_reps["
|
|
255
|
+
reduced_reps["tol"].append(tol)
|
|
250
256
|
|
|
251
257
|
self.iter_redrep += iter_redrep
|
|
252
258
|
self.time_redrep += time_redrep
|
{rsspolymlp-0.4.5 → rsspolymlp-0.4.6}/src/rsspolymlp/analysis/struct_matcher/identify_uniqstr.py
RENAMED
|
@@ -99,9 +99,15 @@ class UniqueStructIdentifier:
|
|
|
99
99
|
pos_tol=self.pos_tol,
|
|
100
100
|
)
|
|
101
101
|
elif self.assign_method == "pymatgen":
|
|
102
|
-
st1 = self.pymat.
|
|
103
|
-
|
|
104
|
-
|
|
102
|
+
st1 = self.pymat.parameter_to_pymat_st(
|
|
103
|
+
uniq_str.original_axis,
|
|
104
|
+
uniq_str.original_positions,
|
|
105
|
+
uniq_str.original_elements,
|
|
106
|
+
)
|
|
107
|
+
st2 = self.pymat.parameter_to_pymat_st(
|
|
108
|
+
struct_reps.original_axis,
|
|
109
|
+
struct_reps.original_positions,
|
|
110
|
+
struct_reps.original_elements,
|
|
105
111
|
)
|
|
106
112
|
judge_duplicate = self.pymat.match_str(st1, st2)
|
|
107
113
|
else:
|
|
@@ -180,8 +186,8 @@ def identify_unique_structure(
|
|
|
180
186
|
pos_tol: float = 0.01,
|
|
181
187
|
assign_method: Literal["redrep", "greedy", "HK", "pymatgen"] = "redrep",
|
|
182
188
|
keep_unique: bool = False,
|
|
183
|
-
|
|
184
|
-
|
|
189
|
+
tol_sm: list[float] = [1e-2],
|
|
190
|
+
tol_redpos: list[float] = [1e-4, 1e-2, 1e-1],
|
|
185
191
|
normalize_axis: bool = False,
|
|
186
192
|
num_process: int = -1,
|
|
187
193
|
backend: str = "loky",
|
|
@@ -215,8 +221,8 @@ def identify_unique_structure(
|
|
|
215
221
|
if verbose:
|
|
216
222
|
print(" - Converting reduced crystal structure representation...")
|
|
217
223
|
generator = StructRepGenerator(
|
|
218
|
-
|
|
219
|
-
|
|
224
|
+
tol_sm=tol_sm,
|
|
225
|
+
tol_redpos=tol_redpos,
|
|
220
226
|
normalize_axis=normalize_axis,
|
|
221
227
|
)
|
|
222
228
|
redreps_list = generator.generate_struct_reps_parallel(
|
|
@@ -0,0 +1,203 @@
|
|
|
1
|
+
import numpy as np
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
def niggli_reduce(
|
|
5
|
+
axis: np.ndarray,
|
|
6
|
+
positions: np.ndarray,
|
|
7
|
+
tol: float = 1e-3,
|
|
8
|
+
):
|
|
9
|
+
"""Niggli reduction."""
|
|
10
|
+
axis = np.array(axis)
|
|
11
|
+
positions = np.array(positions)
|
|
12
|
+
|
|
13
|
+
axis_niggli, P = get_niggli_reduced_cell(
|
|
14
|
+
axis,
|
|
15
|
+
tol=tol,
|
|
16
|
+
)
|
|
17
|
+
pos = positions @ np.linalg.inv(P)
|
|
18
|
+
pos %= 1.0
|
|
19
|
+
|
|
20
|
+
assert abs(round(np.linalg.det(P))) == 1
|
|
21
|
+
return axis_niggli, pos
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
def get_niggli_reduced_cell(axis, tol: float = 1e-5):
|
|
25
|
+
"""
|
|
26
|
+
Get the Niggli-reduced cell using a numerically stable algorithm.
|
|
27
|
+
|
|
28
|
+
References
|
|
29
|
+
----------
|
|
30
|
+
1. I. Krivy and B. Gruber, Acta Cryst. A 32, 297-298 (1976).
|
|
31
|
+
2. R. W. Grosse-Kunstleve, N. K. Sauter, and P. D. Adams, Acta Cryst. A 60, 1-6 (2004).
|
|
32
|
+
|
|
33
|
+
Parameters
|
|
34
|
+
----------
|
|
35
|
+
axis : (3, 3) array_like
|
|
36
|
+
Lattice vectors defining the unit cell in Cartesian coordinates.
|
|
37
|
+
Each row represents one lattice vector (a, b, or c).
|
|
38
|
+
Equivalent to np.array([[a1, a2, a3], [b1, b2, b3], [c1, c2, c3]]).
|
|
39
|
+
tol : float, default=1e-5
|
|
40
|
+
Numerical tolerance for the reduction procedure.
|
|
41
|
+
|
|
42
|
+
Returns
|
|
43
|
+
-------
|
|
44
|
+
axis_niggli : (3, 3) ndarray
|
|
45
|
+
Niggli-reduced lattice vectors, with each row representing one lattice vector.
|
|
46
|
+
"""
|
|
47
|
+
|
|
48
|
+
def get_G_components(G):
|
|
49
|
+
return (
|
|
50
|
+
G[0, 0],
|
|
51
|
+
G[1, 1],
|
|
52
|
+
G[2, 2],
|
|
53
|
+
2 * G[1, 2],
|
|
54
|
+
2 * G[0, 2],
|
|
55
|
+
2 * G[0, 1],
|
|
56
|
+
)
|
|
57
|
+
|
|
58
|
+
def convert_G_and_P(C, G, P):
|
|
59
|
+
G = C.T @ G @ C
|
|
60
|
+
P = P @ C
|
|
61
|
+
return G, P
|
|
62
|
+
|
|
63
|
+
G = np.dot(axis, axis.T)
|
|
64
|
+
P = np.eye(3, dtype=int)
|
|
65
|
+
|
|
66
|
+
norm_a = G[0, 0] ** 0.5
|
|
67
|
+
norm_b = G[1, 1] ** 0.5
|
|
68
|
+
norm_c = G[2, 2] ** 0.5
|
|
69
|
+
e_aa = tol * 2 * norm_a
|
|
70
|
+
e_bb = tol * 2 * norm_b
|
|
71
|
+
e_cc = tol * 2 * norm_c
|
|
72
|
+
e_bc = tol * (norm_b + norm_c)
|
|
73
|
+
e_ac = tol * (norm_a + norm_c)
|
|
74
|
+
e_ab = tol * (norm_a + norm_b)
|
|
75
|
+
|
|
76
|
+
iteration = 100
|
|
77
|
+
for n_iter in range(iteration):
|
|
78
|
+
if n_iter == iteration - 1:
|
|
79
|
+
raise RuntimeError("Niggli reduction did not converge.")
|
|
80
|
+
|
|
81
|
+
aa, bb, cc, bc, ac, ab = get_G_components(G)
|
|
82
|
+
|
|
83
|
+
# A1: Main condition: aa <= bb; Special condition: |bc| < |ac|
|
|
84
|
+
if bb + e_aa + e_bb < aa or (
|
|
85
|
+
abs(aa - bb) < e_aa + e_bb and abs(bc) > abs(ac) + e_bc + e_ac
|
|
86
|
+
):
|
|
87
|
+
C = np.array([[0, -1, 0], [-1, 0, 0], [0, 0, -1]])
|
|
88
|
+
G, P = convert_G_and_P(C, G, P)
|
|
89
|
+
aa, bb, cc, bc, ac, ab = get_G_components(G)
|
|
90
|
+
|
|
91
|
+
# A2: Main condition: bb <= cc; Special condition: |ac| < |ab|
|
|
92
|
+
if cc + e_bb + e_cc < bb or (
|
|
93
|
+
abs(bb - cc) < e_bb + e_cc and abs(ac) > abs(ab) + e_ac + e_ab
|
|
94
|
+
):
|
|
95
|
+
C = np.array([[-1, 0, 0], [0, 0, -1], [0, -1, 0]])
|
|
96
|
+
G, P = convert_G_and_P(C, G, P)
|
|
97
|
+
continue
|
|
98
|
+
|
|
99
|
+
ell = 0 if abs(bc) < e_bc else bc / abs(bc)
|
|
100
|
+
m = 0 if abs(ac) < e_ac else ac / abs(ac)
|
|
101
|
+
n = 0 if abs(ab) < e_ab else ab / abs(ab)
|
|
102
|
+
|
|
103
|
+
# A3: Main condition: bc > 0, ac > 0, ab > 0 (Type I)
|
|
104
|
+
if ell * m * n == 1:
|
|
105
|
+
i = -1 if ell == -1 else 1
|
|
106
|
+
j = -1 if m == -1 else 1
|
|
107
|
+
k = -1 if n == -1 else 1
|
|
108
|
+
C = np.diag((i, j, k))
|
|
109
|
+
G, P = convert_G_and_P(C, G, P)
|
|
110
|
+
|
|
111
|
+
# A4: Main condition: bc <= 0, ac <= 0, ab <= 0 (Type II)
|
|
112
|
+
if ell * m * n in (0, -1):
|
|
113
|
+
i = -1 if ell == 1 else 1
|
|
114
|
+
j = -1 if m == 1 else 1
|
|
115
|
+
k = -1 if n == 1 else 1
|
|
116
|
+
if i * j * k == -1:
|
|
117
|
+
# Keep the proper rotation
|
|
118
|
+
if n == 0:
|
|
119
|
+
k = -1
|
|
120
|
+
elif m == 0:
|
|
121
|
+
j = -1
|
|
122
|
+
elif ell == 0:
|
|
123
|
+
i = -1
|
|
124
|
+
C = np.diag((i, j, k))
|
|
125
|
+
G, P = convert_G_and_P(C, G, P)
|
|
126
|
+
|
|
127
|
+
aa, bb, cc, bc, ac, ab = get_G_components(G)
|
|
128
|
+
|
|
129
|
+
# A5: Main condition: |bc| <= bb;
|
|
130
|
+
# Special conditions: if bc = bb: ab/2 <= ac,
|
|
131
|
+
# elif bc = -bb: ab = 0 (otherwise, convert to Type I)
|
|
132
|
+
if (
|
|
133
|
+
abs(bc) > bb + e_bc + e_bb
|
|
134
|
+
or (abs(bc - bb) < e_bc + e_bb and ab - e_ab - e_ac > 2 * ac)
|
|
135
|
+
or (abs(bc + bb) < e_bc + e_bb and -e_ab > ab)
|
|
136
|
+
):
|
|
137
|
+
# Basis transformation: c' = c - sign(bc) * b
|
|
138
|
+
# cc' = cc + bb - |bc|
|
|
139
|
+
# bc' = bc/2 - sign(bc) * bb
|
|
140
|
+
# ac' = ac/2 - sign(bc) * ab/2
|
|
141
|
+
# If bc = bb and ab > 2 * ac:
|
|
142
|
+
# The transformed cell is Type I and satisfies |ab'| / 2 <= |ac'|,
|
|
143
|
+
# because 2 * |ac'| = 2 * |ac - ab| > ab.
|
|
144
|
+
# If bc = -bb and ab < 0:
|
|
145
|
+
# ac' = ac + ab < 0 and bc' = bb > 0.
|
|
146
|
+
# The transformed cell is Type I.
|
|
147
|
+
# A6 and A7 follow by analogous arguments.
|
|
148
|
+
C = np.array([[1, 0, 0], [0, 1, -bc / abs(bc)], [0, 0, 1]])
|
|
149
|
+
G, P = convert_G_and_P(C, G, P)
|
|
150
|
+
continue
|
|
151
|
+
|
|
152
|
+
# A6: Main condition: |ac| <= aa;
|
|
153
|
+
# Special conditions: if ac = aa: ab/2 <= bc,
|
|
154
|
+
# elif ac = -aa: ab = 0 (otherwise, convert to Type I)
|
|
155
|
+
if (
|
|
156
|
+
abs(ac) > aa + e_aa + e_ac
|
|
157
|
+
or (abs(aa - ac) < e_aa + e_ac and ab - e_ab - e_bc > 2 * bc)
|
|
158
|
+
or (abs(aa + ac) < e_aa + e_ac and -e_ab > ab)
|
|
159
|
+
):
|
|
160
|
+
# Basis transformation: c' = c - sign(ac) * a
|
|
161
|
+
# cc' = cc + aa - |ac|
|
|
162
|
+
# ac' = ac/2 - sign(ac) * aa
|
|
163
|
+
# bc' = bc/2 - sign(ac) * ab/2
|
|
164
|
+
C = np.array([[1, 0, -ac / abs(ac)], [0, 1, 0], [0, 0, 1]])
|
|
165
|
+
G, P = convert_G_and_P(C, G, P)
|
|
166
|
+
continue
|
|
167
|
+
|
|
168
|
+
# A7: Main condition: |ab| <= aa;
|
|
169
|
+
# Special conditions: if ab = aa: ac/2 <= bc,
|
|
170
|
+
# elif ab = -aa: ac = 0 (otherwise, convert to Type I)
|
|
171
|
+
if (
|
|
172
|
+
abs(ab) > aa + e_aa + e_ab
|
|
173
|
+
or (abs(aa - ab) < e_aa + e_ab and ac - e_ac - e_bc > 2 * bc)
|
|
174
|
+
or (abs(aa + ab) < e_aa + e_ab and -e_ac > ac)
|
|
175
|
+
):
|
|
176
|
+
# Basis transformation: b' = b - sign(ab) * a
|
|
177
|
+
# bb' = bb + aa - |ab|
|
|
178
|
+
# ab' = ab/2 - sign(ab) * aa
|
|
179
|
+
# bc' = bc/2 - sign(ab) * ac/2
|
|
180
|
+
C = np.array([[1, -ab / abs(ab), 0], [0, 1, 0], [0, 0, 1]])
|
|
181
|
+
G, P = convert_G_and_P(C, G, P)
|
|
182
|
+
continue
|
|
183
|
+
|
|
184
|
+
# A8: Main condition: |bc| + |ac| + |ab| <= aa + bb (Type II);
|
|
185
|
+
# Special condition: if |bc| + |ac| + |ab| = aa + bb: aa <= |ac| + |ab/2|
|
|
186
|
+
# (otherwise, convert to Type I)
|
|
187
|
+
if -(e_bc + e_ac + e_ab + e_aa + e_bb) > bc + ac + ab + aa + bb or (
|
|
188
|
+
abs(bc + ac + ab + aa + bb)
|
|
189
|
+
< (e_bc + e_ac + e_ab + e_aa + e_bb)
|
|
190
|
+
< ab + (aa + ac) * 2
|
|
191
|
+
):
|
|
192
|
+
# Basis transformation: c' = a + b + c
|
|
193
|
+
# cc' = cc + aa + bb + ab + ac + bc
|
|
194
|
+
# ac' = 2 * aa + ab + ac (special condition: ac' > 0)
|
|
195
|
+
# bc' = 2 * bb + ab + bc (special condition: bc' < 0)
|
|
196
|
+
C = np.array([[1, 0, 1], [0, 1, 1], [0, 0, 1]])
|
|
197
|
+
G, P = convert_G_and_P(C, G, P)
|
|
198
|
+
continue
|
|
199
|
+
|
|
200
|
+
break
|
|
201
|
+
|
|
202
|
+
axis_niggli = P.T @ axis
|
|
203
|
+
return axis_niggli, P.T
|
{rsspolymlp-0.4.5 → rsspolymlp-0.4.6}/src/rsspolymlp/analysis/struct_matcher/primitive_transform.py
RENAMED
|
@@ -1,16 +1,4 @@
|
|
|
1
|
-
"""
|
|
2
|
-
|
|
3
|
-
Convention:
|
|
4
|
-
axis stores lattice vectors as rows.
|
|
5
|
-
L_primitive = inv(M) @ L_original
|
|
6
|
-
frac_primitive = frac_original @ M
|
|
7
|
-
|
|
8
|
-
The implementation is intended for structures whose translational symmetry is
|
|
9
|
-
exact up to a user-specified Cartesian tolerance. It finds candidate
|
|
10
|
-
translations by mapping one reference atom to atoms of the same elements,
|
|
11
|
-
checks each candidate against the complete structure, and reconstructs M using
|
|
12
|
-
an exact integer row-lattice HNF calculation.
|
|
13
|
-
"""
|
|
1
|
+
"""Get a primitive cell from translational symmetry."""
|
|
14
2
|
|
|
15
3
|
from dataclasses import dataclass
|
|
16
4
|
from itertools import product
|
|
@@ -27,12 +15,12 @@ from sympy.matrices.normalforms import hermite_normal_form
|
|
|
27
15
|
class PrimitiveCell:
|
|
28
16
|
"""Result of primitive-cell transformation recovery."""
|
|
29
17
|
|
|
30
|
-
M: np.ndarray # integer 3x3 matrix
|
|
31
|
-
index: int # |det(M)|, number of original cells in primitive cell
|
|
32
|
-
translations: np.ndarray # valid translations in original fractional coordinates
|
|
33
18
|
axis: np.ndarray # inv(M) @ original lattice matrix
|
|
34
19
|
positions: np.ndarray # unique sites in primitive-cell fractional coordinates
|
|
35
20
|
elements: np.ndarray # elements corresponding to primitive_positions
|
|
21
|
+
M: np.ndarray # integer 3x3 matrix
|
|
22
|
+
index: int # |det(M)|, number of original cells in primitive cell
|
|
23
|
+
translations: np.ndarray # valid translations in original fractional coordinates
|
|
36
24
|
mapped_positions: (
|
|
37
25
|
np.ndarray
|
|
38
26
|
) # all original sites transformed by M, wrapped to [0, 1)
|
|
@@ -43,9 +31,8 @@ def get_primitive_cell(
|
|
|
43
31
|
positions: np.ndarray,
|
|
44
32
|
elements: np.ndarray | list[str],
|
|
45
33
|
tol: float = 1e-2,
|
|
46
|
-
translation_tol: float | None = None,
|
|
47
34
|
integer_tol: float = 1e-2,
|
|
48
|
-
verbose: bool =
|
|
35
|
+
verbose: bool = False,
|
|
49
36
|
) -> PrimitiveCell:
|
|
50
37
|
"""Find a primitive-cell transformation from lattice and atom arrays.
|
|
51
38
|
|
|
@@ -59,8 +46,6 @@ def get_primitive_cell(
|
|
|
59
46
|
Length-N sequence identifying each atom elements (e.g. ``["Si", "Si"]``).
|
|
60
47
|
tol
|
|
61
48
|
Cartesian distance tolerance in angstrom for atom matching.
|
|
62
|
-
translation_tol
|
|
63
|
-
Cartesian tolerance for deduplicating candidate translations.
|
|
64
49
|
integer_tol
|
|
65
50
|
Tolerance for checking that ``index * translation`` is integer-valued.
|
|
66
51
|
|
|
@@ -72,20 +57,12 @@ def get_primitive_cell(
|
|
|
72
57
|
|
|
73
58
|
Notes
|
|
74
59
|
-----
|
|
75
|
-
- This implementation assumes the input structure is translationally
|
|
76
|
-
periodic without changing elements.
|
|
77
|
-
- For disordered/partial-occupancy sites, convert to an explicit ordered
|
|
78
|
-
representation before using this function.
|
|
79
60
|
- For strongly skewed, unreduced lattices, the +/-1 image replication used
|
|
80
61
|
by the KD-tree may be insufficient; reduce the lattice first or replace
|
|
81
62
|
the image search with an exact nearest-image routine.
|
|
82
63
|
"""
|
|
83
64
|
if tol <= 0:
|
|
84
65
|
raise ValueError("tol must be positive.")
|
|
85
|
-
if translation_tol is None:
|
|
86
|
-
translation_tol = tol
|
|
87
|
-
if translation_tol <= 0:
|
|
88
|
-
raise ValueError("translation_tol must be positive.")
|
|
89
66
|
|
|
90
67
|
axis = np.asarray(axis, dtype=float)
|
|
91
68
|
positions = np.mod(np.asarray(positions, dtype=float), 1.0)
|
|
@@ -96,9 +73,6 @@ def get_primitive_cell(
|
|
|
96
73
|
raise ValueError("positions must have shape (N, 3).")
|
|
97
74
|
if len(elements) != len(positions):
|
|
98
75
|
raise ValueError("elements and positions must have the same length.")
|
|
99
|
-
n_sites = len(positions)
|
|
100
|
-
if n_sites == 0:
|
|
101
|
-
raise ValueError("Cannot analyze an empty structure.")
|
|
102
76
|
|
|
103
77
|
# Select a reference atom from the least-populated elements to minimize the
|
|
104
78
|
# number of translation candidates.
|
|
@@ -117,10 +91,14 @@ def get_primitive_cell(
|
|
|
117
91
|
for translation in candidate_translations:
|
|
118
92
|
shifted_positions = np.mod(positions + translation, 1.0)
|
|
119
93
|
shifted_cart = shifted_positions @ axis
|
|
120
|
-
|
|
94
|
+
is_valid, mean_translation = _translation_is_valid(
|
|
95
|
+
shifted_cart, elements, trees, tol
|
|
96
|
+
)
|
|
97
|
+
if not is_valid:
|
|
121
98
|
continue
|
|
99
|
+
translation += mean_translation @ np.linalg.inv(axis)
|
|
122
100
|
duplicate = any(
|
|
123
|
-
_periodic_translation_distance(translation, old, axis) <=
|
|
101
|
+
_periodic_translation_distance(translation, old, axis) <= tol
|
|
124
102
|
for old in valid_translations
|
|
125
103
|
)
|
|
126
104
|
if not duplicate:
|
|
@@ -144,7 +122,7 @@ def get_primitive_cell(
|
|
|
144
122
|
mapped_positions, elements, primitive_lattice, tol
|
|
145
123
|
)
|
|
146
124
|
|
|
147
|
-
expected_n_sites =
|
|
125
|
+
expected_n_sites = len(positions) // index
|
|
148
126
|
if len(primitive_positions) != expected_n_sites:
|
|
149
127
|
raise RuntimeError(
|
|
150
128
|
"The recovered primitive cell has an unexpected number of unique sites: "
|
|
@@ -153,12 +131,12 @@ def get_primitive_cell(
|
|
|
153
131
|
)
|
|
154
132
|
|
|
155
133
|
return PrimitiveCell(
|
|
156
|
-
M=M,
|
|
157
|
-
index=index,
|
|
158
|
-
translations=translations,
|
|
159
134
|
axis=primitive_lattice,
|
|
160
135
|
positions=primitive_positions,
|
|
161
136
|
elements=primitive_elements,
|
|
137
|
+
M=M,
|
|
138
|
+
index=index,
|
|
139
|
+
translations=translations,
|
|
162
140
|
mapped_positions=mapped_positions,
|
|
163
141
|
)
|
|
164
142
|
|
|
@@ -188,19 +166,20 @@ def _translation_is_valid(
|
|
|
188
166
|
elements: np.ndarray,
|
|
189
167
|
trees: dict[str, tuple[cKDTree, np.ndarray]],
|
|
190
168
|
tol: float,
|
|
191
|
-
) -> bool:
|
|
169
|
+
) -> tuple[bool, np.ndarray]:
|
|
192
170
|
"""Check whether a translation maps all sites onto same-elements sites."""
|
|
171
|
+
translations = []
|
|
193
172
|
for element in np.unique(elements):
|
|
194
173
|
target_ids = np.flatnonzero(elements == element)
|
|
195
174
|
tree, image_to_atom_id = trees[str(element)]
|
|
196
175
|
target_count = len(target_ids)
|
|
176
|
+
|
|
197
177
|
candidate_rows: list[int] = []
|
|
198
178
|
candidate_cols: list[int] = []
|
|
199
|
-
|
|
200
179
|
neighbor_lists = tree.query_ball_point(shifted_cart[target_ids], r=tol)
|
|
201
180
|
for shifted_atom_id, match_image_idxs in enumerate(neighbor_lists):
|
|
202
181
|
if not match_image_idxs:
|
|
203
|
-
return False
|
|
182
|
+
return False, np.array([])
|
|
204
183
|
match_atom_ids = np.unique(
|
|
205
184
|
image_to_atom_id[np.asarray(match_image_idxs, dtype=int)]
|
|
206
185
|
)
|
|
@@ -216,8 +195,14 @@ def _translation_is_valid(
|
|
|
216
195
|
)
|
|
217
196
|
matching = maximum_bipartite_matching(graph, perm_type="column")
|
|
218
197
|
if matching.shape[0] != target_count or np.any(matching < 0):
|
|
219
|
-
return False
|
|
220
|
-
|
|
198
|
+
return False, np.array([])
|
|
199
|
+
|
|
200
|
+
matched_cart = shifted_cart[target_ids]
|
|
201
|
+
target_cart = shifted_cart[target_ids]
|
|
202
|
+
translations.extend(target_cart[matching] - matched_cart)
|
|
203
|
+
|
|
204
|
+
mean_translation = np.mean(translations, axis=0)
|
|
205
|
+
return True, mean_translation
|
|
221
206
|
|
|
222
207
|
|
|
223
208
|
def _periodic_translation_distance(
|