4 * This source code is part of
8 * GROningen MAchine for Chemical Simulations
12 * Copyright (c) 1991-1999
13 * BIOSON Research Institute, Dept. of Biophysical Chemistry
14 * University of Groningen, The Netherlands
17 * GROMACS: A message-passing parallel molecular dynamics implementation
18 * H.J.C. Berendsen, D. van der Spoel and R. van Drunen
19 * Comp. Phys. Comm. 91, 43-56 (1995)
21 * Also check out our WWW page:
22 * http://md.chem.rug.nl/~gmx
27 * Great Red Oystrich Makes All Chemists Sane
29 static char *SRCID_init_sh_c
= "$Id$";
36 static void pr_shell(FILE *log
,int ns
,t_shell s
[])
40 fprintf(log
,"SHELL DATA\n");
41 fprintf(log
,"%5s %8s %5s %5s %5s\n",
42 "Shell","Force k","Nucl1","Nucl2","Nucl3");
43 for(i
=0; (i
<ns
); i
++) {
44 fprintf(log
,"%5d %8.3f %5d",s
[i
].shell
,1.0/s
[i
].k_1
,s
[i
].nucl1
);
46 fprintf(log
," %5d\n",s
[i
].nucl2
);
47 else if (s
[i
].nnucl
== 3)
48 fprintf(log
," %5d %5d\n",s
[i
].nucl2
,s
[i
].nucl3
);
54 t_shell
*init_shells(FILE *log
,int start
,int homenr
,
55 t_idef
*idef
,t_mdatoms
*md
,int *nshell
)
60 int i
,j
,type
,ftype
,nra
;
65 for(i
=0; (i
<eptNR
); i
++)
67 snew(shell_index
,homenr
);
69 for(i
=start
; (i
<start
+homenr
); i
++) {
71 if (md
->ptype
[i
] == eptShell
)
72 shell_index
[i
-start
] = nsi
++;
74 assert(nsi
== n
[eptShell
]);
75 for(i
=0; (i
<eptNR
); i
++)
77 fprintf(log
,"There are: %d %s\n",n
[i
],ptype_str
[i
]);
84 /* Initiate the shell structures */
85 for(i
=0; (i
<ns
); i
++) {
86 shell
[i
].shell
=NO_ATID
;
87 shell
[i
].nucl1
=NO_ATID
;
88 shell
[i
].nucl2
=NO_ATID
;
89 shell
[i
].nucl3
=NO_ATID
;
95 /* Now fill the structures */
97 ia
=idef
->il
[F_BONDS
].iatoms
;
98 for(i
=0; (i
<idef
->il
[F_BONDS
].nr
); ) {
100 ftype
= idef
->functype
[type
];
101 nra
= interaction_function
[ftype
].nratoms
;
103 /* Check whether we have a bond */
105 if (md
->ptype
[ia
[1]] == eptShell
) {
109 else if (md
->ptype
[ia
[2]] == eptShell
) {
118 /* Check whether one of the particles is a shell... */
119 nsi
= shell_index
[a1
-start
];
120 if ((nsi
< 0) || (nsi
>= *nshell
))
121 fatal_error(0,"nsi is %d should be within 0 - %d. a1 = %d",
123 if (shell
[nsi
].shell
== NO_ATID
) {
124 shell
[nsi
].shell
= a1
;
127 else if (shell
[nsi
].shell
!= a1
)
128 fatal_error(0,"What is this?");
130 if (shell
[nsi
].nucl1
== NO_ATID
)
131 shell
[nsi
].nucl1
= a2
;
132 else if (shell
[nsi
].nucl2
== NO_ATID
)
133 shell
[nsi
].nucl2
= a2
;
134 else if (shell
[nsi
].nucl3
== NO_ATID
)
135 shell
[nsi
].nucl3
= a2
;
137 pr_shell(log
,ns
,shell
);
138 fatal_error(0,"Can not handle more than three bonds per shell\n");
140 shell
[nsi
].k
+= idef
->iparams
[type
].harmonic
.krA
;
146 ia
= idef
->il
[F_WPOL
].iatoms
;
147 for(i
=0; (i
<idef
->il
[F_WPOL
].nr
); ) {
149 ftype
= idef
->functype
[type
];
150 nra
= interaction_function
[ftype
].nratoms
;
152 a1
= ia
[1]+4; /* Shell */
153 a2
= ia
[1]+3; /* Dummy */
155 /* Check whether one of the particles is a shell... */
156 nsi
= shell_index
[a1
-start
];
157 if ((nsi
< 0) || (nsi
>= *nshell
))
158 fatal_error(0,"nsi is %d should be within 0 - %d. a1 = %d",
160 if (shell
[nsi
].shell
== NO_ATID
) {
161 shell
[nsi
].shell
= a1
;
164 else if (shell
[nsi
].shell
!= a1
)
165 fatal_error(0,"What is this? shell=%d, a1=%d",shell
[nsi
].shell
,a1
);
167 shell
[nsi
].nucl1
= a2
;
168 shell
[nsi
].k
= (idef
->iparams
[type
].wpol
.kx
+
169 idef
->iparams
[type
].wpol
.ky
+
170 idef
->iparams
[type
].wpol
.kz
)/3.0;
176 /* Verify whether it's all correct */
177 assert(ns
== *nshell
);
179 for(i
=0; (i
<ns
); i
++)
180 shell
[i
].k_1
= 1.0/shell
[i
].k
;
183 pr_shell(debug
,ns
,shell
);