|
21 | 21 | )
|
22 | 22 |
|
23 | 23 | safe_dist_dict = {
|
24 |
| - "H": 1.2255, |
| 24 | + "H": 0.612, |
25 | 25 | "He": 0.936,
|
26 | 26 | "Li": 1.8,
|
27 | 27 | "Be": 1.56,
|
@@ -169,16 +169,48 @@ def check(
|
169 | 169 | pbc=(not frame.nopbc),
|
170 | 170 | )
|
171 | 171 |
|
172 |
| - P = [[2, 0, 0], [0, 2, 0], [0, 0, 2]] |
173 |
| - extended_structure = make_supercell(structure, P) |
174 |
| - |
175 |
| - coords = extended_structure.positions |
176 |
| - symbols = extended_structure.get_chemical_symbols() |
| 172 | + coords = structure.positions |
| 173 | + symbols = structure.get_chemical_symbols() |
| 174 | + cell, _ = structure.get_cell().standard_form() |
| 175 | + cell = cell.array |
| 176 | + |
| 177 | + a1 = cell[0] |
| 178 | + a2 = cell[1] |
| 179 | + a3 = cell[2] |
| 180 | + |
| 181 | + all_combinations = { |
| 182 | + "a1": np.linalg.norm(a1), |
| 183 | + "a2": np.linalg.norm(a2), |
| 184 | + "a3": np.linalg.norm(a3), |
| 185 | + "a1+a2": np.linalg.norm(a1 + a2), |
| 186 | + "a1+a3": np.linalg.norm(a1 + a3), |
| 187 | + "a2+a3": np.linalg.norm(a2 + a3), |
| 188 | + "a1-a2": np.linalg.norm(a1 - a2), |
| 189 | + "a1-a3": np.linalg.norm(a1 - a3), |
| 190 | + "a2-a3": np.linalg.norm(a2 - a3), |
| 191 | + "a1+a2+a3": np.linalg.norm(a1 + a2 + a3), |
| 192 | + "a1+a2-a3": np.linalg.norm(a1 + a2 - a3), |
| 193 | + "a1-a2+a3": np.linalg.norm(a1 - a2 + a3), |
| 194 | + "a1-a2-a3": np.linalg.norm(a1 - a2 - a3), |
| 195 | + "-a1+a2+a3": np.linalg.norm(-a1 + a2 + a3), |
| 196 | + "-a1+a2-a3": np.linalg.norm(-a1 + a2 - a3), |
| 197 | + "-a1-a2+a3": np.linalg.norm(-a1 - a2 + a3), |
| 198 | + "-a1-a2-a3": np.linalg.norm(-a1 - a2 - a3), |
| 199 | + } |
| 200 | + |
| 201 | + A = list(all_combinations.values()) |
| 202 | + B = [safe_dist[type_i] * 2 for type_i in symbols] |
| 203 | + |
| 204 | + for a in A: |
| 205 | + for b in B: |
| 206 | + if a < b: |
| 207 | + print(f"Lattice length {a:.3f} is less than safe distance {b:.3f} ") |
| 208 | + return False |
177 | 209 |
|
178 | 210 | num_atoms = len(coords)
|
179 | 211 | for i in range(num_atoms):
|
180 | 212 | for j in range(i + 1, num_atoms):
|
181 |
| - dist = extended_structure.get_distance(i, j, mic=True) |
| 213 | + dist = structure.get_distance(i, j, mic=True) |
182 | 214 | type_i = symbols[i]
|
183 | 215 | type_j = symbols[j]
|
184 | 216 | dr = safe_dist[type_i] + safe_dist[type_j]
|
@@ -269,9 +301,9 @@ def check(
|
269 | 301 | cell, _ = structure.get_cell().standard_form()
|
270 | 302 |
|
271 | 303 | if (
|
272 |
| - cell[1][0] > np.tan(self.theta / 180.0 * np.pi) * cell[1][1] # type: ignore |
273 |
| - or cell[2][0] > np.tan(self.theta / 180.0 * np.pi) * cell[2][2] # type: ignore |
274 |
| - or cell[2][1] > np.tan(self.theta / 180.0 * np.pi) * cell[2][2] # type: ignore |
| 304 | + np.abs(cell[1][0]) > np.tan(self.theta / 180.0 * np.pi) * cell[1][1] # type: ignore |
| 305 | + or np.abs(cell[2][0]) > np.tan(self.theta / 180.0 * np.pi) * cell[2][2] # type: ignore |
| 306 | + or np.abs(cell[2][1]) > np.tan(self.theta / 180.0 * np.pi) * cell[2][2] # type: ignore |
275 | 307 | ):
|
276 | 308 | logging.warning("Inclined box")
|
277 | 309 | return False
|
|
0 commit comments