Add different atom types with read_data command

Dear all,

I wanna add carbon atoms into water box previously relaxed. Hereby, I followed LAMMPS documents for read_data command. Could you please write any command what is the problem that I got error to use it?
For more details, I attached the input and data files.

read_data cc.data append extra/atom/types 1 extra/bond/types 1 offset 3 1 0 0 0 group cnt

config2.in (2.4 KB)
config.data (1.6 MB)
cc.data (25.7 KB)

Please see the section about reading multiple data files in the documentation for the read_data command — LAMMPS documentation

That section contains the important statement:

The extra keywords can only be used the first time the read_data command is used.

So getting an error for your command is documented and expected behavior.

Thanks @akohlmey for your comments and guidelines. So, it’s necessary to define the Max number of atom types when the system is first initializing.
Hereby, I tell LAMMPS with the first read_data command that I have one additional atom type (extra/atom/types 1). Also, I defined Max number of atom type and their masses in the first data file. But I don’t know why do I get the following error regarding not finding carbon mass?

ERROR: Not all per-type masses are set (src/velocity.cpp:60)

Attached files are the modified input and data files.
config2.in (2.4 KB)
config.data (1.6 MB)
cc.data (25.7 KB)

Obviously, because it hasn’t been set by the time this error happens.

But, I do not use this additional atom type at first run of my input file. I just defined it to let LAMMPS know I wanna add one additional type at second run of my input file.

Hereby, Since the error took place at velocity command, is it means that the problem is because of not correctly defining atom type?

You are treating LAMMPS as if it can reason and look ahead. LAMMPS is a computer program and does not reason. It processes your input line by line and just looks at the data it has available at the time. It doesn’t care whether you are using something now or only later.

Thanks for your fruitful comments by which I could go forward into recalling second read_data (after relaxation of water molecules).
In this way, I tried to add carbon atoms by one of the following commands:

read_data cc.data add merge 680 group cnt
Or
read_data cc.data add append offset 3 1 0 0 0 group cnt

But both of them were unsuccessful.

ERROR: Illegal read_data command (src/read_data.cpp:284)

ERROR: Invalid type for mass set (src/read_data.cpp:1755)

echo            both
units           real
boundary        p p p
neigh_modify    delay 2 every 1
timestep        1
atom_style      full

bond_style      harmonic
angle_style     harmonic


read_data       config.data extra/atom/types 1 extra/bond/types 1

bond_style harmonic	
bond_coeff 1 469.0  1.0     #H-O
bond_coeff 2 450.0  1.418      #C-C

angle_style harmonic
angle_coeff 1  85.0  109.47    #H-O-H


set  type 1 charge 0.4238
set  type 2 charge -0.8476



pair_style       lj/charmm/coul/long 8.0 10.0 

pair_coeff     1  1     0.0     0.0     #H-H
pair_coeff     2  2    0.1553    3.166     #O-O
pair_coeff     3  3     0.07    3.9848     #C-C

pair_coeff     1  2    0.0     0.0     #H-O
pair_coeff     1  3      0.0     1.9924     #H-C
pair_coeff     2  3      0.104264     3.5754     #O-C


kspace_style    pppm 1e-4

neighbor	      2 bin
neigh_modify     delay 0 every 1 check yes

group solvent type 1 2

fix rigid solvent shake 1.0e-6 500 0 b 1 a 1

fix NVT solvent nvt temp 298.0 298.0 100      


mass 3 12.00
velocity solvent create 298.0 12345678 dist uniform  

thermo 100 
thermo_style custom step temp pe ke etotal
log logequi.txt  


dump 1 all custom 10000 dump.lammpstrj id type x y z 
run 100 # 50000
undump 1
##################

reset_timestep 0

#read_data cc.data add merge 680 group cnt 
read_data cc.data add append offset 3 1 0 0 0 group cnt

pair_coeff     3  3     0.07    3.9848     #C-C
pair_coeff     1  3      0.0     1.9924     #H-C
pair_coeff     2  3      0.104264     3.5754     #O-C


thermo 100 
thermo_style custom step temp pe ke etotal
log logequi2.txt  


dump 2 all custom 1000 dump.lammpstrj id type x y z 
run 1000 # 50000

So you need to go back to the documentation to check each individual command line argument and read through the text explaining. Also, only use the minimum commands and add additional flags later.

This is all basic debugging strategy and I feel a bit silly to repeat this here.

What is the purpose of the “680” here?

Obviously here the sum of the atom type offset and the type ID used in the data file is larger than the reserved number of atom types.

‘680’ is the total number of carbon atoms need to add to the previous data file.

But where in the read_data docs does it say that this has to be there?

read_data data.water add merge 1 group solvent

It’s been written ‘1’ which I didn’t understand what it means.

Please read the description of the command. That is what matters. There is no mention of this number anywhere and this example will cause the same error message.

An example is not the documentation and it can have a typo (this has). You cannot just make up something because of an example.

If you do not understand what it means, it is even more important to read the detailed description below and see if this shows up anywhere.