Closed lan496 closed 1 week ago
Hi @mkhorton, This PR aims to enhance the performance of AflowPrototypeMatcher
with a similar approach to StructureMatcher.group_structures
(see https://github.com/materialsproject/pymatgen/pull/2490). It might be of interest to you. Could you please review this PR?
Merged. Thanks,
Summary
The
AflowPrototypeMatcher
matches a structure against predefined AFLOW prototype structures usingStructureMatcher
.StructureMatcher
requires preprocessing via lattice reduction and primitive-cell conversion. This commit optimizes performance by preprocessing AFLOW prototype structures during the initialization ofAflowPrototypeMatcher
. This change eliminates redundant processing whenAflowPrototypeMatcher.get_prototypes
is called multiple times.Benchmark
I have checked the performance change by the following script, which calls
AflowPrototypeMatcher
with diamond-Si by 10 times.The current master branch takes 20.4 s in total.
StructureMatcher._get_reduced_structure
takes most of the computational time.This PR takes 2.48 s for the same workload. Now, the heavy primitive-cell conversion is called only once.
These profiles are generated with cProfile and SnakeViz as follows
Checklist
ruff
.mypy
.duecredit
@due.dcite
decorators to reference relevant papers by DOI (example)Tip: Install
pre-commit
hooks to auto-check types and linting before every commit: