ACEsuit / mace

MACE - Fast and accurate machine learning interatomic potentials with higher order equivariant message passing.
Other
412 stars 155 forks source link

First experiment using lammps with a pretrained potential (mace mp0) #473

Open nihil39 opened 1 week ago

nihil39 commented 1 week ago

Hi,

I am trying to run my first simulation of bulk water using the potential derived from the mace mp0 model. I followed the guide and successfully generated the model for lammps with the provided script.

I compiled lammps with the MOLECULE package enabled

with the following command

git clone --branch mace --depth=1 https://github.com/ACEsuit/lammps
cd lammps; mkdir build; cd build
cmake -DCMAKE_INSTALL_PREFIX=$(pwd) \
      -D CMAKE_CXX_STANDARD=17 \
      -D CMAKE_CXX_STANDARD_REQUIRED=ON \
      -D BUILD_MPI=ON \
      -D BUILD_OMP=ON \
      -D PKG_OPENMP=ON \
      -D PKG_ML-MACE=ON \
      -D PKG_MOLECULE=ON \
      -D CMAKE_PREFIX_PATH=$(pwd)/../../libtorch \
      ../cmake
make -j 4
make install

But when I try to run this script I got this error

ERROR: Unrecognized atom style ‘full’ is part of the MOLECULE package which is not enabled in this LAMMPS binary. (src/atom.cpp:751)
Last command: atom_style full

But I compiled lammps with the MOLECULE package enabled. Note that that scripts (with a standard LJ potential) works fine with the standard lammps version compiled with the MOLECULE package.

In general, is there an example to run a simulation of bulk water with lammps using a potential derived form the pretrained MACE mp0 model?

Thank you

wcwitt commented 1 week ago

Can you try 'atom_style atomic'?

nihil39 commented 1 week ago

Can you try 'atom_style atomic'?

Thanks, I tried and It kinda works. I forgot to update the question.

If I understand correctly, atomic is the style to be used because it is useless to explicitly define bonds and angle between atoms in molecules using this kind of potentials. Maybe I am wrong but if MACE mp0 is trained on potential coming DFT calculations, so an ab initio method, after a number of iterations, water molecules should "form" only because of the potential, without the need of explicitly fixing distances, bonds, etc.

I tried the following two scripts and it works, the problem is that it is apparently too slow and it segfaults for lack of memory I think, but I'm just trying on a small laptop with 16 GB of RAM...

Lammps input

Initial configuration

wcwitt commented 1 week ago

Does it work on your laptop for a smaller system? Try the smallest that is reasonable.

nihil39 commented 1 week ago

Does it work on your laptop for a smaller system? Try the smallest that is reasonable.

I tried with a 64 molecules systems, so small enough I think but I have still some segfaults problems.

This is the initial configuration, it is a water system that should be equilibrated

https://dpaste.org/Jr81n

This is the error:

https://dpaste.org/JYVtB

This it the lammps input script:

https://dpaste.org/nEPBU

I tried with both domain decomposition and with no domain decomposition.

Can you try and see if I'm doing something wrong? Thank you.

wcwitt commented 1 week ago

I've tried your example and reproduced similar errors. As best I can tell, the main issue is that you are using a gigantic timestep (1 ps). Try something closer to 1 fs.

nihil39 commented 5 days ago

I've tried your example and reproduced similar errors. As best I can tell, the main issue is that you are using a gigantic timestep (1 ps). Try something closer to 1 fs.

Thanks, that was the problem. With a timestep of 0.001 (1 fs) it seems to work.

Another question: I'm running it on a cluster with four Intel(R) Xeon(R) Gold 6252N CPU @ 2.30GHz cpus. I found that the simulation still crashes if I run it with more than one processor, for example with mpirun -np 2 lmp but I have to experiment more.

The best performances are obtained with running a job with just one mpi process but using a large number of threads (96 for example setting the env variable with export OMP_NUM_THREADS=96) without domain decomposition, just following the lammps mace documentation. With this setting it takes 25 seconds to compute 1 timestep for a system of 125 water molecules starting from an equilibrated configuration using the mace mp0 L1 model. Is it normal to get this results?

By the way the next task is trying to compile the GPU version to run on my modest Nvidia RTX 3060Ti 8 GB on my Arch Linux system :-)