Continuing the discussion from [[lammps-users] difficulty using molecule command to add a molecule](https://matsci.org/t/lammps-users-difficulty-using-molecule-command-to-add-a-molecule/40179/2)

Continuing the discussion from [lammps-users] difficulty using molecule command to add a molecule:

Hello,

I have been trying to resolve an issue similar to that in the link above - with all extra types, bonds, angles, dihedrals added. The molecule I am trying to add has 40 atoms, 40 bonds, 76 angles, and 96 dihedrals. I tried giving different numbers to the extra/special/per/atom, but I am still getting the same error. I would appreciate any pointers on my mistake.

Thank you.

Best wishes,
Jean

Relevant lines in input file:

units           real
atom_style      full
boundary        p p p

bond_style      harmonic
angle_style     hybrid fourier cosine/periodic harmonic
dihedral_style  harmonic
improper_style  fourier

pair_style      lj/cut 13
pair_modify     tail yes mix arithmetic

special_bonds   lj 0.0 0.0 0.0

# FRAMEWORK #

box tilt        large
read_data       data.4a54aa8 extra/atom/types 4 extra/bond/types 3 extra/angle/types 6 extra/dihedral/types 4 extra/special/per/atom 100

# MOLECULE #
molecule        ads molecule.txt toff 4 boff 8 aoff 14 doff 4

mass            5   28.0855                         
mass            6   15.999                         
mass            7   12.0000                       
mass            8   1.0000                         

bond_coeff		9  	350.12	1.65817		          
bond_coeff		10  189.65  1.87355		           
bond_coeff		11  200.00  1.09349		           
						
angle_coeff		15	harmonic 14.14  144.50215		
angle_coeff		16	harmonic 94.50	108.5253		
angle_coeff		17	harmonic 49.97	108.833			
angle_coeff		18	harmonic 99.94	111.0215		
angle_coeff		19	harmonic 120.0	110.0926		
angle_coeff		20	harmonic 120.0	108.2526		

dihedral_coeff	5	0.01	1	3				   
dihedral_coeff	6	0.225	1	1				    
dihedral_coeff	7	1.590	-1	3				  
dihedral_coeff	8	0.01	1	3				   

pair_coeff		5	5	0			3.385	       
pair_coeff		6	6	0.1520		2.39	        
pair_coeff		7	7	0.3776		3.85	       
pair_coeff		8	8	0.000		2.00	        
pair_coeff		5	6	0			2.8875	        
pair_coeff		5	7	0			3.67	       
pair_coeff		5	8	0			2.8875	        
pair_coeff		6	7	0.239573 	3.120	        
pair_coeff		6	8	0.00000 	3.000	      
pair_coeff		7	8	0.00000 	3.000	        

set atom *      charge 0.0

info system coeffs out append debug.out

create_atoms    0 random 1 123456 NULL mol ads 456789 overlap 1.0 maxtry 100

Molecule file:

all-atom type

40 atoms
40 bonds
76 angles
96 dihedrals

Types

1	1
2	1
3	1
4	1
5	2
6	2
7	2
8	2
9	3
10	3
11	3
12	3
13	3
14	3
15	3
16	3
17	4
18	4
19	4
20	4
21	4
22	4
23	4
24	4
25	4
26	4
27	4
28	4
29	4
30	4
31	4
32	4
33	4
34	4
35	4
36	4
37	4
38	4
39	4
40	4

Molecules
 
1	40
2	40
3	40
4	40
5	40
6	40
7	40
8	40
9	40
10	40
11	40
12	40
13	40
14	40
15	40
16	40
17	40
18	40
19	40
20	40
21	40
22	40
23	40
24	40
25	40
26	40
27	40
28	40
29	40
30	40
31	40
32	40
33	40
34	40
35	40
36	40
37	40
38	40
39	40
40	40

Coords

1	2.066644457	0.306427621	0.494605648
2	-0.306462995	2.066610897	-0.494566532
3	0.306394227	-2.06657092	-0.494843814
4	-2.066547343	-0.306431706	0.494808748
5	1.189136818	1.355582038	-0.439011105
6	1.355552277	-1.18913268	0.438826828
7	-1.35539259	1.189114221	0.439321785
8	-1.189126263	-1.355384293	-0.439117974
9	2.056309824	0.864721034	2.267730918
10	3.774629618	0.209243144	-0.224876129
11	-0.865094529	2.056119545	-2.26758561
12	-0.209221633	3.774651311	0.22477335
13	0.864750561	-2.05625142	-2.267948203
14	0.209093419	-3.774562307	0.224610868
15	-3.774577799	-0.209039767	-0.224538579
16	-2.056111994	-0.865125584	2.267806697
17	2.530472251	1.844731545	2.375542242
18	1.02977889	0.941795714	2.637360123
19	2.592415094	0.155514688	2.904611074
20	3.731674054	-0.105344518	-1.271089345
21	4.271175418	1.182678544	-0.185039291
22	4.388400462	-0.511025784	0.323207688
23	-0.156022337	2.592193672	-2.904641451
24	-0.942209043	1.029557509	-2.637120214
25	-1.845137903	2.530247355	-2.375251974
26	0.510920157	4.388414449	-0.323486028
27	-1.182686389	4.271151029	0.185079426
28	0.105559441	3.73178356	1.270931953
29	0.941866571	-1.029725717	-2.637583487
30	1.844751587	-2.530441823	-2.375721521
31	0.155551905	-2.592339308	-2.904851542
32	-0.105536947	-3.731609774	1.270811395
33	-0.511180393	-4.388290646	-0.323514461
34	1.182506605	-4.271154728	0.184808675
35	-3.731683123	0.10577302	-1.270686625
36	-4.271149054	-1.182469628	-0.184881024
37	-4.388292353	0.511127097	0.323742568
38	-1.029562194	-0.942287273	2.637365764
39	-2.592176359	-0.156058148	2.904875927
40	-2.530275414	-1.845156769	2.375425452

Bonds

1	1	1	6
2	1	6	3
3	1	3	8
4	1	8	4
5	1	4	7
6	1	7	2
7	1	2	5
8	1	5	1
9	2	1	9
10	2	1	10
11	2	2	11
12	2	2	12
13	2	3	13
14	2	3	14
15	2	4	15
16	2	4	16
17	3	9	17
18	3	9	18
19	3	9	19
20	3	10	20
21	3	10	21
22	3	10	22
23	3	11	23
24	3	11	24
25	3	11	25
26	3	12	26
27	3	12	27
28	3	12	28
29	3	13	29
30	3	13	30
31	3	13	31
32	3	14	32
33	3	14	33
34	3	14	34
35	3	15	35
36	3	15	36
37	3	15	37
38	3	16	38
39	3	16	39
40	3	16	40

Angles

1	1	1	6	3
2	1	3	8	4
3	1	4	7	2
4	1	2	5	1
5	2	5	1	6
6	2	6	3	8
7	2	8	4	7
8	2	7	2	5
9	3	5	1	9
10	3	5	1	10
11	3	5	2	11
12	3	5	2	12
13	3	6	1	9
14	3	6	1	10
15	3	6	3	13
16	3	6	3	14
17	3	7	2	11
18	3	7	2	12
19	3	7	4	15
20	3	7	4	16
21	3	8	3	13
22	3	8	3	14
23	3	8	4	15
24	3	8	4	16
25	4	9	1	10
26	4	11	2	12
27	4	13	3	14
28	4	15	4	16
29	5	17	9	1
30	5	18	9	1
31	5	19	9	1
32	5	20	10	1
33	5	21	10	1
34	5	22	10	1
35	5	23	11	2
36	5	24	11	2
37	5	25	11	2
38	5	26	12	2
39	5	27	12	2
40	5	28	12	2
41	5	29	13	3
42	5	30	13	3
43	5	31	13	3
44	5	32	14	3
45	5	33	14	3
46	5	34	14	3
47	5	35	15	4
48	5	36	15	4
49	5	37	15	4
50	5	38	16	4
51	5	39	16	4
52	5	40	16	4
53	6	17	9	18
54	6	17	9	19
55	6	18	9	19
56	6	20	10	21
57	6	20	10	22
58	6	21	10	22
59	6	23	11	24
60	6	23	11	25
61	6	24	11	25
62	6	26	12	27
63	6	26	12	28
64	6	27	12	28
65	6	29	13	30
66	6	29	13	31
67	6	30	13	31
68	6	32	14	33
69	6	32	14	34
70	6	33	14	34
71	6	35	15	36
72	6	35	15	37
73	6	36	15	37
74	6	38	16	39
75	6	38	16	40
76	6	39	16	40

Dihedrals

1	1	1	5	2	11
2	1	1	5	2	12
3	1	1	6	3	13
4	1	1	6	3	14
5	1	2	5	1	9
6	1	2	5	1	10
7	1	2	7	4	15
8	1	2	7	4	16
9	1	3	6	1	9
10	1	3	6	1	10
11	1	3	8	4	15
12	1	3	8	4	16
13	1	4	7	2	11
14	1	4	7	2	12
15	1	4	8	3	13
16	1	4	8	3	14
17	2	1	5	2	7
18	2	1	6	3	8
19	2	2	5	1	6
20	2	2	7	4	8
21	2	3	6	1	5
22	2	3	8	4	7
23	2	4	7	2	5
24	2	4	8	3	6
25	3	5	1	9	17
26	3	5	1	9	18
27	3	5	1	9	19
28	3	5	1	10	20
29	3	5	1	10	21
30	3	5	1	10	22
31	3	5	2	11	23
32	3	5	2	11	24
33	3	5	2	11	25
34	3	5	2	12	26
35	3	5	2	12	27
36	3	5	2	12	28
37	3	6	1	9	17
38	3	6	1	9	18
39	3	6	1	9	19
40	3	6	1	10	20
41	3	6	1	10	21
42	3	6	1	10	22
43	3	6	3	13	29
44	3	6	3	13	30
45	3	6	3	13	31
46	3	6	3	14	32
47	3	6	3	14	33
48	3	6	3	14	34
49	3	7	2	11	23
50	3	7	2	11	24
51	3	7	2	11	25
52	3	7	2	12	26
53	3	7	2	12	27
54	3	7	2	12	28
55	3	7	4	15	35
56	3	7	4	15	36
57	3	7	4	15	37
58	3	7	4	16	38
59	3	7	4	16	39
60	3	7	4	16	40
61	3	8	3	13	29
62	3	8	3	13	30
63	3	8	3	13	31
64	3	8	3	14	32
65	3	8	3	14	33
66	3	8	3	14	34
67	3	8	4	15	35
68	3	8	4	15	36
69	3	8	4	15	37
70	3	8	4	16	38
71	3	8	4	16	39
72	3	8	4	16	40
73	4	9	1	10	20
74	4	9	1	10	21
75	4	9	1	10	22
76	4	10	1	9	17
77	4	10	1	9	18
78	4	10	1	9	19
79	4	11	2	12	26
80	4	11	2	12	27
81	4	11	2	12	28
82	4	12	2	11	23
83	4	12	2	11	24
84	4	12	2	11	25
85	4	13	3	14	32
86	4	13	3	14	33
87	4	13	3	14	34
88	4	14	3	13	29
89	4	14	3	13	30
90	4	14	3	13	31
91	4	15	4	16	38
92	4	15	4	16	39
93	4	15	4	16	40
94	4	16	4	15	35
95	4	16	4	15	36
96	4	16	4	15	37

Error:

Read molecule template ads:
  40 molecules
  0 fragments
  40 atoms with max type 8
  40 bonds with max type 11
  76 angles with max type 20
  96 dihedrals with max type 8
  0 impropers with max type 0
Setting atom values ...
  1440 settings made for charge
WARNING: Molecule attributes do not match system attributes (src/molecule.cpp:1696)
ERROR: Molecule topology/atom exceeds system topology/atom (src/molecule.cpp:1724)
Last command: create_atoms    0 random 1 123456 NULL mol ads 456789 overlap 1.0 maxtry 1000

You need the extra/*/per/atom keywords for bond, angle, and dihedral. For example, extra/bond/per/atom 3 will leave room for 3 bonds per atom. You may need to increase that to 4 or more, depending.

Note that the error message says as much:
ERROR: Molecule topology/atom exceeds system topology/atom

2 Likes

This is the “relative” molecule ID within the molecule file. If you want to add just one molecule then this should be 1. In your case LAMMPS will think you want to add atoms with molecule ID 1-40 and thus atoms with 40 different molecule IDs. As can be seen from the output:

1 Like

Thank you Michael and Axel, the problem is now resolved!

Best wishes,
Jean