Skip to content

Commit

Permalink
tmp
Browse files Browse the repository at this point in the history
  • Loading branch information
janosh committed Dec 7, 2024
1 parent a575b05 commit 93d1d5c
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 18 deletions.
33 changes: 16 additions & 17 deletions matbench_discovery/structure.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ def analyze_symmetry(
*,
pbar: bool | dict[str, str] = True,
symprec: float = 1e-2,
angle_tolerance: float = -1,
angle_tolerance: float | None = None,
) -> pd.DataFrame:
"""Analyze symmetry of a dictionary of structures using spglib.
Expand All @@ -64,13 +64,12 @@ def analyze_symmetry(
Returns:
pd.DataFrame: DataFrame containing symmetry information for each structure
"""
import moyopy

sym_key_map = {
"number": Key.spg_num,
"hall_number": Key.hall_num,
"international": MbdKey.international_spg_name,
"hall": Key.hall_symbol,
"choice": Key.choice_symbol,
"pointgroup": Key.point_group,
"site_symmetry_symbols": MbdKey.international_spg_name,
"wyckoffs": Key.wyckoff_symbols,
}

Expand All @@ -85,26 +84,26 @@ def analyze_symmetry(
)

for struct_key, struct in iterator:
cell = (struct.lattice.matrix, struct.frac_coords, struct.atomic_numbers)
# spglib 2.5.0 issues lots of warnings:
# - get_bravais_exact_positions_and_lattice failed
# - ssm_get_exact_positions failed
with warnings.catch_warnings():
warnings.filterwarnings(action="ignore", module="spglib")
sym_data = spglib.get_symmetry_dataset(
cell, symprec=symprec, angle_tolerance=angle_tolerance
)
cell = moyopy.Cell(
struct.lattice.matrix, struct.frac_coords, struct.atomic_numbers
)

sym_data = moyopy.MoyoDataset(
cell, symprec=symprec, angle_tolerance=angle_tolerance
)

if sym_data is None:
raise ValueError(f"spglib returned None for {struct_key}\n{struct}")

sym_ops = sym_data.operations

sym_info = {
new_key: getattr(sym_data, old_key)
for old_key, new_key in sym_key_map.items()
} | {
Key.n_sym_ops: len(sym_data.rotations),
Key.n_rot_syms: len(sym_data.rotations),
Key.n_trans_syms: len(sym_data.translations),
Key.n_sym_ops: sym_ops.num_operations(),
Key.n_rot_syms: len(sym_ops.rotations),
Key.n_trans_syms: len(sym_ops.translations),
}
results[struct_key] = sym_info | dict(
symprec=symprec, angle_tolerance=angle_tolerance
Expand Down
2 changes: 1 addition & 1 deletion site/src/routes/+page.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
let show_energy_only: boolean = false
// Default column visibility
let visible_cols = {
let visible_cols: Record<keyof ModelData['metrics'], boolean> = {
Model: true,
F1: true,
DAF: true,
Expand Down
4 changes: 4 additions & 0 deletions site/src/routes/tasks/geo-opt/geo-opt-readme.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
# MLFF Geometry Optimization Analysis

> Disclaimer: There is a caveat to the structure similarity analysis below. The WBM test set was generated using the `MPRelaxSet` which applies [`ISYM=2`](https://vasp.at/wiki/index.php/ISIF). This fixes the structure's symmetry. The MLFFs by contrast use the FIRE or LBFGS optimizers with no symmetry constraints. They may therefore in some cases relax to lower energy states with different symmetry. This is not a mistake of the model and so higher σ<sub>match</sub> (the percentage of structures with matching ML and DFT spacegroups) is not necessarily indicative of a better model. Thanks to Alex Ganose for pointing this out! Undiscovered lower energy structures in the relatively well-explored chemical systems covered by WBM and MP are not expected to be a common occurrence. Hence we believe this analysis still provides some signal so we left it on this secluded page.
All plots/metrics below evaluate the quality of MLFF relaxations for the 257k crystal structures in the [WBM test set](https://nature.com/articles/s41524-020-00481-6). Not all models were able to relax all structures (user/cluster error may explain some failures) but every model was evaluated on at least <slot name="min-relaxed-structures"/> relaxations.

Symmetry detection was performed with the excellent Rust library [`moyopy`](https://github.com/janosh/moyopy), a ~4x faster successor to the already outstanding [`spglib`](https://spglib.readthedocs.io).

<slot name="geo-opt-metrics-table"/>

> σ<sub>match</sub> / σ<sub>dec</sub> / σ<sub>inc</sub> denote the fraction of structures that retain, increase, or decrease the symmetry of the DFT-relaxed structure during MLFF relaxation. The match criterion is for the ML ground state to have identical spacegroup as DFT. For σ<sub>dec</sub> / σ<sub>inc</sub>, ML relaxation increased / decreased the set of symmetry operations on a structure. Note that the symmetry metrics are sensitive to the `symprec` value passed to `spglib` so we show results for multiple values. See the [`spglib` docs](https://spglib.readthedocs.io/en/latest/variable.html#symprec) and [paper](https://arxiv.org/html/1808.01590v2) for details.
Expand Down

0 comments on commit 93d1d5c

Please sign in to comment.