ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/freemol/branches/sync4pymol12/src/mengine/src/ktorsion.c
Revision: 99
Committed: Mon Jan 19 04:31:29 2009 UTC (10 years, 10 months ago) by wdelano
File size: 16354 byte(s)
Log Message:
synchronized with trunk, less openmp lib/include
Line File contents
1 #define EXTERN extern
2
3 #include "pcwin.h"
4 #include "pcmod.h"
5 #include "torsions.h"
6 #include "rings.h"
7 #include "field.h"
8 #include "atom_k.h"
9
10 int isbond(int,int);
11 int is_delocalbond(int,int);
12 void numeral(int,char *,int);
13 void four(char *,char *,char *,char *, char *);
14 int is_ring42(int,int);
15 int is_ring54(int, int, int, int);
16 void message_alert(char *, char *);
17
18 EXTERN struct t_allene {
19 int nallene, ntor[10];
20 } allene;
21
22
23 EXTERN struct t_torkn1 {
24 int use_tor4, use_tor5;
25 int ntor, ntor4, ntor5, ntordel, torindex[MAXTORDEL];
26 char kv[MAXTORCONST][13], kv4[MAXTOR4CONST][13], kv5[MAXTOR5CONST][13];
27 char kvdel[MAXTORDEL][13];
28 float tv1[MAXTORCONST], tv2[MAXTORCONST], tv3[MAXTORCONST];
29 float tv4[MAXTORCONST], tv5[MAXTORCONST], tv6[MAXTORCONST];
30 int phase1[MAXTORCONST], phase2[MAXTORCONST], phase3[MAXTORCONST];
31 int phase4[MAXTORCONST], phase5[MAXTORCONST], phase6[MAXTORCONST];
32 float tv41[MAXTOR4CONST], tv42[MAXTOR4CONST], tv43[MAXTOR4CONST];
33 int phase41[MAXTOR4CONST], phase42[MAXTOR4CONST], phase43[MAXTOR4CONST];
34 float tv51[MAXTOR5CONST], tv52[MAXTOR5CONST], tv53[MAXTOR5CONST];
35 int phase51[MAXTOR5CONST], phase52[MAXTOR5CONST], phase53[MAXTOR5CONST];
36 float tvdel1[MAXTORDEL], tvdel2[MAXTORDEL], tvdel3[MAXTORDEL];
37 int phasedel1[MAXTORDEL], phasedel2[MAXTORDEL], phasedel3[MAXTORDEL];
38 } torkn1;
39
40 EXTERN int Missing_constants;
41
42 void ktorsion()
43 {
44 int i, j, ierr, itor, ii, ki, k;
45 int ia, ib, ic, id;
46 int ita, itb, itc, itd;
47 int cl_a, cl_b, cl_c, cl_d;
48 int use_ring4, use_ring5;
49 char izero[4];
50 char pa[4],pb[4],pc[4],pd[4],pt[13], kv1[13];
51 char k1[13], k2[13], k3[13], k4[13], k5[13], k6[13], k7[13], k8[13], k9[13], k10[13],
52 k11[13], k12[13], k13[13], k14[13], k15[13];
53 float v1, v2, v3, rangle;
54
55 itor = 0;
56 use_ring4 = FALSE;
57 if (rings.nring4 > 0 && torkn1.ntor4 > 0)
58 use_ring4 = TRUE;
59
60 use_ring5 = FALSE;
61 if (rings.nring5 > 0 && torkn1.ntor5 > 0)
62 use_ring5 = TRUE;
63
64 for (i=0; i < torsions.ntor; i++)
65 {
66 ia = torsions.i14[i][0];
67 ib = torsions.i14[i][1];
68 ic = torsions.i14[i][2];
69 id = torsions.i14[i][3];
70
71 ita = atom[ia].type;
72 itb = atom[ib].type;
73 itc = atom[ic].type;
74 itd = atom[id].type;
75
76 cl_a = atom[ia].tclass;
77 cl_b = atom[ib].tclass;
78 cl_c = atom[ic].tclass;
79 cl_d = atom[id].tclass;
80
81 if (field.type == MMX)
82 {
83 if (ita == 40)
84 ita = 2;
85 if (itb == 40)
86 itb = 2;
87 if (itc == 40)
88 itc = 2;
89 if (itd == 40)
90 itd = 2;
91
92 if (ita == 56 && itb == 56 && itc == 56 && itd == 56)
93 {
94 ita = 1; itb = 1; itc = 1; itd = 1;
95 }
96 }
97 numeral(ita,pa,3);
98 numeral(itb,pb,3);
99 numeral(itc,pc,3);
100 numeral(itd,pd,3);
101
102 if (itb < itc )
103 four(pa,pb, pc, pd, pt);
104 else if (itb > itc)
105 four(pd,pc, pb, pa, pt);
106 else if (ita < itd)
107 four(pa,pb, pc, pd, pt);
108 else
109 four(pd,pc, pb, pa, pt);
110 strcpy(izero," 0");
111
112 if (field.type == MMFF94)
113 {
114
115 numeral(atom_k.tclass1[ita],pa,3);
116 numeral(atom_k.tclass[itb],pb,3);
117 numeral(atom_k.tclass[itc],pc,3);
118 numeral(atom_k.tclass1[itd],pd,3);
119
120
121 if (atom_k.tclass[itb] < atom_k.tclass[itc] )
122 {
123 four(pa, pb, pc, izero,k2);
124 four(izero ,pb, pc, pd,k3);
125 } else if (atom_k.tclass[itb] > atom_k.tclass[itc])
126 {
127 four(izero,pc, pb, pa, k2);
128 four(pd,pc, pb, izero, k3);
129 } else if (atom_k.tclass1[ita] < atom_k.tclass1[itd])
130 {
131 four(pa,pb, pc, izero, k2);
132 four(izero,pb, pc, pd, k3);
133 } else
134 {
135 four(izero,pc, pb, pa, k2);
136 four(pd,pc, pb, izero, k3);
137 }
138 } else
139 {
140 four( izero, pc, pb, pa, k1 );
141 four( pd, pc, pb, izero, k2 );
142 four( izero, pb, pc, pd, k3 );
143 }
144
145 numeral(ita,pa,3);
146 numeral(itb,pb,3);
147 numeral(itc,pc,3);
148 numeral(itd,pd,3);
149
150 four( pa, pb, pc, izero, k4 );
151 four( izero, pc, pb, izero, k5 );
152 four( izero, pb, pc, izero, k6 );
153 four( pd, pc, izero, izero, k7 );
154 four( izero, izero, pc,pd, k8 );
155
156 four( izero, izero, pb, pa, k9 );
157 four( pa, pb, izero, izero, k10 );
158 four( izero, izero, pc, izero, k11 );
159 four( izero, pc, izero, izero, k12 );
160 four( izero, izero, pb, izero, k13 );
161 four( izero, pb, izero, izero, k14 );
162
163 numeral(cl_a,pa,3);
164 numeral(cl_b,pb,3);
165 numeral(cl_c,pc,3);
166 numeral(cl_d,pd,3);
167 if (itb < itc )
168 four(pa,pb, pc, pd, k15);
169 else if (itb > itc)
170 four(pd,pc, pb, pa, k15);
171 else if (ita < itd)
172 four(pa,pb, pc, pd, k15);
173 else
174 four(pd,pc, pb, pa, k15);
175
176 ierr = FALSE;
177 // check for four membered rings
178 if ( isbond(ia,id) )
179 {
180 for(j=0; j < torkn1.ntor4; j++)
181 {
182 strcpy(kv1,torkn1.kv4[j]);
183 if (strcmp(pt,kv1) == 0 || strcmp(k1,kv1) == 0 || strcmp(k2,kv1) == 0 || strcmp(k3,kv1) == 0 ||
184 strcmp(k4,kv1) == 0 || strcmp(k5,kv1) == 0 || strcmp(k6,kv1) == 0 || strcmp(k7,kv1) == 0 ||
185 strcmp(k8,kv1) == 0 || strcmp(k9,kv1) == 0 || strcmp(k10,kv1) == 0 || strcmp(k11,kv1) == 0 ||
186 strcmp(k12,kv1) == 0 || strcmp(k13,kv1) == 0 || strcmp(k14,kv1) == 0 )
187 {
188 torsions.v1[i] = torkn1.tv41[j];
189 torsions.ph1[i] = torkn1.phase41[j];
190 torsions.v2[i] = torkn1.tv42[j];
191 torsions.ph2[i] = torkn1.phase42[j];
192 torsions.v3[i] = torkn1.tv43[j];
193 torsions.ph3[i] = torkn1.phase43[j];
194 ierr = TRUE;
195 goto L_10;
196 }
197 }
198 }
199 // delocalized torsions
200 if ( is_delocalbond(ib,ic) )
201 {
202 for(j=0; j < torkn1.ntordel; j++)
203 {
204 strcpy(kv1,torkn1.kvdel[j]);
205 if (strcmp(pt,kv1) == 0 || strcmp(k1,kv1) == 0 || strcmp(k2,kv1) == 0 || strcmp(k3,kv1) == 0 ||
206 strcmp(k4,kv1) == 0 || strcmp(k5,kv1) == 0 || strcmp(k6,kv1) == 0 || strcmp(k7,kv1) == 0 ||
207 strcmp(k8,kv1) == 0 || strcmp(k9,kv1) == 0 || strcmp(k10,kv1) == 0 || strcmp(k11,kv1) == 0 ||
208 strcmp(k12,kv1) == 0 || strcmp(k13,kv1) == 0 || strcmp(k14,kv1) == 0 )
209 {
210 torsions.v1[i] = torkn1.tvdel1[j];
211 torsions.ph1[i] = torkn1.phasedel1[j];
212 torsions.v2[i] = torkn1.tvdel2[j];
213 torsions.ph2[i] = torkn1.phasedel2[j];
214 torsions.v3[i] = torkn1.tvdel3[j];
215 torsions.ph3[i] = torkn1.phasedel3[j];
216 ierr = TRUE;
217 goto L_10;
218 }
219 }
220 }
221 // check for five membered rings
222 if (is_ring54(ia,ib,ic,id) )
223 {
224 for(j=0; j < torkn1.ntor5; j++)
225 {
226 strcpy(kv1,torkn1.kv5[j]);
227 if (strcmp(pt,kv1) == 0 || strcmp(k1,kv1) == 0 || strcmp(k2,kv1) == 0 || strcmp(k3,kv1) == 0 ||
228 strcmp(k4,kv1) == 0 || strcmp(k5,kv1) == 0 || strcmp(k6,kv1) == 0 || strcmp(k7,kv1) == 0 ||
229 strcmp(k8,kv1) == 0 || strcmp(k9,kv1) == 0 || strcmp(k10,kv1) == 0 || strcmp(k11,kv1) == 0 ||
230 strcmp(k12,kv1) == 0 || strcmp(k13,kv1) == 0 || strcmp(k14,kv1) == 0 )
231 {
232 torsions.v1[i] = torkn1.tv51[j];
233 torsions.ph1[i] = torkn1.phase51[j];
234 torsions.v2[i] = torkn1.tv52[j];
235 torsions.ph2[i] = torkn1.phase52[j];
236 torsions.v3[i] = torkn1.tv53[j];
237 torsions.ph3[i] = torkn1.phase53[j];
238 ierr = TRUE;
239 goto L_10;
240 }
241 }
242 }
243 // check regular parameters
244 if (field.type == MMFF94)
245 {
246 for(j=0; j < torkn1.ntor; j++) // specific constants
247 {
248 strcpy(kv1,torkn1.kv[j]);
249 if (strcmp(pt,kv1) == 0)
250 {
251 torsions.v1[i] = torkn1.tv1[j];
252 torsions.ph1[i] = torkn1.phase1[j];
253 torsions.v2[i] = torkn1.tv2[j];
254 torsions.ph2[i] = torkn1.phase2[j];
255 torsions.v3[i] = torkn1.tv3[j];
256 torsions.ph3[i] = torkn1.phase3[j];
257 torsions.v4[i] = torkn1.tv4[j];
258 torsions.ph4[i] = torkn1.phase4[j];
259 torsions.v5[i] = torkn1.tv5[j];
260 torsions.ph5[i] = torkn1.phase5[j];
261 torsions.v6[i] = torkn1.tv6[j];
262 torsions.ph6[i] = torkn1.phase6[j];
263 goto L_10;
264 }
265 }
266 for(j=0; j < torkn1.ntor; j++) // class 2
267 {
268 strcpy(kv1,torkn1.kv[j]);
269 if (strcmp(k2,kv1) == 0 || strcmp(k3,kv1) == 0 )
270 {
271 torsions.v1[i] = torkn1.tv1[j];
272 torsions.ph1[i] = torkn1.phase1[j];
273 torsions.v2[i] = torkn1.tv2[j];
274 torsions.ph2[i] = torkn1.phase2[j];
275 torsions.v3[i] = torkn1.tv3[j];
276 torsions.ph3[i] = torkn1.phase3[j];
277 torsions.v4[i] = torkn1.tv4[j];
278 torsions.ph4[i] = torkn1.phase4[j];
279 torsions.v5[i] = torkn1.tv5[j];
280 torsions.ph5[i] = torkn1.phase5[j];
281 torsions.v6[i] = torkn1.tv6[j];
282 torsions.ph6[i] = torkn1.phase6[j];
283 goto L_10;
284 }
285 }
286 for(j=0; j < torkn1.ntor; j++) // wild cards
287 {
288 strcpy(kv1,torkn1.kv[j]);
289 if (strcmp(k5,kv1) == 0 || strcmp(k6,kv1) == 0 || strcmp(k7,kv1) == 0 || strcmp(k8,kv1) == 0 )
290 {
291 torsions.v1[i] = torkn1.tv1[j];
292 torsions.ph1[i] = torkn1.phase1[j];
293 torsions.v2[i] = torkn1.tv2[j];
294 torsions.ph2[i] = torkn1.phase2[j];
295 torsions.v3[i] = torkn1.tv3[j];
296 torsions.ph3[i] = torkn1.phase3[j];
297 torsions.v4[i] = torkn1.tv4[j];
298 torsions.ph4[i] = torkn1.phase4[j];
299 torsions.v5[i] = torkn1.tv5[j];
300 torsions.ph5[i] = torkn1.phase5[j];
301 torsions.v6[i] = torkn1.tv6[j];
302 torsions.ph6[i] = torkn1.phase6[j];
303 goto L_10;
304 }
305 }
306 }
307 // check regular specific parameters
308 for(j=0; j < torkn1.ntor; j++)
309 {
310 strcpy(kv1,torkn1.kv[j]);
311 if (strcmp(pt,kv1) == 0)
312 {
313 torsions.v1[i] = torkn1.tv1[j];
314 torsions.ph1[i] = torkn1.phase1[j];
315 torsions.v2[i] = torkn1.tv2[j];
316 torsions.ph2[i] = torkn1.phase2[j];
317 torsions.v3[i] = torkn1.tv3[j];
318 torsions.ph3[i] = torkn1.phase3[j];
319 torsions.v4[i] = torkn1.tv4[j];
320 torsions.ph4[i] = torkn1.phase4[j];
321 torsions.v5[i] = torkn1.tv5[j];
322 torsions.ph5[i] = torkn1.phase5[j];
323 torsions.v6[i] = torkn1.tv6[j];
324 torsions.ph6[i] = torkn1.phase6[j];
325 // check for pi torsions = mm3 does not define pitorsion parameter so we need to pick it up here
326 if (itb == 2 && itc == 2 && field.type == MMX)
327 {
328 for (k=0; k < MAXIAT; k++)
329 {
330 if (atom[ib].iat[k] == ic)
331 {
332 if (atom[ib].bo[k] == 1 && is_delocalbond(ib,ic) )
333 {
334 torsions.v1[i] = 0.5;
335 torsions.v2[i] = 1.0;
336 torsions.v3[i] = 0.0;
337 ierr = TRUE;
338 goto L_10;
339 break;
340 }
341 }
342 }
343 }
344 goto L_10;
345 break;
346 }
347 }
348 // check regular generalized parameters
349 for(j=0; j < torkn1.ntor; j++)
350 {
351 strcpy(kv1,torkn1.kv[j]);
352 if (strcmp(pt,kv1) == 0 || strcmp(k1,kv1) == 0 || strcmp(k2,kv1) == 0 || strcmp(k3,kv1) == 0 ||
353 strcmp(k4,kv1) == 0 || strcmp(k5,kv1) == 0 || strcmp(k6,kv1) == 0 || strcmp(k7,kv1) == 0 ||
354 strcmp(k8,kv1) == 0 || strcmp(k9,kv1) == 0 || strcmp(k10,kv1) == 0 || strcmp(k11,kv1) == 0 ||
355 strcmp(k12,kv1) == 0 || strcmp(k13,kv1) == 0 || strcmp(k14,kv1) == 0 || strcmp(k15,kv1) == 0)
356 {
357 torsions.v1[i] = torkn1.tv1[j];
358 torsions.ph1[i] = torkn1.phase1[j];
359 torsions.v2[i] = torkn1.tv2[j];
360 torsions.ph2[i] = torkn1.phase2[j];
361 torsions.v3[i] = torkn1.tv3[j];
362 torsions.ph3[i] = torkn1.phase3[j];
363 torsions.v4[i] = torkn1.tv4[j];
364 torsions.ph4[i] = torkn1.phase4[j];
365 torsions.v5[i] = torkn1.tv5[j];
366 torsions.ph5[i] = torkn1.phase5[j];
367 torsions.v6[i] = torkn1.tv6[j];
368 torsions.ph6[i] = torkn1.phase6[j];
369 // check for pi torsions = mm3 does not define pitorsion parameter so we need to pick it up here
370 if (itb == 2 && itc == 2 && field.type == MMX)
371 {
372 for (k=0; k < MAXIAT; k++)
373 {
374 if (atom[ib].iat[k] == ic)
375 {
376 if (atom[ib].bo[k] == 1 && is_delocalbond(ib,ic) )
377 {
378 torsions.v1[i] = 0.5;
379 torsions.v2[i] = 1.0;
380 torsions.v3[i] = 0.0;
381 ierr = TRUE;
382 goto L_10;
383 break;
384 }
385 }
386 }
387 }
388 goto L_10;
389 break;
390 }
391 }
392 // missing parameters
393 if (ierr == FALSE)
394 {
395 // Missing_constants = TRUE;
396 fprintf(pcmlogfile,"Torsion constants missing: angle: %d %d %d %d types: %d %d %d %d\n",ia,ib,ic,id,
397 ita, itb, itc, itd);
398 }
399 L_10:
400 continue;
401 }
402
403 if (allene.nallene > 0)
404 {
405 for (i = 0; i < allene.nallene; i++)
406 {
407 torsions.v1[allene.ntor[i]] = 0;
408 torsions.v2[allene.ntor[i]] = -11.5;
409 torsions.v3[allene.ntor[i]] = 0;
410 }
411 }
412 }
413 /* -------------------------------------------- */
414 void four(char *pa, char *pb, char *pc, char *pd, char *pt)
415 {
416 strcpy(pt,pa);
417 strcat(pt,pb);
418 strcat(pt,pc);
419 strcat(pt,pd);
420 }