elastic
Elastic constants by finite strain.
C_ij = (1/V) d2E / de_i de_j is computed by straining the cell in each
direction, relaxing the atoms at fixed cell, and differencing the stress.
- Relaxed atoms.
relax_atoms=True(the default) relaxes the atoms at every strained geometry. Clamped-atom constants can be much stiffer, particularly for molecular crystals. - Strain selection. Since
C (R e R^T) = R (C e) R^T, one strain gives the response for its whole point-group orbit. Only strains not already covered are applied (2 for cubic, 3 for hexagonal, 6 for triclinic), and the tensor is a least-squares fit over all rotated responses. - Subgroup relaxation. A strain keeps the operations with
R eps R^T = eps, and the atoms relax within that subgroup (chmpy.opt.symmetry.InvariantAtomic). This cannot find a lower-symmetry minimum if the reference is a saddle point in P1;tensor.is_stable()will usually flag that, andsymmetry=Falserelaxes in P1. - Projection. The result is projected onto the tensors the point group
allows.
symmetry_residualreports the larger of the fit misfit and the size of that projection, andasymmetrythe largest|C_ij - C_ji|; both are noise estimates.
method="hessian" gets the same relaxed-ion tensor without relaxing anything:
C = C0 - L^T Phi^+ L / V from the clamped-ion constants, the internal-strain
tensor and the Gamma-point Hessian, every piece one central difference and the
lot one batch of evaluations. See hessian_elastic_tensor.
ElasticResult
dataclass
An elastic tensor and how much to believe it.
Attributes:
| Name | Type | Description |
|---|---|---|
tensor |
object
|
the |
evaluations |
int
|
calculator evaluations used |
relaxed_atoms |
bool
|
whether the atoms were relaxed at each strain |
residual_stress |
float
|
largest stress component of the reference structure in GPa. Elastic constants are defined at equilibrium; a large value here means the answer is not the quantity it is called. |
asymmetry |
float
|
largest |
symmetry_residual |
float
|
how far the measured stresses are from what the point group allows, in GPa (fit misfit or projection size, whichever is larger). Always zero for triclinic. |
n_independent |
int
|
independent elastic constants the point group allows |
strain |
float
|
the engineering strain used |
strains |
tuple
|
Voigt indices actually applied |
method |
str
|
"strain" (finite strain, atoms relaxed at each) or "hessian" (clamped-ion constants corrected through the internal-strain tensor and the Gamma-point Hessian) |
internal_strain_noise |
float | None
|
for "hessian", the disagreement between the internal-strain tensor measured from strained cells and from displaced ones, propagated into the constants, in GPa |
clamped |
ndarray | None
|
for "hessian", the clamped-ion tensor C0 in GPa |
Source code in chmpy/opt/elastic.py
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 | |
c_voigt
property
(6, 6) elastic constants in GPa
noise
property
The largest of the free error estimates, in GPa
noise_fraction
property
Estimated noise as a fraction of the largest constant.
Two measurements come free with the calculation, and the larger is taken. Above a few percent the tensor is not converged: the strain was too small for the stress response to clear the calculator's noise, or the atomic relaxation was not run hard enough, or both.
StrainPoint
dataclass
One strained cell of a finite-strain elastic tensor.
Attributes:
| Name | Type | Description |
|---|---|---|
index |
int
|
engineering Voigt component, 0-5 (xx yy zz yz xz xy) |
sign |
int
|
+1 or -1 |
strain |
float
|
the engineering strain magnitude |
system |
System
|
the reference cell under this strain, atoms carried affinely and not yet relaxed |
Source code in chmpy/opt/elastic.py
name
property
A label fit for a directory name, e.g. 'voigt3_minus'
elastic_from_stresses(stresses, *, strain, rotations=None, reference_stress=None, relaxed_atoms=True)
Fit an elastic tensor to stresses computed elsewhere.
The counterpart of strain_points: every Voigt index present must have
both its + and - stress, and together they must cover the strains
independent_strains(rotations) asks for. Extra indices are used in the
fit.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
stresses
|
mapping of |
required | |
strain
|
float
|
the engineering strain the cells were built with |
required |
rotations
|
(M, 3, 3) Cartesian point operations in the frame of the strained cells; None or empty for no symmetry |
None
|
|
reference_stress
|
(3, 3) stress of the unstrained cell in eV/A^3, if
computed; reported as |
None
|
|
relaxed_atoms
|
bool
|
whether the atoms were relaxed at each strained cell, recorded on the result |
True
|
Returns:
| Type | Description |
|---|---|
ElasticResult
|
ElasticResult, with |
Source code in chmpy/opt/elastic.py
elastic_tensor(structure, calculator, *, strain=DEFAULT_STRAIN, relax_atoms=True, symmetry=True, rotations=None, info=None, fmax=0.01, steps=200, progress=None, method='strain', displacement=DEFAULT_DISPLACEMENT, force_constants=None)
Compute the elastic tensor of a relaxed structure.
The structure should already be relaxed: elastic constants are second
derivatives at a minimum, and a residual stress makes them ambiguous.
residual_stress on the result says how well that held.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
structure
|
a relaxed |
required | |
calculator
|
a |
required | |
strain
|
float
|
engineering strain magnitude for the finite difference, or "auto" to try successively larger ones until the tensor's own noise estimate falls below a few percent. A strain too small for the stress response to clear the calculator's noise is the usual reason an elastic tensor comes out wrong, and how small is too small depends on the calculator, not on the structure. |
DEFAULT_STRAIN
|
relax_atoms
|
bool
|
relax the atoms at each strained cell. Leave this on unless you specifically want clamped-atom constants. |
True
|
symmetry
|
bool
|
use the point group to choose the strains, relax the atoms within the subgroup each strain preserves, and project the result onto the tensors the point group allows. When False, all six strains are applied and the atoms relax in P1. |
True
|
rotations
|
(M, 3, 3) Cartesian point operations. Taken from a
|
None
|
|
info
|
model inputs that are not geometry, carried on every |
None
|
|
fmax
|
float
|
force convergence for the atomic relaxations, eV/A |
0.01
|
steps
|
int
|
iteration cap for each atomic relaxation |
200
|
progress
|
True to print progress, or a callable given a
|
None
|
|
method
|
str
|
"strain" relaxes the atoms at each strained cell. "hessian"
relaxes none: it takes the clamped-ion constants from strained
cells and corrects them with the internal-strain tensor and the
Gamma-point Hessian, |
'strain'
|
displacement
|
float
|
atomic finite-difference step for method="hessian", A |
DEFAULT_DISPLACEMENT
|
force_constants
|
for method="hessian", |
None
|
Returns:
| Type | Description |
|---|---|
ElasticResult
|
ElasticResult |
Source code in chmpy/opt/elastic.py
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 351 352 353 354 355 356 357 358 359 360 361 362 363 364 | |
fit_elastic(responses, rotations)
Least-squares Voigt tensor from strain responses and their rotations.
Each (index, response) is the stress per unit engineering strain along
Voigt direction index; each rotation adds the pair (R e R^T, R s R^T).
Returns:
| Type | Description |
|---|---|
|
(raw (6, 6) tensor, largest residual of the fit). The residual is |
|
|
nonzero only when responses disagree with the symmetry. |
Source code in chmpy/opt/elastic.py
hessian_elastic_tensor(structure, calculator, *, strain=HESSIAN_STRAIN, displacement=DEFAULT_DISPLACEMENT, symmetry=True, rotations=None, info=None, force_constants=None, progress=None)
Relaxed-ion elastic constants from second derivatives, without relaxing.
Expanding the energy to second order in the strain e and the internal
displacements u and minimising over u gives
C = C0 - (1/V) L^T Phi^+ L
with C0 the clamped-ion constants (stress response at fixed fractional
coordinates), Phi the Gamma-point Hessian of the cell, and
L = d2E/du de the internal-strain tensor. Every piece is a central
difference, so the whole calculation is one batch of independent
evaluations: the symmetry-unique displacements of the unit cell for
Phi, and twelve strained cells for C0 and L.
L is measured twice -- as -dF/de on every atom from the strained
cells, and as d(virial)/du from the displaced ones, completed by
symmetry -- and the two have to agree. Their average is used, and half
the difference between the tensors each gives is internal_strain_noise
on the result. The three uniform translations are projected out of Phi
before it is inverted, which is where the acoustic sum rule comes in.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
structure
|
a relaxed |
required | |
calculator
|
a |
required | |
strain
|
float
|
engineering strain for |
HESSIAN_STRAIN
|
displacement
|
float
|
atomic step for |
DEFAULT_DISPLACEMENT
|
symmetry
|
bool
|
displace only symmetry-unique atoms, fold |
True
|
rotations
|
(M, 3, 3) Cartesian point operations, as for
|
None
|
|
info
|
model inputs that are not geometry |
None
|
|
force_constants
|
|
None
|
|
progress
|
as for |
None
|
Returns:
| Type | Description |
|---|---|
ElasticResult
|
ElasticResult with method="hessian" |
Source code in chmpy/opt/elastic.py
510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 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 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 | |
independent_strains(rotations)
The Voigt strains to apply, skipping any already spanned by the
point-group orbits of earlier ones. Cubic gives [0, 3], hexagonal
[0, 2, 3], triclinic all six.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
rotations
|
(M, 3, 3) Cartesian point operations, or empty for none |
required |
Returns:
| Type | Description |
|---|---|
list[int]
|
Voigt indices, in increasing order |
Source code in chmpy/opt/elastic.py
strain_points(structure, *, strain=DEFAULT_STRAIN, symmetry=True, rotations=None, info=None)
The strained cells elastic_tensor would visit, for another code to run.
Relax the atoms of each at fixed cell (or not, for clamped-ion constants),
take the final stress, and pass the stresses to elastic_from_stresses
with the same strain and rotations. Only the point-group-independent
strains are listed, a + and - cell for each.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
structure
|
a relaxed |
required | |
strain
|
float
|
engineering strain magnitude |
DEFAULT_STRAIN
|
symmetry
|
bool
|
reduce the strains with the point group; False gives all six |
True
|
rotations
|
(M, 3, 3) Cartesian point operations, taken from a
|
None
|
|
info
|
model inputs carried on every |
None
|
Returns:
| Type | Description |
|---|---|
list[StrainPoint]
|
list of |
Source code in chmpy/opt/elastic.py
voigt_strain(index, magnitude)
The strain tensor for one engineering Voigt component.
Voigt order is xx, yy, zz, yz, xz, xy, and the shear components carry the
engineering factor of two: e_3 = 2 * eps_yz, so a unit of e_3 is half a
unit in each of the two off-diagonal entries.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
index
|
int
|
0-5 |
required |
magnitude
|
float
|
the engineering strain |
required |
Returns:
| Type | Description |
|---|---|
ndarray
|
(3, 3) symmetric strain tensor |