Fix numerical residues in symmetry-expanded elastic strains - #1534
Fix numerical residues in symmetry-expanded elastic strains#1534xhuang-lila wants to merge 2 commits into
Conversation
|
@jmmshn Hui suggested I ask for your view because of your atomate2 elasticity experience. I would especially value a check on two API-boundary choices here: using |
|
For info, @computron |
| raise ValueError(f"tol must be positive, got {tol}") | ||
| for strain in strains: | ||
| applied_components = np.abs(strain.voigt) | ||
| nonzero_components = applied_components[applied_components != 0] |
There was a problem hiding this comment.
Could this block be simplified with
if len(applied_components[applied_components > tol]) == 0:
raise ...There was a problem hiding this comment.
Yes, that is sufficient under the function’s documented single-component input assumption. Thanks for the suggestion!
|
Thanks @xhuang-lila, just to clarify: This is basically to remove small numerical noise in the elastic tensor fitting? Generally I'm supportive of this as poor elastic tensor fitting has been a persistent problem in our workflows |
|
Yes—more specifically, this sets numerical residues in the symmetry-expanded strain inputs to exact zero before fitting; it does not modify the calculated stresses or the fitted elastic tensor. atomate2 already classifies those components as zero using |
Summary
expand_strainstolerance before handing them to pymatgen fittingTensorMapping, so symmetry acceptance and deduplication select the same entries as beforeWhy
expand_strainsaccepts a rotated strain as single-component with a default1e-3threshold, but previously stored that strain with numerical residues around1e-9to1e-8. Pymatgen fitting uses a tighter default threshold and can interpret those residues as mixed strain states, producing an ill-conditioned order-2 fit.Validation
tol2e-5 GPa cm^3/g, while the pathological high-value BPC4 population was removedThe immediate downstream benchmark workaround uses
sym_reduce=False, so benchmark correctness does not depend on this PR merging or releasing.