Skip to content

Commit

Permalink
Add bug.py
Browse files Browse the repository at this point in the history
  • Loading branch information
franzpoeschel committed May 30, 2024
1 parent 7e97cce commit c92f983
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions examples/bug.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import os
from ase.io import read
import mala
from mala.datahandling.data_repo import data_repo_path
data_path = os.path.join(data_repo_path, "Be2")

# Trigger LAMMPS by performing inference on an atomic snapshot.
parameters, network, data_handler, predictor = mala.Predictor.\
load_run("be_model", path="basic")
atoms = read(os.path.join(data_path, "Be_snapshot3.out"))
ldos = predictor.predict_for_atoms(atoms)
ldos_calculator: mala.LDOS = predictor.target_calculator
ldos_calculator.read_from_array(ldos)

# Test OpenPMD.
params = mala.Parameters()
ldos_calculator = mala.LDOS. \
from_numpy_file(params,
os.path.join(data_path,
"Be_snapshot1.out.npy"))
ldos_calculator. \
read_additional_calculation_data(os.path.join(data_path,
"Be_snapshot1.out"),
"espresso-out")

# Write and then read in via OpenPMD and make sure all the info is
# retained.
# for key, val in os.environ.items():
# print("\t{}:{}".format(key, val))
ldos_calculator.write_to_openpmd_file("test_openpmd.bp4",
ldos_calculator.
local_density_of_states)

0 comments on commit c92f983

Please sign in to comment.