ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/freemol/branches/sync4pymol12/src/mengine/src/torsions.c
Revision: 93
Committed: Sat Jan 17 23:24:55 2009 UTC (13 years, 5 months ago) by wdelano
File size: 8644 byte(s)
Log Message:
branch created
Line User Rev File contents
1 tjod 3 #define EXTERN extern
2    
3     #include "pcwin.h"
4     #include "pcmod.h"
5     #include "torsions.h"
6    
7     int isbond(int, int);
8     void get_torsions(void);
9     void message_alert(char *, char *);
10     int is_linear(int);
11    
12     struct t_allene {
13     int nallene, ntor[10];
14     } allene;
15     EXTERN struct t_minim_control {
16     int type, method, field, added_const;
17     char added_path[256],added_name[256];
18     } minim_control;
19    
20     int is_allene(int i, int j, int k, int l)
21     {
22     if (atom[i].mmx_type == 2 && atom[j].mmx_type == 4 && atom[k].mmx_type == 2)
23     return FALSE;
24     if (atom[j].mmx_type == 2 && atom[k].mmx_type == 4 && atom[l].mmx_type == 2)
25     return FALSE;
26     return TRUE;
27     }
28     // ==================================================
29     int is_linear(int ia)
30     {
31     if (atom[ia].mmx_type == 4 || atom[ia].mmx_type == 10)
32     return TRUE;
33     if (atom[ia].mmff_type == 53)
34     return TRUE;
35     return FALSE;
36     }
37     // ==================================
38     void get_torsions()
39     {
40     int i, j, k, l,m;
41     int ia1, ia2, nRc;
42     int katm, latm;
43    
44     torsions.ntor = 0;
45     allene.nallene = 0;
46     for (i=1; i <=natom; i++)
47     {
48     ia1 = i;
49     for(j=0; j< MAXIAT; j++)
50     {
51     if (atom[i].iat[j] != 0 && isbond(i,atom[i].iat[j]) && atom[atom[i].iat[j]].type < 300 )
52     {
53     ia2 = atom[i].iat[j];
54     if (is_linear(ia2) == FALSE)
55     {
56     for(k=0; k<MAXIAT; k++)
57     {
58     if (atom[ia2].iat[k] != 0 && isbond(atom[i].iat[j],atom[atom[i].iat[j]].iat[k]) && atom[atom[i].iat[j]].type < 300 )
59     {
60     katm = atom[atom[i].iat[j]].iat[k];
61     if (isbond(ia2,katm) && atom[katm].type < 300 )
62     {
63     if (i != katm)
64     {
65     for(l=0; l<MAXIAT; l++)
66     {
67     if (isbond(katm,atom[katm].iat[l]) && !is_linear(katm) )
68     {
69     latm = atom[katm].iat[l];
70     nRc = is_allene(i,atom[i].iat[j],katm,latm);
71     if ( (latm != atom[i].iat[j]) && (latm >i) && nRc)
72     {
73     torsions.i14[torsions.ntor][0] = i;
74     torsions.i14[torsions.ntor][1] = atom[i].iat[j];
75     torsions.i14[torsions.ntor][2] = katm;
76     torsions.i14[torsions.ntor][3] = latm;
77     torsions.ntor++;
78     if (torsions.ntor > MAXTOR)
79     {
80     message_alert("Too many torsions. PCMODEL will now exit","Torsion Setup");
81 wdelano 58 fprintf(pcmlogfile,"Too many torsions in torsion setup.\n");
82 tjod 3 exit(0);
83     }
84     }
85     }
86     }
87     }
88     }
89     }
90     }
91     }
92     }
93     }
94     }
95     // look for allenes
96     for (i=1; i <= natom; i++)
97     {
98     if (atom[i].mmx_type == 4)
99     {
100     if (atom[i].bo[0] == 2 && atom[i].bo[1] == 2) // got an cummulene
101     {
102     if (atom[atom[i].iat[0]].mmx_type == 2 && atom[atom[i].iat[1]].mmx_type == 2) // got an allene
103     {
104     katm = atom[i].iat[0];
105     latm = atom[i].iat[1];
106     if (atom[katm].iat[0] == i)
107     {
108     j = atom[katm].iat[1];
109     k = atom[katm].iat[2];
110     }else if (atom[katm].iat[1] == i)
111     {
112     j = atom[katm].iat[0];
113     k = atom[katm].iat[2];
114     }else if (atom[katm].iat[2] == i)
115     {
116     j = atom[katm].iat[1];
117     k = atom[katm].iat[2];
118     }
119    
120     if (atom[latm].iat[0] == i)
121     {
122     l = atom[latm].iat[1];
123     m = atom[latm].iat[2];
124     }else if (atom[katm].iat[1] == i)
125     {
126     l = atom[latm].iat[0];
127     m = atom[latm].iat[2];
128     }else if (atom[katm].iat[2] == i)
129     {
130     l = atom[latm].iat[1];
131     m = atom[latm].iat[2];
132     }
133     torsions.i14[torsions.ntor][0] = j;
134     torsions.i14[torsions.ntor][1] = katm;
135     torsions.i14[torsions.ntor][2] = latm;
136     torsions.i14[torsions.ntor][3] = l;
137     allene.ntor[allene.nallene] = torsions.ntor;
138     allene.nallene++;
139     torsions.ntor++;
140    
141     torsions.i14[torsions.ntor][0] = j;
142     torsions.i14[torsions.ntor][1] = katm;
143     torsions.i14[torsions.ntor][2] = latm;
144     torsions.i14[torsions.ntor][3] = m;
145     allene.ntor[allene.nallene] = torsions.ntor;
146     allene.nallene++;
147     torsions.ntor++;
148    
149     torsions.i14[torsions.ntor][0] = k;
150     torsions.i14[torsions.ntor][1] = katm;
151     torsions.i14[torsions.ntor][2] = latm;
152     torsions.i14[torsions.ntor][3] = l;
153     allene.ntor[allene.nallene] = torsions.ntor;
154     allene.nallene++;
155     torsions.ntor++;
156    
157     torsions.i14[torsions.ntor][0] = k;
158     torsions.i14[torsions.ntor][1] = katm;
159     torsions.i14[torsions.ntor][2] = latm;
160     torsions.i14[torsions.ntor][3] = m;
161     allene.ntor[allene.nallene] = torsions.ntor;
162     allene.nallene++;
163     torsions.ntor++;
164     if (torsions.ntor > MAXTOR)
165     {
166     message_alert("Too many allene torsions. PCMODEL will now exit","Torsion Setup");
167 wdelano 58 fprintf(pcmlogfile,"Too many allene torsions in torsion setup.\n");
168 tjod 3 }
169     if (allene.nallene > 10)
170     {
171     message_alert("Too many allene torsions. PCMODEL will now exit","Torsion Setup");
172 wdelano 58 fprintf(pcmlogfile,"Too many allene torsions in torsion setup.\n");
173 tjod 3 }
174     }
175     }
176     }
177     }
178     }
179     // ======================================================================
180     void max_torsions()
181     {
182     int i, j, k, l;
183     int ia1, ia2;
184     int katm, latm;
185    
186     torsions.ntor = 0;
187     for (i=1; i <=natom; i++)
188     {
189     ia1 = i;
190     for(j=0; j< MAXIAT; j++)
191     {
192     if (isbond(i,atom[i].iat[j]) )
193     {
194     ia2 = atom[i].iat[j];
195     for(k=0; k<MAXIAT; k++)
196     {
197     if (isbond(atom[i].iat[j],atom[atom[i].iat[j]].iat[k]) )
198     {
199     katm = atom[atom[i].iat[j]].iat[k];
200     if (i != katm)
201     {
202     for(l=0; l<MAXIAT; l++)
203     {
204     if (isbond(katm,atom[katm].iat[l]) )
205     {
206     latm = atom[katm].iat[l];
207     if ( (latm != atom[i].iat[j]) && (latm >i) )
208     {
209     torsions.ntor++;
210     }
211     }
212     }
213     }
214     }
215     }
216     }
217     }
218     }
219     // find allenes
220     for (i=0; i <= natom; i++)
221     {
222     if (atom[i].mmx_type == 4)
223     {
224     if (atom[i].bo[0] == 2 && atom[i].bo[1] == 2)
225     {
226     if (atom[atom[i].iat[0]].mmx_type == 2 && atom[atom[i].iat[1]].mmx_type == 2)
227     {
228     torsions.ntor += 4;
229     }
230     }
231     }
232     }
233     }