supercells
SupercellGenerator(atoms, grid, q_ibz=None, sc_matrices=None, sc_sizes=None, q_comm=None)
Source code in quesadilla/supercells.py
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
|
get_ibz()
Gets the q points in a structures IBZ. The output is sorted for consistency.
- primitive: phonopy.structure.cells.Primitive The input structure (primitive cell, assumed to be standardized).
- grid: array-like The grid of q points (e.g., [4, 4, 4] for a 4x4x4 grid).
- qpoints: numpy.ndarray The q points in the IBZ (fractional coordinates, sorted).
Source code in quesadilla/supercells.py
50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 |
|
_atoms_to_toml()
Convert the primitive structure to a TOML table.
Source code in quesadilla/supercells.py
88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 |
|
_bz_to_toml()
Convert the Brillouin zone data to a TOML table.
Source code in quesadilla/supercells.py
105 106 107 108 109 110 111 112 113 114 115 |
|
_supercells_to_toml()
Convert the supercells data to a TOML array of tables.
Source code in quesadilla/supercells.py
117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 |
|
to_toml(output_file)
Write the supercell data to a TOML file.
- output_file: str The output file path.
Source code in quesadilla/supercells.py
138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 |
|
from_toml(input_file)
classmethod
Read the supercell data from a TOML file.
- input_file: str The input file path.
Source code in quesadilla/supercells.py
155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 |
|
atoms_from_toml(data)
staticmethod
Reconstructs a PhonopyAtoms object from TOML data.
Source code in quesadilla/supercells.py
184 185 186 187 188 189 190 191 |
|
generate_supercells(minkowski_reduce=True, minimize_supercells=False)
Generate nondiagonal supercells commensurate with the IBZ.
- reduce: bool Whether to Minkowski reduce the supercells (default: True, recommended).
- trim: bool Whether to trim the supercells using ILP (default: False, broken).
Source code in quesadilla/supercells.py
193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 |
|
_get_ndsc_matrices()
Generate nondiagonal supercell matrices commensurate with the IBZ.
Source code in quesadilla/supercells.py
231 232 233 234 235 236 237 238 239 240 241 |
|
_pick_smallest_supercells()
Solves the set cover problem with associated supercell sizes, selecting the smallest set of supercells that cover all q points in the IBZ while minimizing the total size of the selected supercells.
Notes:
This function uses integer linear programming (ILP) to ensure an optimal
selection of supercells with the smallest total size while covering all
q-points. The function requires the pulp
library to solve the ILP problem.
Source code in quesadilla/supercells.py
243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 |
|
convert_to_fraction_array(arr)
Takes a numpy array of floats and converts them to fractions.
The output array has shape (N, 2, M) where N is the number of rows in the input array and M is the number of columns. The second dimension is used to store the numerator and denominator of the fraction, respectively.
Source code in quesadilla/supercells.py
287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 |
|
find_integers(nums, g23, g12, g31, g123)
Compute integers for off-diagonal supercell matrix elements Called by find_nondiagonal()
This function is copied from QEPlayground
Source code in quesadilla/supercells.py
304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 |
|
find_nondiagonal(Q)
Nondiagonal supercell, based on [Phys. Rev. B 92, 184301] This function is copied from QEPlayground
Parameters:
Source code in quesadilla/supercells.py
343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 |
|
minkowski_reduce_sc(T, lattice)
Reduce a supercell matrix using Minkowski reduction.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
T
|
ndarray
|
Supercell matrix. |
required |
lattice
|
ndarray
|
Primitive lattice. |
required |
Returns:
Type | Description |
---|---|
numpy.ndarray: Minkowski-reduced supercell matrix with positive determinant. |
Source code in quesadilla/supercells.py
375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 |
|
make_positive_det(matrix)
If the matrix has a negative determinant, this function flips the sign of the row with the most negative entries. Phonopy requires the supercell matrix to have a positive determinant. This doesn't change the q-point that the supercell is commensurate with.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
matrix
|
ndarray
|
Input square matrix. |
required |
Returns:
Type | Description |
---|---|
ndarray
|
numpy.ndarray: Adjusted matrix. |
Source code in quesadilla/supercells.py
395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 |
|
mink_reduce(vecs, tol=1e-07, max_iter=100)
Perform Minkowski reduction on a set of 3 vectors in 3D space.
Parameters
vecs : np.ndarray of shape (3, 3) Input array where each row represents a 3D vector. tol : float, optional Tolerance for floating-point comparisons, default is 1e-7. max_iter : int, optional Maximum number of iterations, default is 100.
Returns
np.ndarray Minkowski-reduced vectors.
Source code in quesadilla/supercells.py
414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 |
|
reduce_vectors(vecs, tol)
Reduce three 3D vectors by replacing the longest vector with a linear combination that is shorter.
Parameters
vecs : np.ndarray of shape (3, 3) Input array where each row is a 3D vector. tol : float Tolerance for floating-point comparisons.
Returns
np.ndarray A new array with the reduced vectors if a reduction occurs, or the original array unchanged.
Source code in quesadilla/supercells.py
469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 |
|