Assistance with Water Molecule Coordination in LAMMPS

Dear LAMMPS Community,

I am a new user and an Energy Master’s student, currently working on a project involving LAMMPS simulations. I am trying to model a box of water molecules using the SPC/E model but have encountered a coordination issue while defining the water molecule in my input file. Specifically, I am facing an error related to the Coords section of my h2o.dat file.
ERROR: Invalid line in Coords section of molecule file (src/molecule.cpp:733)
Here’s the content of my h2o.dat file:

SPC/E water molecule for LAMMPS - Single H2O molecule

3 atoms
2 bonds
1 angles

Coords section

Coords
1 0.000000 0.000000 0.000000 # Oxygen at the origin
2 0.957200 0.000000 0.000000 # Hydrogen 1 along the x-axis (bond length 0.9572 Å)
3 -0.239000 0.927300 0.000000 # Hydrogen 2 at an angle from Oxygen, 104.52° between H1-O-H2

Types section

Types
1 2
2 3
3 3

Charges section

Charges
1 -0.8476 # Oxygen charge
2 0.4238 # Hydrogen 1 charge
3 0.4238 # Hydrogen 2 charge

Bonds section

Bonds
1 1 1 2 # Bond 1 between Oxygen and Hydrogen 1
2 1 1 3 # Bond 2 between Oxygen and Hydrogen 2

Angles section

Angles
1 1 2 1 3 # H-O-H bond angle

I would greatly appreciate any guidance or advice on resolving this issue.
Thank you in advance for your help!

You can refer to the sample file in the how-to section 10.4.7. SPC and SPC/E water model — LAMMPS documentation and compare with yours.

Notably:

  1. there must be exactly one empty line between the “Coords” line and the coordinates (this rule applies to other sections too). e.g. the following two examples would error:
Coords
1 0.000000 0.000000 0.000000 # ERROR: Invalid line in Coords section of molecule file 
2 0.957200 0.000000 0.000000
3 -0.239000 0.927300 0.000000
Coords


1 0.000000 0.000000 0.000000 # ERROR: Unexpected line in molecule file while looking for the next section:
2 0.957200 0.000000 0.000000
3 -0.239000 0.927300 0.000000
  1. there are apparently some limitations about inserting comments at the beginning of a line. For example, the following example would error:
Coords

1 0.000000 0.000000 0.000000
2 0.957200 0.000000 0.000000
3 -0.239000 0.927300 0.000000

# do not insert comments here (ERROR: Create_atoms molecule must have atom types)
Types

1 1
2 2
3 2

I would say avoid inserting comments at the beginning of lines (except the very first line).

The examples above are tested with 10 Sep 2025.

1 Like

In addition, I would avoid adding comments that state the obvious in the first place.

This is not the SPC/E geometry as advertised in the title line. SPC/E has 1.0 Å and 109.47°

Yet, these charges are the SPC/E charges.