From 6aad6d82c555187d7def2ca44cde91b309a751e1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Franz=20P=C3=B6schel?= Date: Thu, 30 May 2024 10:58:27 +0200 Subject: [PATCH] Add bug.py --- examples/bug.py | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100755 examples/bug.py diff --git a/examples/bug.py b/examples/bug.py new file mode 100755 index 000000000..28be650b2 --- /dev/null +++ b/examples/bug.py @@ -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) \ No newline at end of file