bytedance / bamboo

BAMBOO (Bytedance AI Molecular BOOster) is an AI-driven machine learning force field designed for precise and efficient electrolyte simulations.
GNU General Public License v2.0
27 stars 5 forks source link

Pure Python example for prediction #7

Open mhellstr opened 2 weeks ago

mhellstr commented 2 weeks ago

It would be helpful/instructive if there was a pure Python example that does not rely on LAMMPS for prediction.

For example, how could I use benchmark.pt to get energy/forces/stress of a single structure if I have numpy arrays with atomic numbers, coordinates, lattice vectors?

muzhenliang commented 1 week ago

You can load model by:



m = torch.jit.load("path/to/model.pt")

data = {"input": "your_input_data[in format torch tensor]"}

# Required keys:
# edge_index: [2, Ne].
# edge_cell_shift: [Ne, 3]. Unit: Angstrom
# coul_edge_index: [2, Ne_coul]. 
# coul_edge_cell_shift: [Ne_coul, 3]. Unit: Angstrom
# disp_edge_index: [2, Ne_disp]. 
# disp_edge_cell_shift: [Ne_disp, 3]. Unit: Angstrom
# atom_types: [Na]. torch.long
# cell: [3, 3]. Unit: Angstrom. None or negative means non-PBC
# g_ewald: [1]. g_ewald parameter in LAMMPS, could be 1.0 for test

pred = m.forward(data)

# pred is the output of the model```
mhellstr commented 1 week ago

Thanks, but I guess the question is how would I know how to populate edge_index, edge_cell_shift, etc. ?