Using two force field files

I am doing a mixed model calculation in LAMMPS with liquid and solid phases, and I don’t know how to create separate force field files for the liquid and solid phases and then do the mixed model calculation. I would like to know how to write the in.lj file when using two force field files.

Please have a careful look at: Please Read This First: Guidelines and Suggestions for posting LAMMPS questions

You need to provide more details about the kinds of systems and the kinds of force fields you are planning to use. Your post is far too vague and unspecific to provide any kind of meaningful and specific help. Ideally, you would have already done simulations with each of the two phases separately and thus could provide those input files.

Sorry. I am a new user and cannot upload files.

lammps.dat file

This file is created by Advance/NanoLabo.

 238  atoms

   4  atom types

0.00000000e+00 2.64355335e+01 xlo xhi
0.00000000e+00 5.29709900e+00 ylo yhi
0.00000000e+00 2.54652939e+01 zlo zhi
0.00000000e+00 1.04208143e+01 0.00000000e+00 xy xz yz


   1        1  5.449230e+00  4.336078e+00  1.272895e+01
   2        2  5.480979e+00  8.529571e-01  1.260544e+01
   3        2  4.470040e+00  4.438328e+00  1.010232e+01
   4        1  4.715425e+00  9.020166e-01  1.065572e+01
   5        1  3.782388e+00  4.436574e+00  8.308931e+00
   6        2  3.561453e+00  2.674154e+00  7.728994e+00
   7        1  2.880277e+00  2.661494e+00  5.949264e+00  # 0 0 0
   8        2  2.650179e+00  4.419161e+00  5.369706e+00  # 0 0 0
   9        3  1.296755e+00  8.951950e-01  2.037421e+00  # 0 0 0
  10        1  1.972274e+00  4.418965e+00  3.612498e+00  # 0 0 0
  11        2  1.745081e+00  8.763467e-01  3.046863e+00  # 0 0 0
  12        2  6.761083e+00  3.481732e+00  1.182477e+01



   1  0.000000e+00  0.000000e+00  0.000000e+00
   2  0.000000e+00  0.000000e+00  0.000000e+00
   3  0.000000e+00  0.000000e+00  0.000000e+00
   4  0.000000e+00  0.000000e+00  0.000000e+00
   5  0.000000e+00  0.000000e+00  0.000000e+00


   1  2.808550e+01 # Si
   2  1.201070e+01 # C
   3  1.007940e+00 # H
   4  5.199610e+01 # Cr

ffield.sannp file
3 1 0 0
20 20 6.50000000e+00 6.50000000e+00
2 30 5
Si 3.65877258e+02 1.70605737e+03 14
Cr 3.44785706e+02 1.63313916e+03 24
C 3.34970947e+02 1.56783032e+03 6
-7.84788609e-01 -1.39022911e+00 6.15251958e-01 2.94417429e+00 -2.55578017e+00 -2.65108919e+00 1.14814413e+00 7.88330287e-02

ffield1.sannp file
3 1 0 0
20 20 6.50000000e+00 6.50000000e+00
2 30 5
H 2.86325928e+02 1.32001953e+03 1
C 3.87274902e+02 1.80705176e+03 6
Si 3.73808289e+02 1.73813843e+03 14
2.71967918e-01 -1.96366459e-01 6.11558914e-01 4.61471468e-01 -1.13053598e-01 1.36757240e-01 -9.28981900e-01 1.14382744e+00

in.lj file

Defining the system

units metal
boundary s s s
atom_style atomic
read_data lammps.dat
pair_style nnp
group solid_atoms type 1 192
pair_coeff * * ffield1.sannp eatom zero Si H C
group solid_atoms dynamic all
group liquid_atoms type 193 238
pair_coeff * * ffield.sannp eatom zero Si Cr C
group liquid_atoms dynamic all
velocity all create 1873.0 15180

Statistical properties

reset_timestep 0
compute RDF all rdf 60 1 1 1 3 1 2 3 1 3 3 3 2 2 1 2 3 2 2 cutoff 6.0
#rdf 刻み幅の数値
#cutoff rdfの距離
fix rdfAve all ave/time 4135 1 4135 c_RDF[*] mode vector file lammps.rdf

ave/time N1 N2 N3

#N2は 平均の計算に入力値を使用する回数

compute md1 Si msd
#fix msd1 all ave/time 4135 1 4135 c_md1[*] file

compute md2 C msd
#fix msd2 all ave/time 4135 1 4135 c_md2[*] file

compute md1 C msd
#variable msdx equal c_md1[1]
#variable msdy equal c_md1[2]
#variable msdz equal c_md1[3]
#variable msd equal c_md1[4]
#variable istep equal step
#fix md1 all print 1 “{istep} {msdx} {msdy} {msdz} ${msd}” screen no file msd_C.dat

Setting for output

dump Dump all custom 1 tmpdir/lammps.dmp type x y z
thermo_style custom step time cpu pe ke etotal enthalpy temp press vol density cella cellb cellc cellalpha cellbeta cellgamma
thermo 1

Setting to run MD or minimization

>>> SCHEME-1

fix ensemble all nvt temp 1873.0 1873.0 2.0
#2.0は熱浴の順応性のパラメータ timestepの1000倍にしておく
timestep 2.41837968e-03
run 4135
unfix ensemble


The files you have copied are quite messy and difficult to read. They contain many information that are not related at all to the initial question. What are the two force fields you want to use? Have you looked at the examples here?


When I pasted the code, it automatically became cluttered.
Force field of NeuralMD with SiCCr for the liquid phase and SIC for the solid phase.
Which example should I look at?

man, you have to make the effort to read the posting guidelines.


Pair style nnp is not part of LAMMPS, so we don’t know anything about it. You have to ask the authors of this pair style. It looks like a machine learning potential. Those may or may not support using pair style hybrid. You will certainly not be able to use a single pair style of that kind for two potential files. However, using multiple instances of the same pair style as part of pair style hybrid has multiple restrictions and requirements.

This looks very odd and is not likely to work for even this one subset. You have 192 atom types, but your pair_coeff line only maps the first 3 of them to elements in the pair style. That line already will give you an error (unless the nnp pair style is buggy).

this is the same issue as before.

For using pair style hybrid efficiently, you need to set up your system in the following way:
atom type 1 would be Si atoms of the solid, atom type 2 H atoms of the solid, and type 3 C atoms of the solid, atom type 4 Si atoms of the liquid, atom type 4 Cr atoms of the liquid, and atom type 6 the C atoms of the liquid. That requires to generate your data file accordingly.

With that setup, you can use the nnp pair style for each subsystem, but you now still need a potential that can describe the pairwise interactions between all pairs of atom types between the two subsystems, e.g. via pair style lj/cut or morse. Assuming lj/cut, your force field setup would have to look like this:

pair_style hybrid nnp nnp lj/cut 12.0
pair_coeff nnp 1 * * ffield1.sannp eatom zero Si H C NULL NULL NULL
pair_coeff nnp 2 * * ffield.sannp eatom zero NULL NULL NULL Si Cr C
pair_coeff lj/cut 1 4 ...
pair_coeff lj/cut 2 4 ...
pair_coeff lj/cut 3 4 ...
pair_coeff lj/cut 1 5 ...
pair_coeff lj/cut 2 5 ...
pair_coeff lj/cut 3 5 ...
pair_coeff lj/cut 1 6 ...
pair_coeff lj/cut 2 6 ...
pair_coeff lj/cut 3 6 ...

Of course, instead of ‘…’ you need to provide suitable epsilon and sigma parameters for the elements.
There are a couple of big caveats with this kind of setup:

  • the nnp pair style has to be programmed to support being used with pair style hybrid and being used with it multiple times. Few such machine learning pair styles outside of LAMMPS are compatible with the first requirement and fewer with the second (and even for ML pair styles included in LAMMPS not all are compatible).
  • the system has to be set up in such a way that the error from using a pairwise potential for the “cross-subsystem” interactions is small. This is not always the case.

Thank you.
What procedure should be used to determine the appropriate parameter settings for the pair_coeff command?

Like with any interaction: you have to search the published literature to find something suitable for your system or failing that learn how to parameterize yourself.