4 * This source code is part of
8 * GROningen MAchine for Chemical Simulations
11 * Copyright (c) 1991-2001, University of Groningen, The Netherlands
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation; either version 2
15 * of the License, or (at your option) any later version.
17 * If you want to redistribute modifications, please consider that
18 * scientific software is very special. Version control is crucial -
19 * bugs must be traceable. We will be happy to consider code for
20 * inclusion in the official distribution, but derived work must not
21 * be called official GROMACS. Details are found in the README & COPYING
22 * files - if they are missing, get the official version at www.gromacs.org.
24 * To help us fund GROMACS development, we humbly ask that you cite
25 * the papers on the package - you can find them in the top README file.
27 * For more info, check our website at http://www.gromacs.org
30 * Great Red Owns Many ACres of Sand
46 void gen_waterhydrogen(rvec xa
[], rvec xh
[])
51 const rvec matrix1
[6] = {
59 const rvec matrix2
[6] = {
73 /* This was copied from Gromos */
74 for(m
=0; (m
<DIM
); m
++) {
75 xH1
[m
]=xAI
[m
]+matrix1
[l
][m
];
76 xH2
[m
]=xAI
[m
]+matrix2
[l
][m
];
82 void calc_h_pos(int nht
, rvec xa
[], rvec xh
[])
84 #define alfaH (DEG2RAD*109.5)
87 #define alfaCOM (DEG2RAD*117)
88 #define alfaCO (DEG2RAD*121)
89 #define alfaCOA (DEG2RAD*115)
101 /* common work for constructing one, two or three dihedral hydrogens */
109 for(d
=0; (d
<DIM
); d
++) {
116 sa
[XX
] = sij
[YY
]*sb
[ZZ
]-sij
[ZZ
]*sb
[YY
];
117 sa
[YY
] = sij
[ZZ
]*sb
[XX
]-sij
[XX
]*sb
[ZZ
];
118 sa
[ZZ
] = sij
[XX
]*sb
[YY
]-sij
[YY
]*sb
[XX
];
120 for(d
=0; (d
<DIM
); d
++) {
125 for(d
=0; (d
<DIM
); d
++)
128 sb
[XX
] = sa
[YY
]*sij
[ZZ
]-sa
[ZZ
]*sij
[YY
];
129 sb
[YY
] = sa
[ZZ
]*sij
[XX
]-sa
[XX
]*sij
[ZZ
];
130 sb
[ZZ
] = sa
[XX
]*sij
[YY
]-sa
[YY
]*sij
[XX
];
135 case 1: /* construct one planar hydrogen (peptide,rings) */
138 for(d
=0; (d
<DIM
); d
++) {
139 sij
[d
] = xAI
[d
]-xAJ
[d
];
140 sb
[d
] = xAI
[d
]-xAK
[d
];
147 for(d
=0; (d
<DIM
); d
++) {
148 sa
[d
] = sij
[d
]/rij
+sb
[d
]/rb
;
152 for(d
=0; (d
<DIM
); d
++)
153 xH1
[d
] = xAI
[d
]+distH
*sa
[d
]/ra
;
155 case 2: /* one single hydrogen, e.g. hydroxyl */
156 for(d
=0; (d
<DIM
); d
++) {
157 xH1
[d
] = xAI
[d
]+distH
*sin(alfaH
)*sb
[d
]-distH
*cos(alfaH
)*sij
[d
];
160 case 3: /* two planar hydrogens, e.g. -NH2 */
161 for(d
=0; (d
<DIM
); d
++) {
162 xH1
[d
] = xAI
[d
]-distH
*sin(alfaH
)*sb
[d
]-distH
*cos(alfaH
)*sij
[d
];
163 xH2
[d
] = xAI
[d
]+distH
*sin(alfaH
)*sb
[d
]-distH
*cos(alfaH
)*sij
[d
];
166 case 4: /* two or three tetrahedral hydrogens, e.g. -CH3 */
167 for(d
=0; (d
<DIM
); d
++) {
168 xH1
[d
] = xAI
[d
]+distH
*sin(alfaH
)*sb
[d
]-distH
*cos(alfaH
)*sij
[d
];
170 - distH
*sin(alfaH
)*0.5*sb
[d
]
171 + distH
*sin(alfaH
)*s6
*sa
[d
]
172 - distH
*cos(alfaH
)*sij
[d
] );
173 if ( xH3
[XX
]!=NOTSET
&& xH3
[YY
]!=NOTSET
&& xH3
[ZZ
]!=NOTSET
)
175 - distH
*sin(alfaH
)*0.5*sb
[d
]
176 - distH
*sin(alfaH
)*s6
*sa
[d
]
177 - distH
*cos(alfaH
)*sij
[d
] );
180 case 5: { /* one tetrahedral hydrogen, e.g. C3CH */
184 for(d
=0; (d
<DIM
); d
++) {
185 center
=(xAJ
[d
]+xAK
[d
]+xAL
[d
])/3.0;
186 dxc
[d
]=xAI
[d
]-center
;
189 for(d
=0; (d
<DIM
); d
++)
190 xH1
[d
]=xAI
[d
]+dxc
[d
]*distH
/center
;
193 case 6: { /* two tetrahedral hydrogens, e.g. C-CH2-C */
194 rvec rBB
,rCC1
,rCC2
,rNN
;
197 for(d
=0; (d
<DIM
); d
++)
198 rBB
[d
]=xAI
[d
]-0.5*(xAJ
[d
]+xAK
[d
]);
201 rvec_sub(xAI
,xAJ
,rCC1
);
202 rvec_sub(xAI
,xAK
,rCC2
);
203 oprod(rCC1
,rCC2
,rNN
);
206 for(d
=0; (d
<DIM
); d
++) {
207 xH1
[d
]=xAI
[d
]+distH
*(cos(alfaH
/2.0)*rBB
[d
]/bb
+
208 sin(alfaH
/2.0)*rNN
[d
]/nn
);
209 xH2
[d
]=xAI
[d
]+distH
*(cos(alfaH
/2.0)*rBB
[d
]/bb
-
210 sin(alfaH
/2.0)*rNN
[d
]/nn
);
214 case 7: /* two water hydrogens */
215 gen_waterhydrogen(xa
, xh
);
217 case 8: /* two carboxyl oxygens, -COO- */
218 for(d
=0; (d
<DIM
); d
++) {
219 xH1
[d
] = xAI
[d
]-distOM
*sin(alfaCOM
)*sb
[d
]-distOM
*cos(alfaCOM
)*sij
[d
];
220 xH2
[d
] = xAI
[d
]+distOM
*sin(alfaCOM
)*sb
[d
]-distOM
*cos(alfaCOM
)*sij
[d
];
223 case 9: { /* carboxyl oxygens and hydrogen, -COOH */
224 rvec xa2
[4]; /* i,j,k,l */
226 /* first add two oxygens */
227 for(d
=0; (d
<DIM
); d
++) {
228 xH1
[d
] = xAI
[d
]-distO
*sin(alfaCO
)*sb
[d
]-distO
*cos(alfaCO
)*sij
[d
];
229 xH2
[d
] = xAI
[d
]+distOA
*sin(alfaCOA
)*sb
[d
]-distOA
*cos(alfaCOA
)*sij
[d
];
232 /* now use rule 2 to add hydrogen to 2nd oxygen */
233 copy_rvec(xH2
, xa2
[0]); /* new i = n' */
234 copy_rvec(xAI
, xa2
[1]); /* new j = i */
235 copy_rvec(xAJ
, xa2
[2]); /* new k = j */
236 copy_rvec(xAK
, xa2
[3]); /* new l = k, not used */
237 calc_h_pos(2, xa2
, (xh
+2));
242 fatal_error(0,"Invalid argument (%d) for nht in routine genh\n",nht
);