-
Notifications
You must be signed in to change notification settings - Fork 922
fix: young's modulus unit #4436
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
Head branch was pushed to by a user without write access
|
@shyuep Please check whether the formula and units used in calculating Clarke's thermal conductivity are correct. According to GPT, a Reduced Planck constant is missing. |
|
following up on this |
|
@mkhorton @esoteric-ephemera Pls review this short PR. Do we want to really return the GPa elastic tensor or do we just update the doc to note that it is in eV/A3? I think this will cause all hell to break loose in downstream stuff like MP? |
|
I checked and the only dimensional elasticity data we have on MP are the bulk and shear moduli, which get corrected converted (slightly outdated builder link) to GPa from kilobar. The derived data that would be inconsistent with the docstr is visible when you pull elastic data from the API or AWS My vote is for returning consistent units without conversion and let the user decide which system of units to use |
| Voigt-Reuss-Hill averages of bulk and shear moduli. | ||
| """ | ||
| return 9.0e9 * self.k_vrh * self.g_vrh / (3 * self.k_vrh + self.g_vrh) | ||
| return 9.0e9 * self.k_vrh * self.g_vrh * self.eV_A3_to_GPa / (3 * self.k_vrh + self.g_vrh) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@anyangml I would change the docstr to:
Calculates Young's modulus using Voigt-Reuss-Hill averages of bulk and shear moduli.
and remove the conversion to GPa here (and elsewhere where SI units are reported):
return 9* self.k_vrh * self.g_vrh / (3 * self.k_vrh + self.g_vrh)|
Also @anyangml on the question of other missing units in the thermal conductivity, here's a good reference which summarizes the Clark, Cahill, and Agne thermal conductivity methods:
These should probably get unified into an underlying method: def _estimate_thermalcond(self, structure: Structure, cons: float) -> float:
"""Estimate thermal conductivity using semi-classical methods.
Args:
structure: pymatgen structure object
cons : float
Returns:
float: thermal conductivity
"""
n_sites = len(structure)
site_density = n_sites / structure.volume
return cons * kB* site_density ** (2 / 3) * (self.long_v(structure) + 2 * self.trans_v(structure)) / 3Tagging @naik-aakash who implemented these first to make sure I got that right |
Hi @esoteric-ephemera , I had added only for the Agne model. Currently the formula seems fine to me, but Boltzmann constant (kB) seems to be missing in the function proposed, and I would have expected returned values to be in (W/(m·K)). I'm not sure what the planned change is here. |
|
Thanks for the context and typo fix @naik-aakash - updated the formula above. I think we're trying to avoid coercing values into SI units since there's no easy way to check the units input by a user (without adding a lot of So the units won't be in W/(m . K) unless the input units are also SI |
|
@esoteric-ephemera i would be concerned about lots of breaking changes, especially for the units. |
|
I also don't like the idea of breaking changes, but I think we need to at least alert users about potential incorrect unit conversion from this module. What about:
Ex: @property
def deprecated_y_mod(self) -> float:
"""
Calculates Young's modulus (in non-standard units) using the
Voigt-Reuss-Hill averages of bulk and shear moduli.
"""
warnings.warn("This function which incorrectly performs unit conversion is deprecated and slated for removal on 2026-01-01, but is currently maintained for backwards compatibility")
return 9.0e9 * self.k_vrh * self.g_vrh / (3 * self.k_vrh + self.g_vrh)
@property
def y_mod(self) -> float:
"""
Calculates Young's modulus using the
Voigt-Reuss-Hill averages of bulk and shear moduli.
The units are the same as those for the bulk/shear moduli.
"""
warnings.warn("This function no longer performs unit conversion. For the older function, which performed incorrect unit conversion and will be removed, please see `deprecated_y_mod`.")
return 9 * self.k_vrh * self.g_vrh / (3 * self.k_vrh + self.g_vrh) |
|
@esoteric-ephemera i would prefer this approach! |
Summary
Major changes:
fix Young's Modulus Unit, resolve #4435
Checklist
ruff.mypy.duecredit@due.dcitedecorators to reference relevant papers by DOI (example)Tip: Install
pre-commithooks to auto-check types and linting before every commit: