diff --git a/matbench_discovery/structure.py b/matbench_discovery/structure.py index 4c5c02b4..0f850320 100644 --- a/matbench_discovery/structure.py +++ b/matbench_discovery/structure.py @@ -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. @@ -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, } @@ -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 diff --git a/site/src/routes/+page.svelte b/site/src/routes/+page.svelte index 382c8d26..26203370 100644 --- a/site/src/routes/+page.svelte +++ b/site/src/routes/+page.svelte @@ -10,7 +10,7 @@ let show_energy_only: boolean = false // Default column visibility - let visible_cols = { + let visible_cols: Record = { Model: true, F1: true, DAF: true, diff --git a/site/src/routes/tasks/geo-opt/geo-opt-readme.md b/site/src/routes/tasks/geo-opt/geo-opt-readme.md index 2245ab86..9eb953e1 100644 --- a/site/src/routes/tasks/geo-opt/geo-opt-readme.md +++ b/site/src/routes/tasks/geo-opt/geo-opt-readme.md @@ -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 σmatch (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 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). + > σmatch / σdec / σinc 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 σdec / σinc, 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.