Skip to content

Commit

Permalink
Merge pull request #569 from TRI-AMDD/new_tutorial
Browse files Browse the repository at this point in the history
New tutorial
  • Loading branch information
JosephMontoya-TRI committed Aug 24, 2022
2 parents c7f384f + 36ac209 commit 2f6ee68
Show file tree
Hide file tree
Showing 8 changed files with 1,262 additions and 77 deletions.
3 changes: 2 additions & 1 deletion camd/analysis.py
Original file line number Diff line number Diff line change
Expand Up @@ -328,6 +328,7 @@ def __init__(
self.space = None
self.plot = plot
self.initial_seed_indices = initial_seed_indices
self.current_analysis = None
super(StabilityAnalyzer, self).__init__()

@staticmethod
Expand Down Expand Up @@ -436,7 +437,7 @@ def analyze(self, campaign, finalize=False):
self.plot_hull(
filtered, new_experimental_results.index, filename="hull.png"
)

self.current_analysis = new_data
# Compute summary metrics
summary = self.get_summary(
new_seed,
Expand Down
35 changes: 33 additions & 2 deletions camd/experiment/dft.py
Original file line number Diff line number Diff line change
Expand Up @@ -868,7 +868,11 @@ def get_qmpy_formation_energy(total_e, formula, n_atoms):


def get_mp_formation_energy(
total_e, formula, potcar_symbols, hubbards={}, explain=False
total_e,
formula,
potcar_symbols,
hubbards={},
explain=False
):
"""
Helper function to computer mp-compatible formation
Expand Down Expand Up @@ -902,7 +906,9 @@ def get_mp_formation_energy(
"is_hubbard": is_hubbard,
},
)
entry = compatibility.process_entry(entry)
# process_entry has a bad try/except block that makes it difficult to catch errors,
# use this instead
entry = compatibility.process_entries([entry])[0]
if explain:
print(compatibility.explain(entry))
energy = entry.energy
Expand All @@ -911,6 +917,31 @@ def get_mp_formation_energy(
return energy / comp.num_atoms


def get_mp_formation_energy_from_m3gnet(total_e, structure, explain=False):
"""
Hack to get materials-project compatible formation energy from m3gnet
by overriding potcar/hubbard values with default values from MPRelaxSet
"""
vaspset = MPRelaxSet(structure)
potcar_symbols = ["PBE {}".format(sym) for sym in vaspset.potcar_symbols]
symbols = [s.split()[1] for s in potcar_symbols]
symbols = [re.split(r"_", s)[0] for s in symbols]
if not vaspset.incar.get("LDAU", False):
hubbards = {}
else:
us = vaspset.incar.get("LDAUU")
js = vaspset.incar.get("LDAUJ")
if len(js) != len(us):
js = [0] * len(us)
if len(us) == len(symbols):
hubbards = {symbols[i]: us[i] - js[i] for i in range(len(symbols))}
elif sum(us) == 0 and sum(js) == 0:
hubbards = {}
return get_mp_formation_energy(
total_e, structure.composition.formula, potcar_symbols=potcar_symbols,
hubbards=hubbards, explain=explain)


def update_dataframe_row(dataframe, index, update_dict, add_columns=False):
"""
Method to update a dataframe row via an update_dictionary
Expand Down
4 changes: 2 additions & 2 deletions examples/adaboost_atf_structure_discovery.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -339,7 +339,7 @@
],
"metadata": {
"kernelspec": {
"display_name": "Python 3 (ipykernel)",
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
Expand All @@ -353,7 +353,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.7.12"
"version": "3.9.12"
}
},
"nbformat": 4,
Expand Down
Binary file added examples/binary_sulfides_mp.pickle
Binary file not shown.
395 changes: 324 additions & 71 deletions examples/main_tutorial.ipynb

Large diffs are not rendered by default.

Binary file added examples/mn_s_candidates.pickle
Binary file not shown.
Loading

0 comments on commit 2f6ee68

Please sign in to comment.