Issue with Combining MACE ML Potential and Dispersion Corrections Using pair_style hybrid/overlay

Dear LAMMPS users,
I’m encountering an issue when trying to combine the MACE machine learning potential with dispersion corrections through the pair_style hybrid/overlay command. The MACE potential works fine on its own. I compiled my version of LAMMPS by following the instructions on the MACE website (MACE in LAMMPS — mace 0.3.12 documentation), and I have a working LAMMPS installation that can use the MACE potential.

Unfortunately, this LAMMPS fork does not include the necessary routines for dispersion corrections, but I hope that future versions will support them natively.

As a workaround, I manually copied the last version of the files pair_dispersion_d3.cpp and pair_dispersion_d3.h into the EXTRA-PAIR folder and recompiled LAMMPS to include that package. However, when I try to use the pair_style hybrid/overlay command to combine the ML potential with dispersion corrections, I encounter the following error:

ERROR: Pair_style dispersion/d3 needs 4 arguments (src/EXTRA-PAIR/pair_dispersion_d3.cpp:133)
Last command: pair_style hybrid/overlay mace no_domain_decomposition dispersion/d3 zero pbe 40.0 20.0

Here is the code I’m using to simulate a box of water molecules:

####################################################################
# Initialization
####################################################################

units real
boundary p p p
atom_style atomic
atom_modify map yes
newton on

####################################################################
# Atom definition
####################################################################

read_data water.data
replicate 2 2 2

mass 1 1.00794      # Hydrogen
mass 2 15.9994      # Oxygen

group hydrogen type 1
group oxygen type 2

####################################################################
# Settings: force field, simulation parameters, output options
####################################################################

pair_style hybrid/overlay mace no_domain_decomposition dispersion/d3 zero pbe 40.0 20.0
#pair_style mace no_domain_decomposition    # ML potential works alone
pair_coeff * * small.model-lammps.pt H O

timestep 1.0

### output options
thermo_style custom step temp etotal pe ke 
thermo 50
log log.prod

####################################################################
# Run simulations
####################################################################

### Simulation 1: Equilibration run by rescaling velocities

# initial velocities following distribution of 300 K
velocity all create 300.0 1234

fix  integrate all nve
fix  rescaling all temp/rescale 1 300.0 300.0 0.05 1.0
fix  removeMomentum all momentum 1 linear 1 1 1

run 500

### Simulation 2: Langevin dynamics

unfix rescaling
unfix removeMomentum
fix 1 all langevin 300.0 300.0 100.0 48279

run 1000

The problem is in the keyword “zero”. In recent versions of LAMMPS, this keyword has been renamed to “original”. pair_style dispersion/d3 command — LAMMPS documentation

The reason for that is that the hybrid pair styles split the list of arguments on known names of pair styles. As it happens, “zero” is a valid pair style, so the argument list assumes 3 instead of 2 sub-styles and becomes:

  • mace no_domain_decomposition
  • dispersion/d3
  • zero pbe 40.0 20.0

Please see the previous discussion of the same issue.

1 Like

Thank you very much for your help, Axel.
When I tried to compile the dispersion/d3 feature using the latest version (lammps/src/EXTRA-PAIR/pair_dispersion_d3.cpp at 6372178caa3270752f56284cd10bfc9a7863f6f3 · lammps/lammps · GitHub), I encountered a strange error:

error: src/extra-pair/pair_dispersion_d3.cpp(299): class LAMMPS_NS::Error has no member 'NOLASTLINE'

and was unable to compile.
Instead, I used an older version of the dispersion feature
(lammps/src/EXTRA-PAIR/pair_dispersion_d3.cpp at f0bc9ddcc983b146f589568ee2381cb7e62454c9 · ACEsuit/lammps · GitHub), which compiled successfully. I then edited pair_dispersion_d3.cpp and replaced the "zero" keyword with "original" to avoid naming conflicts.

Everything is working now. I hope that in the future, the MACE fork of LAMMPS can be brought in line with the latest versions.

Again, thank you very much for your invaluable help.