Topology file error

GROMACS version: 2024.1-Homebrew
GROMACS modification: No
Here post your question: Hi, I am a new user trying to simulate 2 LJ spheres but am having trouble with the topology file. I am getting the error “Molecule type ‘LJ1’ contains no atoms”

Gro file (had trouble formatting it; ended up using openmm to make a pdb then converting it to a gro file with gmx editconf):
LJ Spheres
2
1LJ LJ1 1 0.100 0.000 0.000
2LJ LJ2 2 0.400 0.000 0.000
3.00000 3.00000 3.00000

Top file currently:
; Lennard-Jones spheres topology

[ defaults ]
; nbfunc comb-rule gen-pairs fudgeLJ fudgeQQ
1 1 no 1.0 1.0

[ atomtypes ]
; name mass charge ptype sigma epsilon
LJ1 1.0 0.0 A 0.34 0.996
LJ2 1.0 0.0 A 0.34 0.996

[ moleculetype ]
; name nrexcl
LJ1 1
LJ2 1

[ atoms ]
; nr type resnr residue atom cgnr charge mass
1 LJ1 1 LJ1 LJ1 1 0.0 1.0
2 LJ2 2 LJ2 LJ2 1 0.0 1.0

[ system ]
; Name
Lennard-Jones Spheres

[ molecules ]
; Compound nmols
LJ1 1
LJ2 1

I have also tried separating the sections for each particle type:
; Lennard-Jones spheres topology

[ defaults ]
; nbfunc comb-rule gen-pairs fudgeLJ fudgeQQ
1 1 no 1.0 1.0

[ atomtypes ]
; name mass charge ptype sigma epsilon
LJ1 1.0 0.0 A 0.34 0.996

[ moleculetype ]
; name nrexcl
LJ1 1

[ atoms ]
; nr type resnr residue atom cgnr charge mass
1 LJ1 1 LJ1 LJ1 1 0.0 1.0

[ atomtypes ]
; name mass charge ptype sigma epsilon
LJ2 1.0 0.0 A 0.34 0.996

[ moleculetype ]
; name nrexcl
LJ1 1
LJ2 1

[ atoms ]
; nr type resnr residue atom cgnr charge mass
2 LJ2 2 LJ2 LJ2 1 0.0 1.0

[ system ]
; Name
Lennard-Jones Spheres

[ molecules ]
; Compound nmols
LJ1 1
LJ2 1

But get ‘invalid order for directive atomtypes’ error

All atom types must be defined before any atoms (like in your first example). Molecule types must be defined separately and one at a time.
Try

; Lennard-Jones spheres topology

[ defaults ]
; nbfunc comb-rule gen-pairs fudgeLJ fudgeQQ
1 1 no 1.0 1.0

[ atomtypes ]
; name mass charge ptype sigma epsilon
LJ1 1.0 0.0 A 0.34 0.996
LJ2 1.0 0.0 A 0.34 0.996

[ moleculetype ]
; name nrexcl
LJ1 1

[ atoms ]
; nr type resnr residue atom cgnr charge mass
1 LJ1 1 LJ1 LJ1 1 0.0 1.0

[ moleculetype ]
; name nrexcl
LJ2 1

[ atoms ]
; nr type resnr residue atom cgnr charge mass
1 LJ2 1 LJ2 LJ2 1 0.0 1.0

[ system ]
; Name
Lennard-Jones Spheres

[ molecules ]
; Compound nmols
LJ1 1
LJ2 1

or you can manage with one atom type:

; Lennard-Jones spheres topology

[ defaults ]
; nbfunc comb-rule gen-pairs fudgeLJ fudgeQQ
1 1 no 1.0 1.0

[ atomtypes ]
; name mass charge ptype sigma epsilon
LJ 1.0 0.0 A 0.34 0.996

[ moleculetype ]
; name nrexcl
LJ1 1

[ atoms ]
; nr type resnr residue atom cgnr charge mass
1 LJ 1 LJ1 LJ1 1 0.0 1.0

[ moleculetype ]
; name nrexcl
LJ2 1

[ atoms ]
; nr type resnr residue atom cgnr charge mass
1 LJ 1 LJ2 LJ2 1 0.0 1.0

[ system ]
; Name
Lennard-Jones Spheres

[ molecules ]
; Compound nmols
LJ1 1
LJ2 1

Thank you!