Skip to content

Fix WenAlloys.compute_gamma_radii to match documented formula (#952)#967

Open
vasa-develop wants to merge 1 commit into
hackingmaterials:mainfrom
vasa-develop:fix/wenalloys-gamma-radii-952
Open

Fix WenAlloys.compute_gamma_radii to match documented formula (#952)#967
vasa-develop wants to merge 1 commit into
hackingmaterials:mainfrom
vasa-develop:fix/wenalloys-gamma-radii-952

Conversation

@vasa-develop

Copy link
Copy Markdown

Summary

Fixes #952.

WenAlloys.compute_gamma_radii implements the atomic-packing parameter γ = ω_S / ω_L (solid angles of the smallest and largest atoms) from Wang et al., Scripta Materialia 94 (2015) 28–31 (doi:10.1016/j.scriptamat.2014.09.010), where

omega = 1 - sqrt( ((r + r_bar)^2 - r_bar^2) / (r + r_bar)^2 )

The implementation expanded the numerator inside the square root incorrectly:

# before
numerator   = 1 - np.sqrt((mrmean * mrmin + mrmin**2) / (mrmean + mrmin) ** 2)
denominator = 1 - np.sqrt((mrmean * mrmax + mrmax**2) / (mrmean + mrmax) ** 2)

(r + r_bar)^2 - r_bar^2 expands to 2*r_bar*r + r^2, but the code used r_bar*r + r^2 — i.e. it dropped one r_bar*r term. This made the code disagree with both its own docstring and the source paper. (Reported by @KwamiAldo in #952.)

Fix

# after
numerator   = 1 - np.sqrt(((mrmean + mrmin) ** 2 - mrmean**2) / (mrmean + mrmin) ** 2)
denominator = 1 - np.sqrt(((mrmean + mrmax) ** 2 - mrmean**2) / (mrmean + mrmax) ** 2)

The docstring already documented the correct (paper) formula, so this only changes the implementation to match it.

Impact

This changes the value of the "Radii gamma" feature. For example, with mean/min/max Miracle radii of 140/120/160 pm, γ changes from 1.189 to 1.362 — which straddles the commonly used γ ≈ 1.175 solid-solution vs. intermetallic threshold, so the correction can affect downstream phase-stability screening. The pinned "Radii gamma" values in test_WenAlloys are updated accordingly.

Test plan

  • Added test_wen_alloys_gamma_radii, a focused regression test that checks compute_gamma_radii against the closed-form ω_S/ω_L expression (and a hard-coded analytic value). It fails on main (old formula gives 1.1888…) and passes here.
  • Updated the three affected "Radii gamma" values in test_WenAlloys to the corrected outputs.
  • pytest tests/featurizers/composition/test_alloy.py passes (5 passed).
  • black --check (line-length 120) clean on the changed files; no new flake8 issues introduced.

Note

This PR intentionally fixes only compute_gamma_radii. The related #962 also flags the configuration-entropy sign and the mixing-enthalpy abs(); I've kept those out of scope here so this change stays minimal and easy to review. (For what it's worth, the "Yang omega is affected" claim in #962 does not appear to hold — YangSolidSolution.compute_omega wraps the result in abs(), so the entropy sign cancels there — but happy to follow up separately on the entropy/enthalpy features if you'd like.)

…gmaterials#952)

compute_gamma_radii computed the solid-angle numerator/denominator as
(r_bar*r + r**2) instead of the documented ((r + r_bar)**2 - r_bar**2),
so the implementation disagreed with both its own docstring and the
Wang et al. (Scripta Mater. 94, 2015) definition gamma = omega_S/omega_L.
Correct the formula, update the affected pinned values in test_WenAlloys,
and add a focused regression test for compute_gamma_radii.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Concern about formula used in Compute_gamma_radii() in the WenAlloys() class

1 participant