Skip to content
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

Optimize BandCenter and IntersticeDistribution featurizers #897

Merged
merged 1 commit into from
May 26, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions matminer/featurizers/composition/element.py
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,9 @@ class BandCenter(BaseFeaturizer):
- Band center
"""

magpie_data = MagpieData()
deml_data = DemlData()

def featurize(self, comp):
"""
(Rough) estimation of absolution position of band center using
Expand All @@ -222,8 +225,8 @@ def featurize(self, comp):
gmean = 1.0
sumamt = sum(comp.get_el_amt_dict().values())
for el, amt in comp.get_el_amt_dict().items():
first_ioniz = DemlData().get_elemental_property(Element(el), "first_ioniz") / 1000
elec_aff = MagpieData().get_elemental_property(Element(el), "ElectronAffinity")
first_ioniz = self.deml_data.get_elemental_property(Element(el), "first_ioniz") / 1000
elec_aff = self.magpie_data.get_elemental_property(Element(el), "ElectronAffinity")
gmean *= (0.5 * (first_ioniz + elec_aff) / 96.48) ** (amt / sumamt)
return [gmean]

Expand Down
5 changes: 3 additions & 2 deletions matminer/featurizers/site/misc.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ def __init__(self, cutoff=6.5, interstice_types=None, stats=None, radius_type="M
raise ValueError("interstice_types only support sub-list of " "['dist', 'area', 'vol']")
self.stats = ["mean", "std_dev", "minimum", "maximum"] if stats is None else stats
self.radius_type = radius_type
self.data_source = MagpieData()

def featurize(self, struct, idx):
"""
Expand All @@ -78,9 +79,9 @@ def featurize(self, struct, idx):
nn_coords = np.array([nn["site"].coords for nn in n_w])

# Get center atom's radius and its nearest neighbors' radii
center_r = MagpieData().get_elemental_properties([struct[idx].specie], self.radius_type)[0] / 100
center_r = self.data_source.get_elemental_properties([struct[idx].specie], self.radius_type)[0] / 100
nn_els = [nn["site"].specie for nn in n_w]
nn_rs = np.array(MagpieData().get_elemental_properties(nn_els, self.radius_type)) / 100
nn_rs = np.array(self.data_source.get_elemental_properties(nn_els, self.radius_type)) / 100

# Get indices of atoms forming the simplices of convex hull
convex_hull_simplices = ConvexHull(nn_coords).simplices
Expand Down