ERROR: Must use consistent type to element mappings with threebody off

Hey all,

I am trying to simulate a system in which I want to use a hybrid of stillinged weber potential with three body on and off. I am using LAMMPS (2 Aug 2023 - Update 2). I have three atom types. I set up the non-bonded interactions in the following way:

# set non bonded interactions
pair_style          hybrid sw threebody on sw threebody off
# three body interactions (OH-OH-OH,mW-mW-mW)
pair_coeff          * * sw 1 params.sw NULL OH NULL
pair_coeff          * * sw 1 params.sw NULL NULL MW
# two body interations (CH3-CH3,CH3-OH,CH3-mW)
pair_coeff          1 1 sw 2 params.sw CH3  CH3 CH3
pair_coeff          1 2 sw 2 params.sw CH3  OH  OH
pair_coeff          1 3 sw 2 params.sw CH3  MW  MW

The aim here should be clear from the comments. The params.sw file that I use is also included here:

#    Three       body      set                                                                                                                   
OH  OH    OH   6.189  2.3925  1.8  23.15  1.20  -0.333333  7.049556277  0.6022245584  4.0  0.0  0.0
MW  MW    MW   6.189  2.3925  1.8  23.15  1.20  -0.333333  7.049556277  0.6022245584  4.0  0.0  0.0
#   Only  Two  body                                                                             
CH3  CH3         CH3       2.601770907  3.668729141  1.8  0.000  0.00  0.000000  7.049556277  0.6022245584  4.0  0.0  0.0
CH3  OH          OH        1.367038049  5.36308005   1.8  0.000  0.00  0.000000  7.049556277  0.6022245584  4.0  0.0  0.0
CH3  MW          MW        1.367038049  5.36308005   1.8  0.000  0.00  0.000000  7.049556277  0.6022245584  4.0  0.0  0.0
OH   CH3         CH3       1.367038049  5.36308005   1.8  0.000  0.00  0.000000  7.049556277  0.6022245584  4.0  0.0  0.0
MW   CH3         CH3       1.367038049  5.36308005   1.8  0.000  0.00  0.000000  7.049556277  0.6022245584  4.0  0.0  0.0
#    Irrelevant  (ignored  by           LAMMPS)                                                                       
CH3  CH3  OH   1.367038049  5.36308005   1.8  0.000  1.20  -0.333333  7.049556277  0.6022245584  4.0  0.0  0.0
CH3  CH3  MW   1.367038049  5.36308005   1.8  0.000  1.20  -0.333333  7.049556277  0.6022245584  4.0  0.0  0.0
CH3  OH   CH3  2.601770907  3.668729141  1.8  0.000  0.00  0.000000   0.000000000  0.0000000000  4.0  0.0  0.0
CH3  MW   CH3  2.601770907  3.668729141  1.8  0.000  0.00  0.000000   0.000000000  0.0000000000  4.0  0.0  0.0
OH   OH   CH3  1.367038049  5.36308005   1.8  0.000  1.20  -0.333333  7.049556277  0.6022245584  4.0  0.0  0.0
MW   MW   CH3  1.367038049  5.36308005   1.8  0.000  1.20  -0.333333  7.049556277  0.6022245584  4.0  0.0  0.0
OH   CH3  OH   6.189        2.3925       1.8  23.15  1.20  -0.333333  7.049556277  0.6022245584  4.0  0.0  0.0
MW   CH3  MW   6.189        2.3925       1.8  23.15  1.20  -0.333333  7.049556277  0.6022245584  4.0  0.0  0.0

I am getting the error:

ERROR: Must use consistent type to element mappings with threebody off (src/src/MANYBODY/pair_sw.cpp:301)
Last command: pair_coeff          1 2 sw 2 params.sw CH3  OH  OH

From what I read from the documentation and the example file in GH, the two body terms are in the line ikk. However, it is not clear to me how exactly should the element-to-type and type-to-element information should be used in the pair_coeff command.

Why does this line work: pair_coeff 1 1 sw 2 params.sw CH3 CH3 CH3 but the next one does not work.

PS: Edit was to add more information.

Since your atom type 1 corresponds to CH3, atom type 2 to OH and atom type 3 to MW, these lines should read

pair_coeff          1 1 sw 2 params.sw CH3  OH MW
pair_coeff          1 2 sw 2 params.sw CH3  OH MW
pair_coeff          1 3 sw 2 params.sw CH3  OH MW

Otherwise the you will get the error message you quoted.

Because this is the first command for the sw instance with threebody off and that sets the reference to which all others for the same substyle are compared.

Update:
Just made a test and noticed that the parameter file is missing some permutations for the pair_coeff commands I listed. You can use this instead:

# set non bonded interactions
pair_style          hybrid sw threebody on sw threebody off sw threebody off
# three body interactions (OH-OH-OH,mW-mW-mW)
pair_coeff          * * sw 1 params.sw NULL OH NULL
pair_coeff          * * sw 1 params.sw NULL NULL MW
# two body interactions
pair_coeff          1 1 sw 2 params.sw CH3 OH NULL
pair_coeff          1 2 sw 2 params.sw CH3 OH NULL
pair_coeff          1 3 sw 3 params.sw CH3 NULL MW

Hey Alex,

Your script works perfectly. Thank you so very much for the explaination about the ordering. I am not fully sure why three pair_styles are required, but I will take a look at the files closely.

Thank you once again.

This is because the Stillinger-Weber potential file you have does not contain settings for all permutations of the three elements. Even if you are only using twobody interactions, the code that is reading the potential file does not now this and thus requires additional entries with all the permutations of three-body terms. As the comment indicates, those will be read and stored but not used with “treebody off”.

This is all rather complex because the “threebody off” option has been added only recently and it had to be done in a way to retain all the functionality for “threebody on”.

1 Like