Skip to content

Commit de03673

Browse files
shyuepclaude
andcommitted
docs: use units_GPa in ElasticityCalc README and notebook examples
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
1 parent 39311f6 commit de03673

2 files changed

Lines changed: 10 additions & 3 deletions

File tree

README.md

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -116,13 +116,19 @@ from pymatgen.ext.matproj import MPRester
116116

117117
mpr = MPRester()
118118
si = mpr.get_structure_by_material_id("mp-149")
119-
c = mtc.ElasticityCalc("TensorNet-PES-MatPES-PBE-2025.2", relax_structure=True)
119+
c = mtc.ElasticityCalc("TensorNet-PES-MatPES-PBE-2025.2", relax_structure=True, units_GPa=True)
120120
props = c.calc(si)
121-
print(f"K_VRH = {props['bulk_modulus_vrh'] * 160.2176621} GPa")
121+
print(f"K_VRH = {props['bulk_modulus_vrh']} GPa")
122122
```
123123

124124
The calculated `K_VRH` is about 102 GPa, in reasonably good agreement with the experimental and DFT values.
125125

126+
By default, `ElasticityCalc` returns the elastic tensor and moduli in pymatgen's native units of
127+
eV/ų. Pass `units_GPa=True` (as above) to have `elastic_tensor`, `bulk_modulus_vrh`,
128+
`shear_modulus_vrh`, `youngs_modulus`, and `residuals_sum` returned directly in GPa, avoiding manual
129+
unit conversion. The returned dict also carries a `_units` entry mapping each numeric output to its
130+
unit string.
131+
126132
You can list all supported universal calculators using the `UNIVERSAL_CALCULATORS` enum:
127133

128134
```python
@@ -193,6 +199,7 @@ elast_calc = mtc.ElasticityCalc(
193199
use_equilibrium=True,
194200
relax_structure=False, # Skip re-relaxation since we already relaxed above.
195201
relax_deformed_structures=True,
202+
units_GPa=True, # Report moduli in GPa rather than eV/A^3.
196203
)
197204
prop_calc = mtc.ChainedCalc([relax_calc, energetics_calc, elast_calc])
198205
results = prop_calc.calc(structure)

examples/Calculating MLIP properties.ipynb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -382,7 +382,7 @@
382382
"source": [
383383
"propcalc = ChainedCalc([\n",
384384
" RelaxCalc(\"TensorNet-PES-MatPES-PBE-2025.2\", fmax=fmax, optimizer=optimizer), \n",
385-
" ElasticityCalc(\"TensorNet-PES-MatPES-PBE-2025.2\", fmax=fmax, relax_structure=False), \n",
385+
" ElasticityCalc(\"TensorNet-PES-MatPES-PBE-2025.2\", fmax=fmax, relax_structure=False, units_GPa=True), \n",
386386
" EOSCalc(\"TensorNet-PES-MatPES-PBE-2025.2\", fmax=fmax, optimizer=optimizer, relax_structure=False)])\n",
387387
"propcalc.calc(mp_data[0])"
388388
]

0 commit comments

Comments
 (0)