[lammps-users] difficulty using molecule command to add a molecule

Hi,

I am having a lot of difficulty adding a molecule to an already-existing simulation. I have tried my best to read the documentation and follow examples. I have also done this before succesfully with a more simple molecule (hydrogen gas), so I am perplexed with the current problems.

I am running the 7 Aug 2019 version of LAMMPS; I’d like to keep this version since that’s what I used for the previous simulations but I could change if needed. I get the same error from the 3 March 2020 version.

I am trying to add a molecule to, e.g., a box of water. I first run a short simulation on the box of water, with no problems. Then I use a molecule template to add 1 molecule at random into the box. I get a warning and an error:

WARNING: Molecule attributes do not match system attributes (…/molecule.cpp:1386)

ERROR: Molecule topology/atom exceeds system topology/atom (…/molecule.cpp:1415)

I have specified the needed number of extra types, bonds, angles, etc. I have tried doing this in various ways. I don’t seem to succeed in any case. I have attached my molecule template and input script below.

Thanks,

Amalie

Here’s the molecule file:

Zincate

9 atoms

8 bonds

10 angles

Coords

1 -1.603907 1.211837 -0.272400

2 -2.219043 0.545670 0.077819

3 -0.015670 0.068918 -0.020661

4 -0.707721 -1.625115 0.801466

5 -0.391026 -2.153992 0.049244

6 0.932809 -0.511747 -1.667599

7 1.807081 -0.231367 -1.348724

8 1.412678 0.761188 1.181746

9 1.259616 0.068276 1.846429

Types

1 3

2 4

3 5

4 2

5 3

6 2

7 3

8 2

9 3

Charges

1 -1.0027

2 0.2838

3 0.8756

4 -1.0027

5 0.2838

6 -1.0027

7 0.2838

8 -1.0027

9 0.2838

Masses

1 15.9994

2 1.0078

3 65.4

4 15.9994

5 1.0078

6 15.9994

7 1.0078

8 15.9994

9 1.0078

Bonds

1 1 1 2

2 2 1 3

3 2 3 4

4 2 3 6

5 2 3 8

6 1 4 5

7 1 6 7

8 1 8 9

Angles

1 1 2 1 3

2 1 5 3 4

3 1 7 3 6

4 1 9 3 8

5 2 1 3 4

6 2 1 3 6

7 2 1 3 8

8 2 4 3 6

9 2 4 3 8

10 2 6 3 8

Here’s the lammps input file; the data file is just a simple box of water.

Variable definitions

variable project index “wat”

Initialization

units real

atom_style full

pair_style lj/cut/coul/long 10.0 10.0

bond_style harmonic

angle_style harmonic

dihedral_style opls

special_bonds lj/coul 0.0 0.0 0.5 dihedral no

System

read_data water.data extra/atom/types 3 extra/bond/types 2 extra/angle/types 2 extra/special/per/atom 20

pair_modify tail no

kspace_style pppm 1.e-4

mass 3 15.999

mass 4 1.0078

mass 5 65.4

pair_coeff 1 1 0.1554 3.16557 # ow, ow

pair_coeff 1 2 0.0 2.0614 # ow, hw

pair_coeff 2 2 0.0 0.9572 # hw, hw

pair_coeff 3 3 0.2104 3.0664 # amber

pair_coeff 4 4 0.0 0.0

pair_coeff 5 5 0.0007549 2.0989 # amber

Bond Coeffs

bond_coeff 1 600.00000 0.95720 # ow4,hw

bond_coeff 2 700 1.0

bond_coeff 3 700 1.96

Angle Coeffs

angle_coeff 1 75.00000 109.50000 # hw,ow4,hw

angle_coeff 2 1000 94.19

angle_coeff 3 1000 109.47

variable TK equal 300.0

variable PBAR equal 1.0

group wat type 1 2

Settings

neighbor 1.0 bin

neigh_modify delay 0 every 1 check yes

velocity all create 300 3189434 dist gaussian rot yes mom yes sum yes

timestep 1.0

thermo_style custom step temp pe etotal press vol density

thermo 500

thermo_modify flush yes

keep water rigid

fix watsh wat shake 0.0001 20 0 b 1 a 1

fix TPSTAT all npt temp {TK} {TK} 100 iso {PBAR} {PBAR} 1000

dump TRAJ all custom 20000 wat.lammpstrj id mol type element x y z ix iy iz

restart 1000000 wat.rst

run 1000

add zincate

molecule zincate zincate.template toff 0 boff 1 aoff 1

region cell block EDGE EDGE EDGE EDGE EDGE EDGE

create_atoms 0 random 1 225698 cell mol zincate 13546

run 10000

write_restart restart.*.lmp

write_data data.*.lmp

You get the warning because your molecule file has per-atom masses, while your atom style full uses per-atomtype masses and thus the molecule file should not have a Masses section. The masses will be set by the data file or the mass command or both.

While you have added space for additional types, you also need to reserve space to actually store bonds and angles. In LAMMPS that information is stored with individual atoms. With newton bond on (the default) each bond, angle, dihedral or improper is stored by default with one of its constituent atoms. The read_data command will use the minimal amount suitable with the topology contained in the data file (for water molecules, those will be 2 bonds, 1 angle, and 2 special neighbors per atom). You get the error because your molecule file requires more space, most certainly more special neighbors.

Thanks very much, that clarified the information storage issues for me, and I got my script to work.

Best regards,

Amalie