Skip to content

Commit

Permalink
Collect md steps (#380)
Browse files Browse the repository at this point in the history
* collect md steps node

* convert to python types

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
  • Loading branch information
PythonFZ and pre-commit-ci[bot] authored Dec 16, 2024
1 parent 351a543 commit c0b3efa
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 1 deletion.
2 changes: 2 additions & 0 deletions ipsuite/__init__.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ from .analysis import (
BoxHeatUp,
BoxScale,
CalibrationMetrics,
CollectMDSteps,
ConnectivityCheck,
DebugCheck,
DipoleHistogram,
Expand Down Expand Up @@ -168,6 +169,7 @@ __all__ = [
"ThresholdCheck",
"TemperatureCheck",
"AnalyseDensity",
"CollectMDSteps",
# Calculators
"CP2KSinglePoint",
"ASEGeoOpt",
Expand Down
3 changes: 2 additions & 1 deletion ipsuite/analysis/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
)
from ipsuite.analysis.bond_stretch import BondStretchAnalyses
from ipsuite.analysis.ensemble import ModelEnsembleAnalysis
from ipsuite.analysis.md import AnalyseDensity
from ipsuite.analysis.md import AnalyseDensity, CollectMDSteps
from ipsuite.analysis.model import (
BoxHeatUp,
BoxScale,
Expand Down Expand Up @@ -62,4 +62,5 @@
"ForcesUncertaintyHistogram",
"EnergyUncertaintyHistogram",
"AnalyseDensity",
"CollectMDSteps",
]
15 changes: 15 additions & 0 deletions ipsuite/analysis/md.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import zntrack

from ipsuite import base
from ipsuite.calculators.ase_md import ASEMD
from ipsuite.utils.ase_sim import get_density_from_atoms


Expand Down Expand Up @@ -36,3 +37,17 @@ def run(self):
}

self.results = pd.DataFrame(densities, columns=["density"])


class CollectMDSteps(base.IPSNode):
mds: list[ASEMD] = zntrack.deps()
metrics: dict = zntrack.metrics()

def run(self):
steps: list[int] = [x.steps_before_stopping for x in self.mds]

self.metrics = {
"total": int(np.sum(steps)),
"mean": float(np.mean(steps)),
"std": float(np.std(steps)),
}

0 comments on commit c0b3efa

Please sign in to comment.