symmetry
Degrees of freedom that cannot break a crystal's symmetry.
The degrees of freedom here are the asymmetric unit. Symmetry operations are
applied to produce the unit cell, so every geometry the calculator sees is
exactly symmetric by construction, and the optimiser carries roughly 3N / |G|
atomic variables plus one per allowed strain rather than 3N + 9. For acetic
acid in Pna2_1 that is 24 atomic and 3 cell freedoms in place of 102.
Being exact rather than approximate matters most when the forces are noisy, which is to say whenever they come from a machine-learned potential: a relaxation that projects a structure back towards symmetry after each step accumulates the residual, while one that cannot express an asymmetric geometry has nothing to accumulate.
Atoms on special positions get fewer than three freedoms each rather than three followed by a projection. The site-symmetry group's invariant subspace is computed once and the atom is parameterised by its coordinates in it: two freedoms on a mirror plane, one on a three-fold axis, none on an inversion centre.
AtomMap
How each of a set of symmetry operations permutes a system's atoms.
Operation g takes atom i onto atom permutation[g, i] in the cell
displaced by the integer lattice vector shifts[g, i]:
R_g x_i + t_g = x_(permutation[g, i]) + shifts[g, i]
in fractional coordinates.
Attributes:
| Name | Type | Description |
|---|---|---|
rotations |
(G, 3, 3) fractional rotation parts |
|
translations |
(G, 3) fractional translation parts |
|
permutation |
(G, N) image atom of each atom under each operation |
|
shifts |
(G, N, 3) integer lattice shift of each image |
Source code in chmpy/opt/symmetry.py
380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 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 | |
cartesian(cell)
identity(n_atoms)
classmethod
The trivial group, for a structure with no symmetry to use
preserving_strain(strain, cell, tolerance=1e-08)
The operations with R eps R^T = eps, i.e. those a strained cell keeps.
Fractional coordinates are unchanged by a strain, so the permutations and shifts carry over.
Source code in chmpy/opt/symmetry.py
subset(keep)
The operations selected by a boolean mask or an index array
Source code in chmpy/opt/symmetry.py
symmetrise(vectors, cell)
Symmetric part of per-atom vectors (e.g. forces).
Group average of v_i -> R_g v_i placed on atom g(i), i.e. the
orthogonal projection onto the invariant subspace.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
vectors
|
(N, 3) Cartesian vectors, one per atom |
required | |
cell
|
(3, 3) lattice vectors as rows, to make the rotations Cartesian in |
required |
Returns:
| Type | Description |
|---|---|
ndarray
|
(N, 3) symmetric part |
Source code in chmpy/opt/symmetry.py
InvariantAtomic
Bases: Coordinates
Cartesian atomic positions at a fixed cell, restricted by a symmetry.
One degree of freedom per symmetry-unique atom and allowed site direction;
the rest of each orbit follows by symmetry. Like SymmetryAdapted but
needs only a P1 System and an AtomMap, so it works for any subgroup.
A unit amplitude moves each atom in the orbit by 1 Angstrom.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
system
|
the structure to vary |
required | |
atom_map
|
AtomMap
|
the operations to preserve, from |
required |
Source code in chmpy/opt/symmetry.py
576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 | |
SymmetryAdapted
Bases: Strain
The asymmetric unit and the allowed cell strains, and nothing else.
The atomic degrees of freedom are displacements of the asymmetric unit in fractional coordinates, which is the natural choice once the cell can deform: fractional coordinates are unchanged by a strain, so the two kinds of freedom do not fight each other, and the strain gradient is exactly the stress.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
crystal
|
the structure to relax |
required | |
cell
|
bool
|
whether to vary the cell |
True
|
fixed
|
(n_asym,) boolean mask of asymmetric-unit atoms to hold still |
None
|
|
tolerance
|
float
|
site-merging tolerance passed to |
0.01
|
info
|
model inputs that are not geometry, carried on the |
None
|
Attributes:
| Name | Type | Description |
|---|---|---|
crystal |
the crystal this was built from |
|
system |
the P1 unit cell handed to the calculator |
Source code in chmpy/opt/symmetry.py
83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 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 183 184 185 186 187 188 189 190 191 192 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 230 231 232 233 234 235 236 237 238 239 240 241 242 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 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 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 341 342 343 344 345 346 347 348 349 350 | |
n_atomic
property
Atomic degrees of freedom, after site symmetry has removed the rest
asymmetric_fractional()
(n_asym, 3) current fractional coordinates of the asymmetric unit
Source code in chmpy/opt/symmetry.py
reanchor(x, force=False)
Fold the current strain into the reference cell.
The atomic freedoms are fractional, so they are untouched by this -- only the cell reference and the amplitudes change.
Source code in chmpy/opt/symmetry.py
scale()
Angstroms moved per unit degree of freedom.
A fractional displacement of one along a basis direction moves the atom
by the length of that direction's Cartesian image -- roughly a cell
edge. Getting this wrong is what makes an unscaled optimiser take
wildly different effective step sizes along a and along c.
Source code in chmpy/opt/symmetry.py
to_crystal()
The relaxed structure, in its original space group.
Source code in chmpy/opt/symmetry.py
cartesian_operations(rotations, cell)
Fractional rotations as Cartesian ones, A^T R A^-T, with lattice
vectors as the rows of A.
Unlike chmpy.opt.strain.cartesian_rotations this keeps duplicates, so the
result lines up with an AtomMap.
Source code in chmpy/opt/symmetry.py
crystal_atom_map(crystal, system, tolerance=0.01)
A crystal's space group, as it acts on a P1 system built from that crystal
map_atoms(system, operations, tolerance=0.01)
Find how each operation permutes the atoms of a periodic system.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
system
|
a periodic |
required | |
operations
|
|
required | |
tolerance
|
float
|
max distance in Angstroms between an image and its match;
the default matches |
0.01
|
Raises:
| Type | Description |
|---|---|
ValueError
|
if an operation is not a symmetry of the structure |
Source code in chmpy/opt/symmetry.py
site_displacement_basis(rotations, tolerance=1e-08)
The displacements a site may make without leaving its special position.
The site-symmetry group fixes the site, so a displacement d keeps it
there exactly when R d = d for every R in that group. Averaging the
group gives P = (1/|G|) sum_R R, which is idempotent, and the fixed
vectors are exactly its range: P d = d for any d = P v, and any fixed
d is P d. So an orthonormal basis of the range of P is the answer.
It has to be the range, not an eigenvector calculation. In fractional
coordinates R is an integer matrix that is only orthogonal when the cell
is, so for a trigonal, hexagonal or rhombohedral cell P is idempotent but
not symmetric, and neither symmetrising it nor taking the eigenvectors of
P^T P recovers the space it projects onto. Both give a direction that
leaves the special position: for triazine in R-3c they move an atom off a
two-fold axis, the site multiplicity doubles from 18 to 36, and the cell
comes back with 72 atoms in it instead of 54, some of them 0.37 A apart.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
rotations
|
(M, 3, 3) fractional rotation parts of the operations that map the site onto itself |
required | |
tolerance
|
float
|
how far the rank of |
1e-08
|
Returns:
| Type | Description |
|---|---|
ndarray
|
(3, d) orthonormal columns spanning the allowed displacements, with |
ndarray
|
from 0 (a fixed site, such as an inversion centre) to 3 (a general one) |
Source code in chmpy/opt/symmetry.py
symmetric_measures(result, atom_map, cell, basis=None, free=None)
Convergence measures for a symmetry-constrained relaxation.
fmax and smax are taken on the symmetric parts of the forces and
stress, since those are all the relaxation can change. Models that are not
exactly equivariant (e.g. PET) leave a small symmetry-forbidden force that
would otherwise make tight tolerances unreachable. Its size is reported as
forbidden but is not a convergence criterion.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
result
|
a calculator |
required | |
atom_map
|
the operations the relaxation preserves |
required | |
cell
|
the current lattice vectors |
required | |
basis
|
(k, 3, 3) the allowed strains, or None at fixed cell |
None
|
|
free
|
(N,) mask of the atoms that may move; the force on a fixed atom is no measure of convergence |
None
|
Returns:
| Type | Description |
|---|---|
dict
|
{"fmax", "forbidden"}, plus "smax" when the cell varies |