rsspolymlp 0.4.3__tar.gz → 0.4.5__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.3/src/rsspolymlp.egg-info → rsspolymlp-0.4.5}/PKG-INFO +4 -7
- {rsspolymlp-0.4.3 → rsspolymlp-0.4.5}/README.md +2 -6
- {rsspolymlp-0.4.3 → rsspolymlp-0.4.5}/pyproject.toml +2 -1
- {rsspolymlp-0.4.3 → rsspolymlp-0.4.5}/src/rsspolymlp/analysis/rss_summarize.py +85 -35
- rsspolymlp-0.4.5/src/rsspolymlp/analysis/struct_matcher/assignment_algo.py +245 -0
- {rsspolymlp-0.4.3 → rsspolymlp-0.4.5}/src/rsspolymlp/analysis/struct_matcher/gen_struct_rep.py +95 -124
- {rsspolymlp-0.4.3 → rsspolymlp-0.4.5}/src/rsspolymlp/analysis/struct_matcher/identify_uniqstr.py +15 -12
- rsspolymlp-0.4.5/src/rsspolymlp/analysis/struct_matcher/primitive_transform.py +348 -0
- rsspolymlp-0.4.5/src/rsspolymlp/analysis/struct_matcher/redrep_lattice.py +143 -0
- {rsspolymlp-0.4.3 → rsspolymlp-0.4.5}/src/rsspolymlp/analysis/struct_matcher/redrep_position.py +55 -93
- {rsspolymlp-0.4.3 → rsspolymlp-0.4.5}/src/rsspolymlp/analysis/struct_matcher/struct_match.py +13 -10
- rsspolymlp-0.4.3/src/rsspolymlp/common/convert_dict.py → rsspolymlp-0.4.5/src/rsspolymlp/analysis/utils/convert_data_format.py +1 -1
- {rsspolymlp-0.4.3 → rsspolymlp-0.4.5}/src/rsspolymlp/api/cli_rsspolymlp.py +9 -1
- {rsspolymlp-0.4.3 → rsspolymlp-0.4.5}/src/rsspolymlp/api/cli_rsspolymlp_utils.py +2 -9
- {rsspolymlp-0.4.3 → rsspolymlp-0.4.5}/src/rsspolymlp/api/rsspolymlp.py +4 -1
- {rsspolymlp-0.4.3 → rsspolymlp-0.4.5}/src/rsspolymlp/api/rsspolymlp_utils.py +31 -24
- {rsspolymlp-0.4.3 → rsspolymlp-0.4.5}/src/rsspolymlp/common/atomic_energy.py +2 -0
- rsspolymlp-0.4.5/src/rsspolymlp/common/interface_pypolymlp.py +50 -0
- rsspolymlp-0.4.5/src/rsspolymlp/common/interface_spglib.py +115 -0
- {rsspolymlp-0.4.3 → rsspolymlp-0.4.5}/src/rsspolymlp/common/interface_vasp.py +5 -1
- {rsspolymlp-0.4.3 → rsspolymlp-0.4.5}/src/rsspolymlp/common/property.py +2 -13
- {rsspolymlp-0.4.3 → rsspolymlp-0.4.5}/src/rsspolymlp/mlp_dev/dataset/split_dataset.py +4 -3
- {rsspolymlp-0.4.3 → rsspolymlp-0.4.5}/src/rsspolymlp/rss/eliminate_duplicates.py +6 -5
- {rsspolymlp-0.4.3 → rsspolymlp-0.4.5}/src/rsspolymlp/rss/optimization_mlp.py +9 -4
- {rsspolymlp-0.4.3 → rsspolymlp-0.4.5}/src/rsspolymlp/utils/matplot_util/make_plot.py +14 -3
- {rsspolymlp-0.4.3 → rsspolymlp-0.4.5/src/rsspolymlp.egg-info}/PKG-INFO +4 -7
- {rsspolymlp-0.4.3 → rsspolymlp-0.4.5}/src/rsspolymlp.egg-info/SOURCES.txt +4 -3
- {rsspolymlp-0.4.3 → rsspolymlp-0.4.5}/src/rsspolymlp.egg-info/requires.txt +1 -0
- rsspolymlp-0.4.3/src/rsspolymlp/analysis/struct_matcher/assignment_algo.py +0 -181
- rsspolymlp-0.4.3/src/rsspolymlp/analysis/struct_matcher/redrep_lattice.py +0 -144
- rsspolymlp-0.4.3/src/rsspolymlp/analysis/struct_matcher/test/time_measure.py +0 -0
- rsspolymlp-0.4.3/src/rsspolymlp/utils/spglib_utils.py +0 -232
- {rsspolymlp-0.4.3 → rsspolymlp-0.4.5}/LICENSE +0 -0
- {rsspolymlp-0.4.3 → rsspolymlp-0.4.5}/setup.cfg +0 -0
- {rsspolymlp-0.4.3 → rsspolymlp-0.4.5}/src/rsspolymlp/__init__.py +0 -0
- {rsspolymlp-0.4.3 → rsspolymlp-0.4.5}/src/rsspolymlp/analysis/__init__.py +0 -0
- {rsspolymlp-0.4.3 → rsspolymlp-0.4.5}/src/rsspolymlp/analysis/eos.py +0 -0
- {rsspolymlp-0.4.3 → rsspolymlp-0.4.5}/src/rsspolymlp/analysis/ghost_minima.py +0 -0
- {rsspolymlp-0.4.3 → rsspolymlp-0.4.5}/src/rsspolymlp/analysis/phase_analysis.py +0 -0
- {rsspolymlp-0.4.3 → rsspolymlp-0.4.5}/src/rsspolymlp/analysis/struct_matcher/__init__.py +0 -0
- {rsspolymlp-0.4.3 → rsspolymlp-0.4.5}/src/rsspolymlp/analysis/struct_matcher/chiral_spg.py +0 -0
- {rsspolymlp-0.4.3 → rsspolymlp-0.4.5}/src/rsspolymlp/analysis/struct_matcher/test/gen_lattice.py +0 -0
- {rsspolymlp-0.4.3 → rsspolymlp-0.4.5}/src/rsspolymlp/api/__init__.py +0 -0
- {rsspolymlp-0.4.3 → rsspolymlp-0.4.5}/src/rsspolymlp/api/cli_rsspolymlp_devkit.py +0 -0
- {rsspolymlp-0.4.3 → rsspolymlp-0.4.5}/src/rsspolymlp/api/cli_rsspolymlp_plot.py +0 -0
- {rsspolymlp-0.4.3 → rsspolymlp-0.4.5}/src/rsspolymlp/api/rsspolymlp_devkit.py +0 -0
- {rsspolymlp-0.4.3 → rsspolymlp-0.4.5}/src/rsspolymlp/api/rsspolymlp_plot.py +0 -0
- {rsspolymlp-0.4.3 → rsspolymlp-0.4.5}/src/rsspolymlp/common/__init__.py +0 -0
- {rsspolymlp-0.4.3 → rsspolymlp-0.4.5}/src/rsspolymlp/common/composition.py +0 -0
- {rsspolymlp-0.4.3 → rsspolymlp-0.4.5}/src/rsspolymlp/mlp_dev/dataset/compress_vasprun.py +0 -0
- {rsspolymlp-0.4.3 → rsspolymlp-0.4.5}/src/rsspolymlp/mlp_dev/dataset/gen_mlp_dataset.py +0 -0
- {rsspolymlp-0.4.3 → rsspolymlp-0.4.5}/src/rsspolymlp/mlp_dev/estimate_cost.py +0 -0
- {rsspolymlp-0.4.3 → rsspolymlp-0.4.5}/src/rsspolymlp/mlp_dev/model_selection/binary/gen_single_model.py +0 -0
- {rsspolymlp-0.4.3 → rsspolymlp-0.4.5}/src/rsspolymlp/mlp_dev/model_selection/elemental/gen_hybrid_model.py +0 -0
- {rsspolymlp-0.4.3 → rsspolymlp-0.4.5}/src/rsspolymlp/mlp_dev/model_selection/elemental/gen_single_model.py +0 -0
- {rsspolymlp-0.4.3 → rsspolymlp-0.4.5}/src/rsspolymlp/mlp_dev/model_selection/n_feature.py +0 -0
- {rsspolymlp-0.4.3 → rsspolymlp-0.4.5}/src/rsspolymlp/mlp_dev/model_selection/pypolymlp_gridsearch.py +0 -0
- {rsspolymlp-0.4.3 → rsspolymlp-0.4.5}/src/rsspolymlp/mlp_dev/model_selection/reduce_grid.py +0 -0
- {rsspolymlp-0.4.3 → rsspolymlp-0.4.5}/src/rsspolymlp/mlp_dev/pareto_opt_mlp.py +0 -0
- {rsspolymlp-0.4.3 → rsspolymlp-0.4.5}/src/rsspolymlp/mlp_dev/polymlp_dev.py +0 -0
- {rsspolymlp-0.4.3 → rsspolymlp-0.4.5}/src/rsspolymlp/rss/__init__.py +0 -0
- {rsspolymlp-0.4.3 → rsspolymlp-0.4.5}/src/rsspolymlp/rss/load_logfile.py +0 -0
- {rsspolymlp-0.4.3 → rsspolymlp-0.4.5}/src/rsspolymlp/rss/random_struct.py +0 -0
- {rsspolymlp-0.4.3 → rsspolymlp-0.4.5}/src/rsspolymlp/utils/__init__.py +0 -0
- {rsspolymlp-0.4.3 → rsspolymlp-0.4.5}/src/rsspolymlp/utils/lammps_utils.py +0 -0
- {rsspolymlp-0.4.3 → rsspolymlp-0.4.5}/src/rsspolymlp/utils/matplot_util/__init__.py +0 -0
- {rsspolymlp-0.4.3 → rsspolymlp-0.4.5}/src/rsspolymlp/utils/matplot_util/custom_plt.py +0 -0
- {rsspolymlp-0.4.3 → rsspolymlp-0.4.5}/src/rsspolymlp/utils/matplot_util/examples/__init__.py +0 -0
- {rsspolymlp-0.4.3 → rsspolymlp-0.4.5}/src/rsspolymlp/utils/matplot_util/examples/example.py +0 -0
- {rsspolymlp-0.4.3 → rsspolymlp-0.4.5}/src/rsspolymlp/utils/matplot_util/examples/template.py +0 -0
- {rsspolymlp-0.4.3 → rsspolymlp-0.4.5}/src/rsspolymlp/utils/opt_sscha/opt_geometry_sscha.py +0 -0
- {rsspolymlp-0.4.3 → rsspolymlp-0.4.5}/src/rsspolymlp/utils/opt_sscha/opt_position_sscha.py +0 -0
- {rsspolymlp-0.4.3 → rsspolymlp-0.4.5}/src/rsspolymlp/utils/opt_sscha/run_opt_sscha.py +0 -0
- {rsspolymlp-0.4.3 → rsspolymlp-0.4.5}/src/rsspolymlp/utils/opt_sscha/sscha_property.py +0 -0
- {rsspolymlp-0.4.3 → rsspolymlp-0.4.5}/src/rsspolymlp/utils/pymatgen_utils.py +0 -0
- {rsspolymlp-0.4.3 → rsspolymlp-0.4.5}/src/rsspolymlp/utils/vasp_util/__init__.py +0 -0
- {rsspolymlp-0.4.3 → rsspolymlp-0.4.5}/src/rsspolymlp/utils/vasp_util/api.py +0 -0
- {rsspolymlp-0.4.3 → rsspolymlp-0.4.5}/src/rsspolymlp/utils/vasp_util/gen_incar.py +0 -0
- {rsspolymlp-0.4.3 → rsspolymlp-0.4.5}/src/rsspolymlp/utils/vasp_util/gen_script.py +0 -0
- {rsspolymlp-0.4.3 → rsspolymlp-0.4.5}/src/rsspolymlp/utils/vasp_util/write_poscar.py +0 -0
- {rsspolymlp-0.4.3 → rsspolymlp-0.4.5}/src/rsspolymlp.egg-info/dependency_links.txt +0 -0
- {rsspolymlp-0.4.3 → rsspolymlp-0.4.5}/src/rsspolymlp.egg-info/entry_points.txt +0 -0
- {rsspolymlp-0.4.3 → rsspolymlp-0.4.5}/src/rsspolymlp.egg-info/top_level.txt +0 -0
- {rsspolymlp-0.4.3 → rsspolymlp-0.4.5}/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.5
|
|
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
|
|
|
@@ -79,11 +81,6 @@ pip install rsspolymlp
|
|
|
79
81
|
- Global RSS with polynomial MLPs
|
|
80
82
|
- Unique structure identification and RSS result summarization
|
|
81
83
|
- Phase stability analysis
|
|
82
|
-
- [Development kit for polynomial MLPs](docs/rsspolymlp_dev.md)
|
|
83
|
-
- MLP dataset generation
|
|
84
|
-
- DFT dataset division
|
|
85
|
-
- Polynomial MLP development
|
|
86
|
-
- Pareto-optimal MLP selection
|
|
87
84
|
- Python API
|
|
88
85
|
- [RSS workflow](docs/api_rsspolymlp.md)
|
|
89
86
|
- [VASP calculation utilities](src/rsspolymlp/utils/vasp_util/readme.md)
|
|
@@ -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
|
|
|
@@ -48,11 +49,6 @@ pip install rsspolymlp
|
|
|
48
49
|
- Global RSS with polynomial MLPs
|
|
49
50
|
- Unique structure identification and RSS result summarization
|
|
50
51
|
- Phase stability analysis
|
|
51
|
-
- [Development kit for polynomial MLPs](docs/rsspolymlp_dev.md)
|
|
52
|
-
- MLP dataset generation
|
|
53
|
-
- DFT dataset division
|
|
54
|
-
- Polynomial MLP development
|
|
55
|
-
- Pareto-optimal MLP selection
|
|
56
52
|
- Python API
|
|
57
53
|
- [RSS workflow](docs/api_rsspolymlp.md)
|
|
58
54
|
- [VASP calculation utilities](src/rsspolymlp/utils/vasp_util/readme.md)
|
|
@@ -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.5"
|
|
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",
|
|
@@ -6,24 +6,24 @@ import xml.etree.ElementTree as ET
|
|
|
6
6
|
from collections import defaultdict
|
|
7
7
|
from pathlib import Path
|
|
8
8
|
from time import time
|
|
9
|
-
from typing import Optional
|
|
9
|
+
from typing import Literal, Optional
|
|
10
10
|
|
|
11
11
|
import numpy as np
|
|
12
|
-
from pypolymlp.utils.vasp_utils import write_poscar_file
|
|
13
12
|
|
|
13
|
+
from pypolymlp.utils.vasp_utils import write_poscar_file
|
|
14
14
|
from rsspolymlp.analysis.ghost_minima import detect_ghost_minima
|
|
15
15
|
from rsspolymlp.analysis.struct_matcher.gen_struct_rep import (
|
|
16
16
|
StructRepGenerator,
|
|
17
17
|
StructReps,
|
|
18
18
|
)
|
|
19
19
|
from rsspolymlp.analysis.struct_matcher.identify_uniqstr import (
|
|
20
|
+
UniqueStructIdentifier,
|
|
20
21
|
identify_unique_structure,
|
|
21
22
|
)
|
|
22
|
-
from rsspolymlp.
|
|
23
|
-
from rsspolymlp.common.convert_dict import (
|
|
23
|
+
from rsspolymlp.analysis.utils.convert_data_format import (
|
|
24
24
|
polymlp_struct_from_dict,
|
|
25
|
-
polymlp_struct_to_dict,
|
|
26
25
|
)
|
|
26
|
+
from rsspolymlp.common.composition import compute_composition
|
|
27
27
|
from rsspolymlp.common.interface_vasp import Vasprun, parse_properties_from_vasprun
|
|
28
28
|
from rsspolymlp.common.property import PropUtil
|
|
29
29
|
|
|
@@ -37,7 +37,8 @@ class RSSResultSummarizer:
|
|
|
37
37
|
element_order: list = None,
|
|
38
38
|
num_process: int = -1,
|
|
39
39
|
backend: str = "loky",
|
|
40
|
-
|
|
40
|
+
assign_method: Literal["redrep", "greedy", "HK", "pymatgen"] = "redrep",
|
|
41
|
+
primitive_symprecs: list[float] = [1e-2],
|
|
41
42
|
output_poscar: bool = False,
|
|
42
43
|
thresholds: list[float] = None,
|
|
43
44
|
parse_vasp: bool = False,
|
|
@@ -50,6 +51,7 @@ class RSSResultSummarizer:
|
|
|
50
51
|
self.element_order = element_order
|
|
51
52
|
self.num_process = num_process
|
|
52
53
|
self.backend = backend
|
|
54
|
+
self.assign_method = assign_method
|
|
53
55
|
self.primitive_symprecs = primitive_symprecs
|
|
54
56
|
self.output_poscar = output_poscar
|
|
55
57
|
self.thresholds = thresholds
|
|
@@ -89,6 +91,11 @@ class RSSResultSummarizer:
|
|
|
89
91
|
axis_tol = 0.1
|
|
90
92
|
pos_tol = 0.1
|
|
91
93
|
|
|
94
|
+
self.analyzer = UniqueStructIdentifier(
|
|
95
|
+
axis_tol=axis_tol,
|
|
96
|
+
pos_tol=pos_tol,
|
|
97
|
+
assign_method=self.assign_method,
|
|
98
|
+
)
|
|
92
99
|
for comp_tag, res_paths in json_paths_c.items():
|
|
93
100
|
print(f"Composition {comp_tag}: summarizing...")
|
|
94
101
|
time_start = time()
|
|
@@ -116,6 +123,9 @@ class RSSResultSummarizer:
|
|
|
116
123
|
rss_results_c[comp_tag][res_path],
|
|
117
124
|
axis_tol=axis_tol,
|
|
118
125
|
pos_tol=pos_tol,
|
|
126
|
+
assign_method=self.assign_method,
|
|
127
|
+
primitive_symprecs=self.primitive_symprecs,
|
|
128
|
+
num_process=self.num_process,
|
|
119
129
|
pre_analyzer=self.analyzer,
|
|
120
130
|
)
|
|
121
131
|
|
|
@@ -124,11 +134,11 @@ class RSSResultSummarizer:
|
|
|
124
134
|
unique_structs = self.analyzer.unique_str
|
|
125
135
|
unique_str_prop = self.analyzer.unique_str_prop
|
|
126
136
|
enthalpies = np.array([s["energy"] for s in unique_str_prop])
|
|
127
|
-
distances = np.array([s["least_distance"] for s in unique_str_prop])
|
|
128
137
|
sort_idx = np.argsort(enthalpies)
|
|
129
138
|
|
|
130
139
|
if not self.parse_vasp:
|
|
131
140
|
os.makedirs("ghost_minima", exist_ok=True)
|
|
141
|
+
distances = np.array([s["least_distance"] for s in unique_str_prop])
|
|
132
142
|
is_ghost_minima, ghost_minima_info = detect_ghost_minima(
|
|
133
143
|
enthalpies[sort_idx], distances[sort_idx]
|
|
134
144
|
)
|
|
@@ -209,6 +219,9 @@ class RSSResultSummarizer:
|
|
|
209
219
|
keep_unique=True,
|
|
210
220
|
axis_tol=axis_tol,
|
|
211
221
|
pos_tol=pos_tol,
|
|
222
|
+
assign_method=self.assign_method,
|
|
223
|
+
primitive_symprecs=self.primitive_symprecs,
|
|
224
|
+
num_process=self.num_process,
|
|
212
225
|
pre_analyzer=self.analyzer,
|
|
213
226
|
)
|
|
214
227
|
time_finish = time() - time_start
|
|
@@ -220,7 +233,7 @@ class RSSResultSummarizer:
|
|
|
220
233
|
sort_idx = np.argsort(enthalpies)
|
|
221
234
|
sort_idx = sorted(
|
|
222
235
|
sort_idx,
|
|
223
|
-
key=lambda i: len(
|
|
236
|
+
key=lambda i: len(unique_structs[i]),
|
|
224
237
|
reverse=True,
|
|
225
238
|
)
|
|
226
239
|
unique_str_sorted = [unique_structs[i] for i in sort_idx]
|
|
@@ -254,18 +267,26 @@ class RSSResultSummarizer:
|
|
|
254
267
|
|
|
255
268
|
processed_paths = []
|
|
256
269
|
for r in rss_results:
|
|
257
|
-
|
|
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"])
|
|
258
279
|
processed_paths.extend(r["dupstr_paths"])
|
|
259
280
|
r["dupstr_paths"] = set(r["dupstr_paths"])
|
|
260
281
|
|
|
261
282
|
print(" - Converting reduced crystal structure representation...")
|
|
262
283
|
generator = StructRepGenerator(
|
|
263
|
-
num_process=self.num_process,
|
|
264
|
-
backend=self.backend,
|
|
265
284
|
primitive_symprecs=self.primitive_symprecs,
|
|
266
285
|
)
|
|
267
286
|
struct_reps_list = generator.generate_struct_reps_parallel(
|
|
268
287
|
rss_results,
|
|
288
|
+
num_process=self.num_process,
|
|
289
|
+
backend=self.backend,
|
|
269
290
|
)
|
|
270
291
|
if self.update_parent:
|
|
271
292
|
print(" - Eliminating duplicate structures...")
|
|
@@ -370,7 +391,15 @@ class RSSResultSummarizer:
|
|
|
370
391
|
for r in loaded_dict["rss_results"]:
|
|
371
392
|
r["struct_path"] = resolve_path(base, r["struct_path"])
|
|
372
393
|
r["dupstr_paths"] = {resolve_path(base, p) for p in r["dupstr_paths"]}
|
|
373
|
-
|
|
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"])
|
|
374
403
|
r["struct_tag"] = None
|
|
375
404
|
r["pressure"] = pressure
|
|
376
405
|
|
|
@@ -422,7 +451,9 @@ class RSSResultSummarizer:
|
|
|
422
451
|
res_dict["struct_path"] = os.path.relpath(
|
|
423
452
|
path_name + "/vasprun.xml", os.getcwd()
|
|
424
453
|
)
|
|
425
|
-
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
|
|
426
457
|
res_dict["energy"] = energy_dft
|
|
427
458
|
res_dict["spg_list"] = spg_list
|
|
428
459
|
res_dict["dupstr_paths"] = {res_dict["struct_path"]}
|
|
@@ -468,14 +499,18 @@ def dump_json_rss_results(
|
|
|
468
499
|
|
|
469
500
|
rss_results = []
|
|
470
501
|
for idx, _str in enumerate(struct_reps_list):
|
|
471
|
-
|
|
472
|
-
|
|
502
|
+
axis = _str.original_axis
|
|
503
|
+
positions = _str.original_positions
|
|
504
|
+
elements = _str.original_elements
|
|
505
|
+
objprop = PropUtil(axis, positions)
|
|
473
506
|
rss_results.append(
|
|
474
507
|
{
|
|
475
508
|
"struct_path": _str.struct_path,
|
|
476
509
|
"poscar_path": _str.struct_path,
|
|
477
|
-
"structure": polymlp_struct_to_dict(polymlp_st),
|
|
478
510
|
"energy": enthalpy_lists[idx],
|
|
511
|
+
"axis": axis.tolist(),
|
|
512
|
+
"positions": positions.tolist(),
|
|
513
|
+
"elements": elements.tolist(),
|
|
479
514
|
"axis_abc": objprop.abc,
|
|
480
515
|
"least_distance": objprop.least_distance,
|
|
481
516
|
"volume": objprop.volume,
|
|
@@ -486,7 +521,7 @@ def dump_json_rss_results(
|
|
|
486
521
|
}
|
|
487
522
|
)
|
|
488
523
|
if len(struct_reps_list) > 0:
|
|
489
|
-
comp_res = compute_composition(
|
|
524
|
+
comp_res = compute_composition(elements)
|
|
490
525
|
rss_result_all = {
|
|
491
526
|
"elements": comp_res.unique_elements.tolist(),
|
|
492
527
|
"comp_ratio": comp_res.comp_ratio,
|
|
@@ -509,6 +544,7 @@ def log_unique_structures(
|
|
|
509
544
|
enthalpy_lists: Optional[list[float]] = None,
|
|
510
545
|
is_ghost_minima=None,
|
|
511
546
|
unique_struct_iters=None,
|
|
547
|
+
print_duplicates: bool = False,
|
|
512
548
|
):
|
|
513
549
|
if is_ghost_minima is None:
|
|
514
550
|
is_ghost_minima = np.full_like(struct_reps_list, False, dtype=bool)
|
|
@@ -545,10 +581,12 @@ def log_unique_structures(
|
|
|
545
581
|
e = enthalpy_lists[idx]
|
|
546
582
|
else:
|
|
547
583
|
e = None
|
|
548
|
-
polymlp_st = _str.original_polymlp_st
|
|
549
|
-
objprop = PropUtil(polymlp_st.axis.T, polymlp_st.positions.T)
|
|
550
|
-
dupstr_paths = list(_str.dupstr_paths)
|
|
551
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)
|
|
552
590
|
print(f" - struct_No: {_str.struct_tag}", file=f)
|
|
553
591
|
print(f" struct_path: {_str.struct_path}", file=f)
|
|
554
592
|
if energy_min is not None:
|
|
@@ -557,21 +595,22 @@ def log_unique_structures(
|
|
|
557
595
|
print(f" enthalpy: {e}", file=f)
|
|
558
596
|
print(f" axis: {objprop.abc}", file=f)
|
|
559
597
|
print(
|
|
560
|
-
f" positions: {
|
|
598
|
+
f" positions: {positions.tolist()}",
|
|
561
599
|
file=f,
|
|
562
600
|
)
|
|
563
|
-
print(f" elements: {
|
|
601
|
+
print(f" elements: {elements.tolist()}", file=f)
|
|
564
602
|
print(f" space_group: {_str.spg_list}", file=f)
|
|
565
603
|
|
|
566
604
|
info = [
|
|
567
|
-
f"{len(
|
|
605
|
+
f"{len(elements)} atom",
|
|
568
606
|
f"distance {round(objprop.least_distance, 3)} (Ang.)",
|
|
569
607
|
f"volume {round(objprop.volume, 2)} (A^3/atom)",
|
|
570
608
|
]
|
|
571
609
|
if unique_struct_iters is not None:
|
|
572
610
|
info.append(f"iteration {unique_struct_iters[idx]}")
|
|
573
611
|
print(f" other_info: {' / '.join(info)}", file=f)
|
|
574
|
-
|
|
612
|
+
if print_duplicates:
|
|
613
|
+
print(" duplicate_paths:", _str.dupstr_paths, file=f)
|
|
575
614
|
if is_ghost_minima[idx]:
|
|
576
615
|
print(" ghost_minima_flag: true", file=f)
|
|
577
616
|
|
|
@@ -586,6 +625,14 @@ def log_all_unique_structures(
|
|
|
586
625
|
with open(file_name, "a") as f:
|
|
587
626
|
print("unique_structures:", file=f)
|
|
588
627
|
for idx1, _str in enumerate(unique_structs):
|
|
628
|
+
if unique_str_prop is not None:
|
|
629
|
+
sorted_data = sorted(
|
|
630
|
+
zip(unique_structs[idx1], unique_str_prop[idx1]),
|
|
631
|
+
key=lambda x: x[1]["energy"],
|
|
632
|
+
)
|
|
633
|
+
unique_structs[idx1], unique_str_prop[idx1] = map(
|
|
634
|
+
list, zip(*sorted_data)
|
|
635
|
+
)
|
|
589
636
|
print(f" - struct_No: {idx1 + 1}", file=f)
|
|
590
637
|
print(" structures:", file=f)
|
|
591
638
|
for idx2, _str in enumerate(unique_structs[idx1]):
|
|
@@ -593,22 +640,26 @@ def log_all_unique_structures(
|
|
|
593
640
|
e = unique_str_prop[idx1][idx2]["energy"]
|
|
594
641
|
else:
|
|
595
642
|
e = None
|
|
596
|
-
|
|
597
|
-
|
|
643
|
+
axis = _str.original_axis
|
|
644
|
+
positions = _str.original_positions
|
|
645
|
+
elements = _str.original_elements
|
|
646
|
+
objprop = PropUtil(axis, positions)
|
|
598
647
|
print(f" - sub_struct_No: '{idx1 + 1}_{idx2 + 1}'", file=f)
|
|
599
648
|
print(f" struct_path: {_str.struct_path}", file=f)
|
|
600
|
-
print(
|
|
649
|
+
print(
|
|
650
|
+
f" pressure: {unique_str_prop[idx1][idx2]['pressure']}", file=f
|
|
651
|
+
)
|
|
601
652
|
print(f" enthalpy: {e}", file=f)
|
|
602
653
|
print(f" axis: {objprop.abc}", file=f)
|
|
603
654
|
print(
|
|
604
|
-
f" positions: {
|
|
655
|
+
f" positions: {positions.tolist()}",
|
|
605
656
|
file=f,
|
|
606
657
|
)
|
|
607
|
-
print(f" elements: {
|
|
658
|
+
print(f" elements: {elements}", file=f)
|
|
608
659
|
print(f" space_group: {_str.spg_list}", file=f)
|
|
609
660
|
|
|
610
661
|
info = [
|
|
611
|
-
f"{len(
|
|
662
|
+
f"{len(elements)} atom",
|
|
612
663
|
f"distance {round(objprop.least_distance, 3)} (Ang.)",
|
|
613
664
|
f"volume {round(objprop.volume, 2)} (A^3/atom)",
|
|
614
665
|
]
|
|
@@ -616,8 +667,9 @@ def log_all_unique_structures(
|
|
|
616
667
|
|
|
617
668
|
_res = {}
|
|
618
669
|
_res["struct_path"] = _str.struct_path
|
|
619
|
-
|
|
620
|
-
_res["
|
|
670
|
+
_res["axis"] = axis
|
|
671
|
+
_res["positions"] = positions
|
|
672
|
+
_res["elements"] = elements
|
|
621
673
|
_res["energy"] = e
|
|
622
674
|
_res["pressure"] = None
|
|
623
675
|
_res["spg_list"] = _str.spg_list
|
|
@@ -627,13 +679,11 @@ def log_all_unique_structures(
|
|
|
627
679
|
if unique_other_prop is not None:
|
|
628
680
|
print(" properties:", unique_other_prop[idx1], file=f)
|
|
629
681
|
|
|
630
|
-
comp_res = compute_composition(
|
|
631
|
-
|
|
682
|
+
comp_res = compute_composition(elements)
|
|
632
683
|
rss_result_all = {
|
|
633
684
|
"elements": comp_res.unique_elements.tolist(),
|
|
634
685
|
"comp_ratio": comp_res.comp_ratio,
|
|
635
686
|
"pressure": None,
|
|
636
687
|
"rss_results": rss_results,
|
|
637
688
|
}
|
|
638
|
-
|
|
639
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
|