@@ -48,22 +48,27 @@ class AflowPrototypeMatcher:
48
48
https://doi.org/10.1016/j.commatsci.2017.01.017
49
49
"""
50
50
51
- def __init__ (self , initial_ltol = 0.2 , initial_stol = 0.3 , initial_angle_tol = 5 ):
51
+ def __init__ (
52
+ self ,
53
+ initial_ltol : float = 0.2 ,
54
+ initial_stol : float = 0.3 ,
55
+ initial_angle_tol : float = 5 ,
56
+ ) -> None :
52
57
"""
53
58
Tolerances as defined in StructureMatcher. Tolerances will be
54
59
gradually decreased until only a single match is found (if possible).
55
60
56
61
Args:
57
- initial_ltol: fractional length tolerance
58
- initial_stol: site tolerance
59
- initial_angle_tol: angle tolerance
62
+ initial_ltol (float) : fractional length tolerance.
63
+ initial_stol (float) : site tolerance.
64
+ initial_angle_tol (float) : angle tolerance.
60
65
"""
61
66
self .initial_ltol = initial_ltol
62
67
self .initial_stol = initial_stol
63
68
self .initial_angle_tol = initial_angle_tol
64
69
65
70
# Preprocess AFLOW prototypes
66
- self ._aflow_prototype_library = []
71
+ self ._aflow_prototype_library : list [ tuple [ Structure , dict ]] = []
67
72
for dct in AFLOW_PROTOTYPE_LIBRARY :
68
73
structure : Structure = dct ["snl" ].structure
69
74
reduced_structure = self ._preprocess_structure (structure )
@@ -73,7 +78,11 @@ def __init__(self, initial_ltol=0.2, initial_stol=0.3, initial_angle_tol=5):
73
78
def _preprocess_structure (structure : Structure ) -> Structure :
74
79
return structure .get_reduced_structure (reduction_algo = "niggli" ).get_primitive_structure ()
75
80
76
- def _match_prototype (self , structure_matcher : StructureMatcher , reduced_structure : Structure ):
81
+ def _match_prototype (
82
+ self ,
83
+ structure_matcher : StructureMatcher ,
84
+ reduced_structure : Structure ,
85
+ ) -> list [dict ]:
77
86
tags = []
78
87
for aflow_reduced_structure , dct in self ._aflow_prototype_library :
79
88
# Since both structures are already reduced, we can skip the structure reduction step
@@ -84,7 +93,7 @@ def _match_prototype(self, structure_matcher: StructureMatcher, reduced_structur
84
93
tags .append (dct )
85
94
return tags
86
95
87
- def _match_single_prototype (self , structure : Structure ):
96
+ def _match_single_prototype (self , structure : Structure ) -> list [ dict ] :
88
97
sm = StructureMatcher (
89
98
ltol = self .initial_ltol ,
90
99
stol = self .initial_stol ,
@@ -102,23 +111,23 @@ def _match_single_prototype(self, structure: Structure):
102
111
break
103
112
return tags
104
113
105
- def get_prototypes (self , structure : Structure ) -> list | None :
114
+ def get_prototypes (self , structure : Structure ) -> list [ dict ] | None :
106
115
"""Get prototype(s) structures for a given input structure. If you use this method in
107
116
your work, please cite the appropriate AFLOW publication:
108
117
109
- Mehl, M. J., Hicks, D., Toher, C., Levy, O., Hanson, R. M., Hart, G., & Curtarolo,
110
- S. (2017). The AFLOW library of crystallographic prototypes: part 1. Computational
111
- Materials Science, 136, S1-S828. https://doi.org/10.1016/j.commatsci.2017.01.017
118
+ Mehl, M. J., Hicks, D., Toher, C., Levy, O., Hanson, R. M., Hart, G., & Curtarolo,
119
+ S. (2017). The AFLOW library of crystallographic prototypes: part 1. Computational
120
+ Materials Science, 136, S1-S828. https://doi.org/10.1016/j.commatsci.2017.01.017
112
121
113
122
Args:
114
- structure: structure to match
123
+ structure (Structure) : structure to match
115
124
116
125
Returns:
117
- list | None: A list of dicts with keys ' snl' for the matched prototype and
118
- ' tags' , a dict of tags (' mineral', ' strukturbericht' and ' aflow' ) of that
126
+ list[dict] | None: A list of dicts with keys " snl" for the matched prototype and
127
+ " tags" , a dict of tags (" mineral", " strukturbericht" and " aflow" ) of that
119
128
prototype. This should be a list containing just a single entry, but it is
120
129
possible a material can match multiple prototypes.
121
130
"""
122
- tags = self ._match_single_prototype (structure )
131
+ tags : list [ dict ] = self ._match_single_prototype (structure )
123
132
124
133
return tags or None
0 commit comments