Skip to content

Commit

Permalink
basic/ex05: skip if total_energy not found
Browse files Browse the repository at this point in the history
We do this in test/workflow_test.py, so seems sensible to do it here as well.
  • Loading branch information
elcorto committed Mar 18, 2024
1 parent ae659f0 commit 6c48669
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions examples/basic/ex05_run_predictions.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import os
from importlib.util import find_spec

from ase.io import read
import mala
Expand All @@ -13,7 +14,7 @@
Show how a prediction can be made using MALA, based on only a
trained network and atomic configurations.
REQUIRES LAMMPS (and potentiall the total energy module).
REQUIRES LAMMPS (and potentially the total energy module).
"""


Expand All @@ -37,7 +38,11 @@
ldos_calculator: mala.LDOS = predictor.target_calculator
ldos_calculator.read_from_array(ldos)
printout("Predicted band energy: ", ldos_calculator.band_energy)

# If the total energy module is installed, the total energy can also be
# calculated.
# parameters.targets.pseudopotential_path = data_path
# printout("Predicted total energy", ldos_calculator.total_energy)
if find_spec("total_energy"):
parameters.targets.pseudopotential_path = data_path
printout("Predicted total energy", ldos_calculator.total_energy)
else:
print("total_energy module not found, skipping total energy calculation")

0 comments on commit 6c48669

Please sign in to comment.