rsspolymlp 0.4.4__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.4/src/rsspolymlp.egg-info → rsspolymlp-0.4.6}/PKG-INFO +4 -2
- {rsspolymlp-0.4.4 → rsspolymlp-0.4.6}/README.md +2 -1
- {rsspolymlp-0.4.4 → rsspolymlp-0.4.6}/pyproject.toml +2 -1
- {rsspolymlp-0.4.4 → rsspolymlp-0.4.6}/src/rsspolymlp/analysis/rss_summarize.py +60 -30
- rsspolymlp-0.4.6/src/rsspolymlp/analysis/struct_matcher/assignment_algo.py +245 -0
- {rsspolymlp-0.4.4 → rsspolymlp-0.4.6}/src/rsspolymlp/analysis/struct_matcher/gen_struct_rep.py +119 -142
- {rsspolymlp-0.4.4 → rsspolymlp-0.4.6}/src/rsspolymlp/analysis/struct_matcher/identify_uniqstr.py +15 -16
- rsspolymlp-0.4.6/src/rsspolymlp/analysis/struct_matcher/niggli_reduce.py +203 -0
- rsspolymlp-0.4.6/src/rsspolymlp/analysis/struct_matcher/primitive_transform.py +333 -0
- {rsspolymlp-0.4.4 → rsspolymlp-0.4.6}/src/rsspolymlp/analysis/struct_matcher/redrep_position.py +151 -107
- {rsspolymlp-0.4.4 → rsspolymlp-0.4.6}/src/rsspolymlp/analysis/struct_matcher/struct_match.py +18 -15
- rsspolymlp-0.4.4/src/rsspolymlp/common/convert_dict.py → rsspolymlp-0.4.6/src/rsspolymlp/analysis/utils/convert_data_format.py +1 -1
- {rsspolymlp-0.4.4 → rsspolymlp-0.4.6}/src/rsspolymlp/api/cli_rsspolymlp.py +1 -1
- {rsspolymlp-0.4.4 → rsspolymlp-0.4.6}/src/rsspolymlp/api/cli_rsspolymlp_utils.py +6 -20
- {rsspolymlp-0.4.4 → rsspolymlp-0.4.6}/src/rsspolymlp/api/rsspolymlp.py +2 -2
- {rsspolymlp-0.4.4 → rsspolymlp-0.4.6}/src/rsspolymlp/api/rsspolymlp_utils.py +41 -33
- rsspolymlp-0.4.6/src/rsspolymlp/common/interface_pypolymlp.py +50 -0
- rsspolymlp-0.4.6/src/rsspolymlp/common/interface_spglib.py +115 -0
- {rsspolymlp-0.4.4 → rsspolymlp-0.4.6}/src/rsspolymlp/common/interface_vasp.py +44 -1
- {rsspolymlp-0.4.4 → rsspolymlp-0.4.6}/src/rsspolymlp/common/property.py +2 -13
- {rsspolymlp-0.4.4 → rsspolymlp-0.4.6}/src/rsspolymlp/rss/eliminate_duplicates.py +6 -5
- {rsspolymlp-0.4.4 → rsspolymlp-0.4.6}/src/rsspolymlp/rss/load_logfile.py +5 -0
- {rsspolymlp-0.4.4 → rsspolymlp-0.4.6}/src/rsspolymlp/rss/optimization_mlp.py +80 -101
- {rsspolymlp-0.4.4 → rsspolymlp-0.4.6}/src/rsspolymlp/rss/random_struct.py +7 -2
- {rsspolymlp-0.4.4 → rsspolymlp-0.4.6/src/rsspolymlp.egg-info}/PKG-INFO +4 -2
- {rsspolymlp-0.4.4 → rsspolymlp-0.4.6}/src/rsspolymlp.egg-info/SOURCES.txt +5 -5
- {rsspolymlp-0.4.4 → rsspolymlp-0.4.6}/src/rsspolymlp.egg-info/requires.txt +1 -0
- rsspolymlp-0.4.4/src/rsspolymlp/analysis/struct_matcher/assignment_algo.py +0 -181
- rsspolymlp-0.4.4/src/rsspolymlp/analysis/struct_matcher/redrep_lattice.py +0 -144
- rsspolymlp-0.4.4/src/rsspolymlp/analysis/struct_matcher/test/time_measure.py +0 -0
- rsspolymlp-0.4.4/src/rsspolymlp/utils/spglib_utils.py +0 -236
- rsspolymlp-0.4.4/src/rsspolymlp/utils/vasp_util/write_poscar.py +0 -49
- {rsspolymlp-0.4.4 → rsspolymlp-0.4.6}/LICENSE +0 -0
- {rsspolymlp-0.4.4 → rsspolymlp-0.4.6}/setup.cfg +0 -0
- {rsspolymlp-0.4.4 → rsspolymlp-0.4.6}/src/rsspolymlp/__init__.py +0 -0
- {rsspolymlp-0.4.4 → rsspolymlp-0.4.6}/src/rsspolymlp/analysis/__init__.py +0 -0
- {rsspolymlp-0.4.4 → rsspolymlp-0.4.6}/src/rsspolymlp/analysis/eos.py +0 -0
- {rsspolymlp-0.4.4 → rsspolymlp-0.4.6}/src/rsspolymlp/analysis/ghost_minima.py +0 -0
- {rsspolymlp-0.4.4 → rsspolymlp-0.4.6}/src/rsspolymlp/analysis/phase_analysis.py +0 -0
- {rsspolymlp-0.4.4 → rsspolymlp-0.4.6}/src/rsspolymlp/analysis/struct_matcher/__init__.py +0 -0
- {rsspolymlp-0.4.4 → rsspolymlp-0.4.6}/src/rsspolymlp/analysis/struct_matcher/chiral_spg.py +0 -0
- {rsspolymlp-0.4.4 → rsspolymlp-0.4.6}/src/rsspolymlp/analysis/struct_matcher/test/gen_lattice.py +0 -0
- {rsspolymlp-0.4.4 → rsspolymlp-0.4.6}/src/rsspolymlp/api/__init__.py +0 -0
- {rsspolymlp-0.4.4 → rsspolymlp-0.4.6}/src/rsspolymlp/api/cli_rsspolymlp_devkit.py +0 -0
- {rsspolymlp-0.4.4 → rsspolymlp-0.4.6}/src/rsspolymlp/api/cli_rsspolymlp_plot.py +0 -0
- {rsspolymlp-0.4.4 → rsspolymlp-0.4.6}/src/rsspolymlp/api/rsspolymlp_devkit.py +0 -0
- {rsspolymlp-0.4.4 → rsspolymlp-0.4.6}/src/rsspolymlp/api/rsspolymlp_plot.py +0 -0
- {rsspolymlp-0.4.4 → rsspolymlp-0.4.6}/src/rsspolymlp/common/__init__.py +0 -0
- {rsspolymlp-0.4.4 → rsspolymlp-0.4.6}/src/rsspolymlp/common/atomic_energy.py +0 -0
- {rsspolymlp-0.4.4 → rsspolymlp-0.4.6}/src/rsspolymlp/common/composition.py +0 -0
- {rsspolymlp-0.4.4 → rsspolymlp-0.4.6}/src/rsspolymlp/mlp_dev/dataset/compress_vasprun.py +0 -0
- {rsspolymlp-0.4.4 → rsspolymlp-0.4.6}/src/rsspolymlp/mlp_dev/dataset/gen_mlp_dataset.py +0 -0
- {rsspolymlp-0.4.4 → rsspolymlp-0.4.6}/src/rsspolymlp/mlp_dev/dataset/split_dataset.py +0 -0
- {rsspolymlp-0.4.4 → rsspolymlp-0.4.6}/src/rsspolymlp/mlp_dev/estimate_cost.py +0 -0
- {rsspolymlp-0.4.4 → rsspolymlp-0.4.6}/src/rsspolymlp/mlp_dev/model_selection/binary/gen_single_model.py +0 -0
- {rsspolymlp-0.4.4 → rsspolymlp-0.4.6}/src/rsspolymlp/mlp_dev/model_selection/elemental/gen_hybrid_model.py +0 -0
- {rsspolymlp-0.4.4 → rsspolymlp-0.4.6}/src/rsspolymlp/mlp_dev/model_selection/elemental/gen_single_model.py +0 -0
- {rsspolymlp-0.4.4 → rsspolymlp-0.4.6}/src/rsspolymlp/mlp_dev/model_selection/n_feature.py +0 -0
- {rsspolymlp-0.4.4 → rsspolymlp-0.4.6}/src/rsspolymlp/mlp_dev/model_selection/pypolymlp_gridsearch.py +0 -0
- {rsspolymlp-0.4.4 → rsspolymlp-0.4.6}/src/rsspolymlp/mlp_dev/model_selection/reduce_grid.py +0 -0
- {rsspolymlp-0.4.4 → rsspolymlp-0.4.6}/src/rsspolymlp/mlp_dev/pareto_opt_mlp.py +0 -0
- {rsspolymlp-0.4.4 → rsspolymlp-0.4.6}/src/rsspolymlp/mlp_dev/polymlp_dev.py +0 -0
- {rsspolymlp-0.4.4 → rsspolymlp-0.4.6}/src/rsspolymlp/rss/__init__.py +0 -0
- {rsspolymlp-0.4.4 → rsspolymlp-0.4.6}/src/rsspolymlp/utils/__init__.py +0 -0
- {rsspolymlp-0.4.4 → rsspolymlp-0.4.6}/src/rsspolymlp/utils/lammps_utils.py +0 -0
- {rsspolymlp-0.4.4 → rsspolymlp-0.4.6}/src/rsspolymlp/utils/matplot_util/__init__.py +0 -0
- {rsspolymlp-0.4.4 → rsspolymlp-0.4.6}/src/rsspolymlp/utils/matplot_util/custom_plt.py +0 -0
- {rsspolymlp-0.4.4 → rsspolymlp-0.4.6}/src/rsspolymlp/utils/matplot_util/examples/__init__.py +0 -0
- {rsspolymlp-0.4.4 → rsspolymlp-0.4.6}/src/rsspolymlp/utils/matplot_util/examples/example.py +0 -0
- {rsspolymlp-0.4.4 → rsspolymlp-0.4.6}/src/rsspolymlp/utils/matplot_util/examples/template.py +0 -0
- {rsspolymlp-0.4.4 → rsspolymlp-0.4.6}/src/rsspolymlp/utils/matplot_util/make_plot.py +0 -0
- {rsspolymlp-0.4.4 → rsspolymlp-0.4.6}/src/rsspolymlp/utils/opt_sscha/opt_geometry_sscha.py +0 -0
- {rsspolymlp-0.4.4 → rsspolymlp-0.4.6}/src/rsspolymlp/utils/opt_sscha/opt_position_sscha.py +0 -0
- {rsspolymlp-0.4.4 → rsspolymlp-0.4.6}/src/rsspolymlp/utils/opt_sscha/run_opt_sscha.py +0 -0
- {rsspolymlp-0.4.4 → rsspolymlp-0.4.6}/src/rsspolymlp/utils/opt_sscha/sscha_property.py +0 -0
- {rsspolymlp-0.4.4 → rsspolymlp-0.4.6}/src/rsspolymlp/utils/pymatgen_utils.py +0 -0
- {rsspolymlp-0.4.4 → rsspolymlp-0.4.6}/src/rsspolymlp/utils/vasp_util/__init__.py +0 -0
- {rsspolymlp-0.4.4 → rsspolymlp-0.4.6}/src/rsspolymlp/utils/vasp_util/api.py +0 -0
- {rsspolymlp-0.4.4 → rsspolymlp-0.4.6}/src/rsspolymlp/utils/vasp_util/gen_incar.py +0 -0
- {rsspolymlp-0.4.4 → rsspolymlp-0.4.6}/src/rsspolymlp/utils/vasp_util/gen_script.py +0 -0
- {rsspolymlp-0.4.4 → rsspolymlp-0.4.6}/src/rsspolymlp.egg-info/dependency_links.txt +0 -0
- {rsspolymlp-0.4.4 → rsspolymlp-0.4.6}/src/rsspolymlp.egg-info/entry_points.txt +0 -0
- {rsspolymlp-0.4.4 → rsspolymlp-0.4.6}/src/rsspolymlp.egg-info/top_level.txt +0 -0
- {rsspolymlp-0.4.4 → 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>
|
|
@@ -12,6 +12,7 @@ Description-Content-Type: text/markdown
|
|
|
12
12
|
License-File: LICENSE
|
|
13
13
|
Requires-Dist: numpy
|
|
14
14
|
Requires-Dist: scipy
|
|
15
|
+
Requires-Dist: sympy
|
|
15
16
|
Requires-Dist: scikit-learn
|
|
16
17
|
Requires-Dist: joblib
|
|
17
18
|
Requires-Dist: pypolymlp
|
|
@@ -41,6 +42,7 @@ The formulation and development of polynomial MLPs are detailed in [`pypolymlp`]
|
|
|
41
42
|
|
|
42
43
|
- python >= 3.10
|
|
43
44
|
- scikit-learn
|
|
45
|
+
- sympy
|
|
44
46
|
- joblib
|
|
45
47
|
- pypolymlp
|
|
46
48
|
- spglib
|
|
@@ -67,7 +69,7 @@ conda install -c conda-forge rsspolymlp
|
|
|
67
69
|
```shell
|
|
68
70
|
conda create -n rsspolymlp
|
|
69
71
|
conda activate rsspolymlp
|
|
70
|
-
conda install -c conda-forge scikit-learn joblib pypolymlp spglib symfc
|
|
72
|
+
conda install -c conda-forge scikit-learn sympy joblib pypolymlp spglib symfc
|
|
71
73
|
pip install rsspolymlp
|
|
72
74
|
```
|
|
73
75
|
|
|
@@ -10,6 +10,7 @@ The formulation and development of polynomial MLPs are detailed in [`pypolymlp`]
|
|
|
10
10
|
|
|
11
11
|
- python >= 3.10
|
|
12
12
|
- scikit-learn
|
|
13
|
+
- sympy
|
|
13
14
|
- joblib
|
|
14
15
|
- pypolymlp
|
|
15
16
|
- spglib
|
|
@@ -36,7 +37,7 @@ conda install -c conda-forge rsspolymlp
|
|
|
36
37
|
```shell
|
|
37
38
|
conda create -n rsspolymlp
|
|
38
39
|
conda activate rsspolymlp
|
|
39
|
-
conda install -c conda-forge scikit-learn joblib pypolymlp spglib symfc
|
|
40
|
+
conda install -c conda-forge scikit-learn sympy joblib pypolymlp spglib symfc
|
|
40
41
|
pip install rsspolymlp
|
|
41
42
|
```
|
|
42
43
|
|
|
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "rsspolymlp"
|
|
7
|
-
version = "0.4.
|
|
7
|
+
version = "0.4.6"
|
|
8
8
|
description = "A framework for random structure search using polynomial MLPs"
|
|
9
9
|
license = "MIT"
|
|
10
10
|
authors = [
|
|
@@ -18,6 +18,7 @@ requires-python = ">=3.10"
|
|
|
18
18
|
dependencies = [
|
|
19
19
|
"numpy",
|
|
20
20
|
"scipy",
|
|
21
|
+
"sympy",
|
|
21
22
|
"scikit-learn",
|
|
22
23
|
"joblib",
|
|
23
24
|
"pypolymlp",
|
|
@@ -20,11 +20,10 @@ from rsspolymlp.analysis.struct_matcher.identify_uniqstr import (
|
|
|
20
20
|
UniqueStructIdentifier,
|
|
21
21
|
identify_unique_structure,
|
|
22
22
|
)
|
|
23
|
-
from rsspolymlp.
|
|
24
|
-
from rsspolymlp.common.convert_dict import (
|
|
23
|
+
from rsspolymlp.analysis.utils.convert_data_format import (
|
|
25
24
|
polymlp_struct_from_dict,
|
|
26
|
-
polymlp_struct_to_dict,
|
|
27
25
|
)
|
|
26
|
+
from rsspolymlp.common.composition import compute_composition
|
|
28
27
|
from rsspolymlp.common.interface_vasp import Vasprun, parse_properties_from_vasprun
|
|
29
28
|
from rsspolymlp.common.property import PropUtil
|
|
30
29
|
|
|
@@ -39,7 +38,7 @@ class RSSResultSummarizer:
|
|
|
39
38
|
num_process: int = -1,
|
|
40
39
|
backend: str = "loky",
|
|
41
40
|
assign_method: Literal["redrep", "greedy", "HK", "pymatgen"] = "redrep",
|
|
42
|
-
|
|
41
|
+
tol_sm: list[float] = [1e-2],
|
|
43
42
|
output_poscar: bool = False,
|
|
44
43
|
thresholds: list[float] = None,
|
|
45
44
|
parse_vasp: bool = False,
|
|
@@ -53,7 +52,7 @@ class RSSResultSummarizer:
|
|
|
53
52
|
self.num_process = num_process
|
|
54
53
|
self.backend = backend
|
|
55
54
|
self.assign_method = assign_method
|
|
56
|
-
self.
|
|
55
|
+
self.tol_sm = tol_sm
|
|
57
56
|
self.output_poscar = output_poscar
|
|
58
57
|
self.thresholds = thresholds
|
|
59
58
|
self.parse_vasp = parse_vasp
|
|
@@ -125,6 +124,8 @@ class RSSResultSummarizer:
|
|
|
125
124
|
axis_tol=axis_tol,
|
|
126
125
|
pos_tol=pos_tol,
|
|
127
126
|
assign_method=self.assign_method,
|
|
127
|
+
tol_sm=self.tol_sm,
|
|
128
|
+
num_process=self.num_process,
|
|
128
129
|
pre_analyzer=self.analyzer,
|
|
129
130
|
)
|
|
130
131
|
|
|
@@ -219,6 +220,8 @@ class RSSResultSummarizer:
|
|
|
219
220
|
axis_tol=axis_tol,
|
|
220
221
|
pos_tol=pos_tol,
|
|
221
222
|
assign_method=self.assign_method,
|
|
223
|
+
tol_sm=self.tol_sm,
|
|
224
|
+
num_process=self.num_process,
|
|
222
225
|
pre_analyzer=self.analyzer,
|
|
223
226
|
)
|
|
224
227
|
time_finish = time() - time_start
|
|
@@ -264,13 +267,21 @@ class RSSResultSummarizer:
|
|
|
264
267
|
|
|
265
268
|
processed_paths = []
|
|
266
269
|
for r in rss_results:
|
|
267
|
-
|
|
270
|
+
if "structure" in r:
|
|
271
|
+
r["structure"] = polymlp_struct_from_dict(r["structure"])
|
|
272
|
+
r["axis"] = r["structure"].axis.T
|
|
273
|
+
r["positions"] = r["structure"].positions.T
|
|
274
|
+
r["elements"] = r["structure"].elements
|
|
275
|
+
else:
|
|
276
|
+
r["axis"] = np.array(r["axis"])
|
|
277
|
+
r["positions"] = np.array(r["positions"])
|
|
278
|
+
r["elements"] = np.array(r["elements"])
|
|
268
279
|
processed_paths.extend(r["dupstr_paths"])
|
|
269
280
|
r["dupstr_paths"] = set(r["dupstr_paths"])
|
|
270
281
|
|
|
271
282
|
print(" - Converting reduced crystal structure representation...")
|
|
272
283
|
generator = StructRepGenerator(
|
|
273
|
-
|
|
284
|
+
tol_sm=self.tol_sm,
|
|
274
285
|
)
|
|
275
286
|
struct_reps_list = generator.generate_struct_reps_parallel(
|
|
276
287
|
rss_results,
|
|
@@ -380,7 +391,15 @@ class RSSResultSummarizer:
|
|
|
380
391
|
for r in loaded_dict["rss_results"]:
|
|
381
392
|
r["struct_path"] = resolve_path(base, r["struct_path"])
|
|
382
393
|
r["dupstr_paths"] = {resolve_path(base, p) for p in r["dupstr_paths"]}
|
|
383
|
-
|
|
394
|
+
if "structure" in r:
|
|
395
|
+
r["structure"] = polymlp_struct_from_dict(r["structure"])
|
|
396
|
+
r["axis"] = r["structure"].axis.T
|
|
397
|
+
r["positions"] = r["structure"].positions.T
|
|
398
|
+
r["elements"] = r["structre"].elements
|
|
399
|
+
else:
|
|
400
|
+
r["axis"] = np.array(r["axis"])
|
|
401
|
+
r["positions"] = np.array(r["positions"])
|
|
402
|
+
r["elements"] = np.array(r["elements"])
|
|
384
403
|
r["struct_tag"] = None
|
|
385
404
|
r["pressure"] = pressure
|
|
386
405
|
|
|
@@ -432,7 +451,9 @@ class RSSResultSummarizer:
|
|
|
432
451
|
res_dict["struct_path"] = os.path.relpath(
|
|
433
452
|
path_name + "/vasprun.xml", os.getcwd()
|
|
434
453
|
)
|
|
435
|
-
res_dict["
|
|
454
|
+
res_dict["axis"] = polymlp_st.axis.T
|
|
455
|
+
res_dict["positions"] = polymlp_st.positions.T
|
|
456
|
+
res_dict["elements"] = polymlp_st.elements
|
|
436
457
|
res_dict["energy"] = energy_dft
|
|
437
458
|
res_dict["spg_list"] = spg_list
|
|
438
459
|
res_dict["dupstr_paths"] = {res_dict["struct_path"]}
|
|
@@ -478,14 +499,18 @@ def dump_json_rss_results(
|
|
|
478
499
|
|
|
479
500
|
rss_results = []
|
|
480
501
|
for idx, _str in enumerate(struct_reps_list):
|
|
481
|
-
|
|
482
|
-
|
|
502
|
+
axis = _str.original_axis
|
|
503
|
+
positions = _str.original_positions
|
|
504
|
+
elements = _str.original_elements
|
|
505
|
+
objprop = PropUtil(axis, positions)
|
|
483
506
|
rss_results.append(
|
|
484
507
|
{
|
|
485
508
|
"struct_path": _str.struct_path,
|
|
486
509
|
"poscar_path": _str.struct_path,
|
|
487
|
-
"structure": polymlp_struct_to_dict(polymlp_st),
|
|
488
510
|
"energy": enthalpy_lists[idx],
|
|
511
|
+
"axis": axis.tolist(),
|
|
512
|
+
"positions": positions.tolist(),
|
|
513
|
+
"elements": elements.tolist(),
|
|
489
514
|
"axis_abc": objprop.abc,
|
|
490
515
|
"least_distance": objprop.least_distance,
|
|
491
516
|
"volume": objprop.volume,
|
|
@@ -496,7 +521,7 @@ def dump_json_rss_results(
|
|
|
496
521
|
}
|
|
497
522
|
)
|
|
498
523
|
if len(struct_reps_list) > 0:
|
|
499
|
-
comp_res = compute_composition(
|
|
524
|
+
comp_res = compute_composition(elements)
|
|
500
525
|
rss_result_all = {
|
|
501
526
|
"elements": comp_res.unique_elements.tolist(),
|
|
502
527
|
"comp_ratio": comp_res.comp_ratio,
|
|
@@ -519,6 +544,7 @@ def log_unique_structures(
|
|
|
519
544
|
enthalpy_lists: Optional[list[float]] = None,
|
|
520
545
|
is_ghost_minima=None,
|
|
521
546
|
unique_struct_iters=None,
|
|
547
|
+
print_duplicates: bool = False,
|
|
522
548
|
):
|
|
523
549
|
if is_ghost_minima is None:
|
|
524
550
|
is_ghost_minima = np.full_like(struct_reps_list, False, dtype=bool)
|
|
@@ -555,10 +581,12 @@ def log_unique_structures(
|
|
|
555
581
|
e = enthalpy_lists[idx]
|
|
556
582
|
else:
|
|
557
583
|
e = None
|
|
558
|
-
polymlp_st = _str.original_polymlp_st
|
|
559
|
-
objprop = PropUtil(polymlp_st.axis.T, polymlp_st.positions.T)
|
|
560
|
-
dupstr_paths = list(_str.dupstr_paths)
|
|
561
584
|
|
|
585
|
+
axis = _str.original_axis
|
|
586
|
+
positions = _str.original_positions
|
|
587
|
+
elements = _str.original_elements
|
|
588
|
+
objprop = PropUtil(axis, positions)
|
|
589
|
+
dupstr_paths = list(_str.dupstr_paths)
|
|
562
590
|
print(f" - struct_No: {_str.struct_tag}", file=f)
|
|
563
591
|
print(f" struct_path: {_str.struct_path}", file=f)
|
|
564
592
|
if energy_min is not None:
|
|
@@ -567,21 +595,22 @@ def log_unique_structures(
|
|
|
567
595
|
print(f" enthalpy: {e}", file=f)
|
|
568
596
|
print(f" axis: {objprop.abc}", file=f)
|
|
569
597
|
print(
|
|
570
|
-
f" positions: {
|
|
598
|
+
f" positions: {positions.tolist()}",
|
|
571
599
|
file=f,
|
|
572
600
|
)
|
|
573
|
-
print(f" elements: {
|
|
601
|
+
print(f" elements: {elements.tolist()}", file=f)
|
|
574
602
|
print(f" space_group: {_str.spg_list}", file=f)
|
|
575
603
|
|
|
576
604
|
info = [
|
|
577
|
-
f"{len(
|
|
605
|
+
f"{len(elements)} atom",
|
|
578
606
|
f"distance {round(objprop.least_distance, 3)} (Ang.)",
|
|
579
607
|
f"volume {round(objprop.volume, 2)} (A^3/atom)",
|
|
580
608
|
]
|
|
581
609
|
if unique_struct_iters is not None:
|
|
582
610
|
info.append(f"iteration {unique_struct_iters[idx]}")
|
|
583
611
|
print(f" other_info: {' / '.join(info)}", file=f)
|
|
584
|
-
|
|
612
|
+
if print_duplicates:
|
|
613
|
+
print(" duplicate_paths:", _str.dupstr_paths, file=f)
|
|
585
614
|
if is_ghost_minima[idx]:
|
|
586
615
|
print(" ghost_minima_flag: true", file=f)
|
|
587
616
|
|
|
@@ -611,8 +640,10 @@ def log_all_unique_structures(
|
|
|
611
640
|
e = unique_str_prop[idx1][idx2]["energy"]
|
|
612
641
|
else:
|
|
613
642
|
e = None
|
|
614
|
-
|
|
615
|
-
|
|
643
|
+
axis = _str.original_axis
|
|
644
|
+
positions = _str.original_positions
|
|
645
|
+
elements = _str.original_elements
|
|
646
|
+
objprop = PropUtil(axis, positions)
|
|
616
647
|
print(f" - sub_struct_No: '{idx1 + 1}_{idx2 + 1}'", file=f)
|
|
617
648
|
print(f" struct_path: {_str.struct_path}", file=f)
|
|
618
649
|
print(
|
|
@@ -621,14 +652,14 @@ def log_all_unique_structures(
|
|
|
621
652
|
print(f" enthalpy: {e}", file=f)
|
|
622
653
|
print(f" axis: {objprop.abc}", file=f)
|
|
623
654
|
print(
|
|
624
|
-
f" positions: {
|
|
655
|
+
f" positions: {positions.tolist()}",
|
|
625
656
|
file=f,
|
|
626
657
|
)
|
|
627
|
-
print(f" elements: {
|
|
658
|
+
print(f" elements: {elements}", file=f)
|
|
628
659
|
print(f" space_group: {_str.spg_list}", file=f)
|
|
629
660
|
|
|
630
661
|
info = [
|
|
631
|
-
f"{len(
|
|
662
|
+
f"{len(elements)} atom",
|
|
632
663
|
f"distance {round(objprop.least_distance, 3)} (Ang.)",
|
|
633
664
|
f"volume {round(objprop.volume, 2)} (A^3/atom)",
|
|
634
665
|
]
|
|
@@ -636,8 +667,9 @@ def log_all_unique_structures(
|
|
|
636
667
|
|
|
637
668
|
_res = {}
|
|
638
669
|
_res["struct_path"] = _str.struct_path
|
|
639
|
-
|
|
640
|
-
_res["
|
|
670
|
+
_res["axis"] = axis
|
|
671
|
+
_res["positions"] = positions
|
|
672
|
+
_res["elements"] = elements
|
|
641
673
|
_res["energy"] = e
|
|
642
674
|
_res["pressure"] = None
|
|
643
675
|
_res["spg_list"] = _str.spg_list
|
|
@@ -647,13 +679,11 @@ def log_all_unique_structures(
|
|
|
647
679
|
if unique_other_prop is not None:
|
|
648
680
|
print(" properties:", unique_other_prop[idx1], file=f)
|
|
649
681
|
|
|
650
|
-
comp_res = compute_composition(
|
|
651
|
-
|
|
682
|
+
comp_res = compute_composition(elements)
|
|
652
683
|
rss_result_all = {
|
|
653
684
|
"elements": comp_res.unique_elements.tolist(),
|
|
654
685
|
"comp_ratio": comp_res.comp_ratio,
|
|
655
686
|
"pressure": None,
|
|
656
687
|
"rss_results": rss_results,
|
|
657
688
|
}
|
|
658
|
-
|
|
659
689
|
return rss_result_all
|
|
@@ -0,0 +1,245 @@
|
|
|
1
|
+
import time
|
|
2
|
+
|
|
3
|
+
import numpy as np
|
|
4
|
+
from scipy.optimize import minimize
|
|
5
|
+
from scipy.sparse import csr_array
|
|
6
|
+
from scipy.sparse.csgraph import maximum_bipartite_matching
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
def sort_match_screen(
|
|
10
|
+
pos_reps1: np.ndarray,
|
|
11
|
+
pos_reps2: np.ndarray,
|
|
12
|
+
elements1: np.ndarray,
|
|
13
|
+
elements2: np.ndarray,
|
|
14
|
+
axis_abc: np.ndarray,
|
|
15
|
+
pos_tol: float,
|
|
16
|
+
verbose: bool = False,
|
|
17
|
+
):
|
|
18
|
+
# pos1: (N1, n_atoms, 3)
|
|
19
|
+
# pos2: (N2, n_atoms, 3)
|
|
20
|
+
if len(elements1) != len(elements2):
|
|
21
|
+
return np.zeros((len(pos_reps1), len(pos_reps2)), dtype=bool)
|
|
22
|
+
unique_elements = np.unique(elements1)
|
|
23
|
+
|
|
24
|
+
def sort_positions_axis(pos_reps, elements, axis):
|
|
25
|
+
pos_reps = np.asarray(pos_reps)
|
|
26
|
+
reps_diff = np.empty_like(pos_reps[:, :, axis])
|
|
27
|
+
start = 0
|
|
28
|
+
for el in unique_elements:
|
|
29
|
+
idx = np.flatnonzero(elements == el)
|
|
30
|
+
sorted_reps = np.sort(pos_reps[:, idx, axis], axis=1)
|
|
31
|
+
diff = np.roll(sorted_reps, -1, axis=1) - sorted_reps
|
|
32
|
+
diff[:, -1] += axis_abc[axis]
|
|
33
|
+
reps_diff[:, start : start + len(idx)] = np.sort(diff, axis=1)
|
|
34
|
+
start += len(idx)
|
|
35
|
+
return reps_diff
|
|
36
|
+
|
|
37
|
+
matched = np.ones(
|
|
38
|
+
(len(pos_reps1), len(pos_reps2)),
|
|
39
|
+
dtype=bool,
|
|
40
|
+
)
|
|
41
|
+
if verbose:
|
|
42
|
+
print("code: sort_match_screen (all candidates)")
|
|
43
|
+
print(f" Candidate matches: {np.count_nonzero(matched)}")
|
|
44
|
+
for axis in range(3):
|
|
45
|
+
rows, cols = np.where(matched)
|
|
46
|
+
if len(rows) == 0:
|
|
47
|
+
break
|
|
48
|
+
|
|
49
|
+
t_start_s = time.time()
|
|
50
|
+
pos1_axis = sort_positions_axis(pos_reps1, elements1, axis)
|
|
51
|
+
pos2_axis = sort_positions_axis(pos_reps2, elements2, axis)
|
|
52
|
+
if verbose:
|
|
53
|
+
print(f"code: sort_match_screen (axis {axis})")
|
|
54
|
+
print(f" Sorting: {round((time.time() - t_start_s) * 1000, 2)} ms")
|
|
55
|
+
|
|
56
|
+
t_start_m = time.time()
|
|
57
|
+
diff = pos1_axis[rows] - pos2_axis[cols]
|
|
58
|
+
diff -= axis_abc[axis] * np.round(diff / axis_abc[axis])
|
|
59
|
+
matched[rows, cols] = np.all(np.abs(diff) <= pos_tol, axis=1)
|
|
60
|
+
if verbose:
|
|
61
|
+
print(f" Matching: {round((time.time() - t_start_m) * 1000, 2)} ms")
|
|
62
|
+
print(f" Candidate matches: {np.count_nonzero(matched)}")
|
|
63
|
+
return matched
|
|
64
|
+
|
|
65
|
+
|
|
66
|
+
def greedy_match(
|
|
67
|
+
pos1: np.ndarray,
|
|
68
|
+
pos2: np.ndarray,
|
|
69
|
+
elements1: np.ndarray,
|
|
70
|
+
elements2: np.ndarray,
|
|
71
|
+
axis_abc: np.ndarray,
|
|
72
|
+
pos_tol: float,
|
|
73
|
+
verbose: bool = False,
|
|
74
|
+
):
|
|
75
|
+
def get_matching(diff, pos_tol):
|
|
76
|
+
pos_d = np.max(np.abs(diff), axis=2)
|
|
77
|
+
|
|
78
|
+
used1 = np.zeros(diff.shape[0], dtype=bool)
|
|
79
|
+
used2 = np.zeros(diff.shape[1], dtype=bool)
|
|
80
|
+
matching = np.full(len(targets1), -1, dtype=int)
|
|
81
|
+
while not np.all(used1):
|
|
82
|
+
pos_d_masked = pos_d.copy()
|
|
83
|
+
pos_d_masked[used1, :] = np.inf
|
|
84
|
+
pos_d_masked[:, used2] = np.inf
|
|
85
|
+
i, j = np.unravel_index(
|
|
86
|
+
np.argmin(pos_d_masked),
|
|
87
|
+
pos_d_masked.shape,
|
|
88
|
+
)
|
|
89
|
+
if pos_d_masked[i, j] >= pos_tol:
|
|
90
|
+
return None, False
|
|
91
|
+
matching[i] = j
|
|
92
|
+
used1[i] = True
|
|
93
|
+
used2[j] = True
|
|
94
|
+
return matching, True
|
|
95
|
+
|
|
96
|
+
inv_axis_abc = 1 / axis_abc
|
|
97
|
+
|
|
98
|
+
t_start_g = time.time()
|
|
99
|
+
for el in np.unique(elements1):
|
|
100
|
+
targets1 = np.where(elements1 == el)[0]
|
|
101
|
+
targets2 = np.where(elements2 == el)[0]
|
|
102
|
+
pos1_sub = pos1[targets1]
|
|
103
|
+
pos2_sub = pos2[targets2]
|
|
104
|
+
|
|
105
|
+
diff = pos1_sub[:, None, :] - pos2_sub[None, :, :]
|
|
106
|
+
col_ind = []
|
|
107
|
+
for _ in range(10):
|
|
108
|
+
diff -= axis_abc * np.round(diff * inv_axis_abc)
|
|
109
|
+
matching, judge = get_matching(diff, pos_tol=pos_tol * 2)
|
|
110
|
+
if not judge:
|
|
111
|
+
return False
|
|
112
|
+
|
|
113
|
+
row_ind = np.arange(len(targets1))
|
|
114
|
+
matched_diff = diff[row_ind, matching]
|
|
115
|
+
if np.max(matched_diff) < pos_tol:
|
|
116
|
+
break
|
|
117
|
+
if np.array_equal(matching, col_ind):
|
|
118
|
+
return False
|
|
119
|
+
|
|
120
|
+
col_ind = matching
|
|
121
|
+
translation_correction, max_displacement = optimize_translation(
|
|
122
|
+
matched_diff
|
|
123
|
+
)
|
|
124
|
+
diff = diff - translation_correction
|
|
125
|
+
|
|
126
|
+
if not judge:
|
|
127
|
+
break
|
|
128
|
+
if verbose:
|
|
129
|
+
print("code: greedy_match")
|
|
130
|
+
print(f" Matching: {round((time.time() - t_start_g) * 1000, 2)} ms")
|
|
131
|
+
|
|
132
|
+
return True
|
|
133
|
+
|
|
134
|
+
|
|
135
|
+
def bottleneck_assignment(
|
|
136
|
+
pos1: np.ndarray,
|
|
137
|
+
pos2: np.ndarray,
|
|
138
|
+
elements1: np.ndarray,
|
|
139
|
+
elements2: np.ndarray,
|
|
140
|
+
axis_abc: np.ndarray,
|
|
141
|
+
pos_tol: float,
|
|
142
|
+
verbose: bool = False,
|
|
143
|
+
):
|
|
144
|
+
def get_matching(pos_tol, pos_d):
|
|
145
|
+
rows, cols = np.where(pos_d <= pos_tol)
|
|
146
|
+
graph = csr_array(
|
|
147
|
+
(
|
|
148
|
+
np.ones(len(rows), dtype=np.int8),
|
|
149
|
+
(rows, cols),
|
|
150
|
+
),
|
|
151
|
+
shape=pos_d.shape,
|
|
152
|
+
)
|
|
153
|
+
matching = maximum_bipartite_matching(graph, perm_type="column")
|
|
154
|
+
return matching
|
|
155
|
+
|
|
156
|
+
inv_axis_abc = 1 / axis_abc
|
|
157
|
+
for el in np.unique(elements1):
|
|
158
|
+
targets1 = np.where(elements1 == el)[0]
|
|
159
|
+
targets2 = np.where(elements2 == el)[0]
|
|
160
|
+
pos1_sub = pos1[targets1]
|
|
161
|
+
pos2_sub = pos2[targets2]
|
|
162
|
+
|
|
163
|
+
t_start_d = time.time()
|
|
164
|
+
diff = pos1_sub[:, None, :] - pos2_sub[None, :, :]
|
|
165
|
+
diff -= axis_abc * np.round(diff * inv_axis_abc)
|
|
166
|
+
|
|
167
|
+
if verbose:
|
|
168
|
+
print("code: bottleneck_assignment")
|
|
169
|
+
print(
|
|
170
|
+
f" Difference Calc.: {round((time.time() - t_start_d) * 1000, 2)} ms"
|
|
171
|
+
)
|
|
172
|
+
|
|
173
|
+
col_ind = []
|
|
174
|
+
for _ in range(10):
|
|
175
|
+
pos_d = np.max(np.abs(diff), axis=2)
|
|
176
|
+
|
|
177
|
+
sorted_pos_d = np.sort(pos_d, axis=0)
|
|
178
|
+
pos_d_minmax = np.max(sorted_pos_d[0])
|
|
179
|
+
if pos_d_minmax > 2 * pos_tol:
|
|
180
|
+
return False
|
|
181
|
+
|
|
182
|
+
t_start_m = time.time()
|
|
183
|
+
_pos_tol = pos_tol
|
|
184
|
+
matching = get_matching(_pos_tol, pos_d)
|
|
185
|
+
if verbose:
|
|
186
|
+
print(f" Matching: {round((time.time() - t_start_m) * 1000, 2)} ms")
|
|
187
|
+
|
|
188
|
+
if np.all(matching >= 0):
|
|
189
|
+
return True
|
|
190
|
+
else:
|
|
191
|
+
t_start_m = time.time()
|
|
192
|
+
_pos_tol *= 2
|
|
193
|
+
matching = get_matching(_pos_tol, pos_d)
|
|
194
|
+
if verbose:
|
|
195
|
+
print(
|
|
196
|
+
f" Matching: {round((time.time() - t_start_m) * 1000, 2)} ms"
|
|
197
|
+
)
|
|
198
|
+
|
|
199
|
+
if not np.all(matching >= 0):
|
|
200
|
+
return False
|
|
201
|
+
if np.array_equal(matching, col_ind):
|
|
202
|
+
return False
|
|
203
|
+
|
|
204
|
+
row_ind = np.arange(len(matching))
|
|
205
|
+
col_ind = matching
|
|
206
|
+
matched_diff = diff[row_ind, col_ind]
|
|
207
|
+
translation_correction, max_displacement = optimize_translation(
|
|
208
|
+
matched_diff
|
|
209
|
+
)
|
|
210
|
+
diff = diff - translation_correction
|
|
211
|
+
diff -= axis_abc * np.round(diff * inv_axis_abc)
|
|
212
|
+
|
|
213
|
+
return True
|
|
214
|
+
|
|
215
|
+
|
|
216
|
+
def optimize_translation(diffs):
|
|
217
|
+
"""Find a translation minimizing the maximum displacement.
|
|
218
|
+
|
|
219
|
+
Args:
|
|
220
|
+
diffs: Displacement vectors of matched atom pairs, shape (N, 3).
|
|
221
|
+
|
|
222
|
+
Returns:
|
|
223
|
+
translation: Optimal translation correction, shape (3,).
|
|
224
|
+
max_displacement: Minimum achievable maximum displacement.
|
|
225
|
+
"""
|
|
226
|
+
|
|
227
|
+
diffs = np.asarray(diffs, dtype=float)
|
|
228
|
+
|
|
229
|
+
def objective(translation):
|
|
230
|
+
corrected = diffs - translation
|
|
231
|
+
return np.max(np.linalg.norm(corrected, axis=1))
|
|
232
|
+
|
|
233
|
+
initial_translation = np.mean(diffs, axis=0)
|
|
234
|
+
|
|
235
|
+
result = minimize(
|
|
236
|
+
objective,
|
|
237
|
+
initial_translation,
|
|
238
|
+
method="Nelder-Mead",
|
|
239
|
+
options={"xatol": 1e-10, "maxiter": 10000},
|
|
240
|
+
)
|
|
241
|
+
|
|
242
|
+
translation = result.x
|
|
243
|
+
max_displacement = objective(translation)
|
|
244
|
+
|
|
245
|
+
return translation, max_displacement
|