ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/freemol/trunk/smi23d/src/mengine/angles.c
Revision: 3
Committed: Mon Jun 9 21:38:26 2008 UTC (12 years, 4 months ago) by tjod
File size: 14539 byte(s)
Log Message:
test

Line User Rev File contents
1 tjod 3
2     #define EXTERN extern
3    
4     #include "pcwin.h"
5     #include "pcmod.h"
6    
7     #include "angles.h"
8     #include "field.h"
9     #include "pot.h"
10    
11     // number of atoms with 5 or greater real bonds
12     struct t_high_coord {
13     int ncoord, i13[400][3];
14     } high_coord;
15    
16     void message_alert(char *, char *);
17     void get_angles(void);
18     int isangle(int, int);
19    
20     void get_angles()
21     {
22     int i,j,k,icount;
23     int ia, ib, ic, id, ie;
24     int jj, icoord;
25     int itemp[5];
26    
27     angles.nang = 0;
28     high_coord.ncoord = 0;
29     for (i=0; i < MAXANG; i++)
30     {
31     angles.i13[i][0] = 0;
32     angles.i13[i][1] = 0;
33     angles.i13[i][2] = 0;
34     angles.i13[i][3] = 0;
35     }
36     //
37     for (i = 1; i <= natom; i++)
38     {
39     jj = 0;
40     icoord = 0;
41     for (j=0; j < MAXIAT; j++)
42     {
43     if (atom[i].iat[j] != 0 && atom[i].bo[j] != 9)
44     jj++;
45     if (atom[i].bo[j] == 9)
46     icoord++;
47     }
48    
49     if (jj == 2 && atom[i].type < 300)
50     {
51     icount = 0;
52     for (j=0; j < MAXIAT; j++)
53     {
54     if (atom[i].iat[j] != 0 && atom[i].bo[j] != 9)
55     {
56     icount++;
57     if (icount == 1)
58     ia = atom[i].iat[j];
59     else if (icount == 2)
60     {
61     ib = atom[i].iat[j];
62     break;
63     }
64     }
65     }
66     angles.i13[angles.nang][0] = ia;
67     angles.i13[angles.nang][1] = i;
68     angles.i13[angles.nang][2] = ib;
69     angles.i13[angles.nang][3] = 0;
70     angles.nang++;
71     } else if (jj == 3 && atom[i].type < 300)
72     {
73     if (icoord == 0)
74     {
75     ia = atom[i].iat[0];
76     ib = atom[i].iat[1];
77     ic = atom[i].iat[2];
78     } else
79     {
80     icoord = 0;
81     for(j=0; j < MAXIAT; j++)
82     {
83     if (atom[i].iat[j] !=0 && atom[i].bo[j] != 9)
84     {
85     itemp[icoord] = atom[i].iat[j];
86     icoord++;
87     }
88     }
89     ia = itemp[0];
90     ib = itemp[1];
91     ic = itemp[2];
92     }
93     angles.i13[angles.nang][0] = ia;
94     angles.i13[angles.nang][1] = i;
95     angles.i13[angles.nang][2] = ib;
96     angles.i13[angles.nang][3] = ic;
97     angles.nang++;
98     angles.i13[angles.nang][0] = ia;
99     angles.i13[angles.nang][1] = i;
100     angles.i13[angles.nang][2] = ic;
101     angles.i13[angles.nang][3] = ib;
102     angles.nang++;
103     angles.i13[angles.nang][0] = ib;
104     angles.i13[angles.nang][1] = i;
105     angles.i13[angles.nang][2] = ic;
106     angles.i13[angles.nang][3] = ia;
107     angles.nang++;
108     } else if (jj == 4 && atom[i].type < 300)
109     {
110     if (icoord == 0)
111     {
112     ia = atom[i].iat[0];
113     ib = atom[i].iat[1];
114     ic = atom[i].iat[2];
115     id = atom[i].iat[3];
116     } else
117     {
118     icoord = 0;
119     for (j=0; j < MAXIAT; j++)
120     {
121     if (atom[i].iat[j] != 0 && atom[i].bo[j] != 9)
122     {
123     itemp[icoord] = atom[i].iat[j];
124     icoord++;
125     }
126     }
127     ia = itemp[0];
128     ib = itemp[1];
129     ic = itemp[2];
130     id = itemp[3];
131     }
132     angles.i13[angles.nang][0] = ia;
133     angles.i13[angles.nang][1] = i;
134     angles.i13[angles.nang][2] = ib;
135     angles.i13[angles.nang][3] = 0;
136     angles.nang++;
137     angles.i13[angles.nang][0] = ia;
138     angles.i13[angles.nang][1] = i;
139     angles.i13[angles.nang][2] = ic;
140     angles.i13[angles.nang][3] = 0;
141     angles.nang++;
142     angles.i13[angles.nang][0] = ia;
143     angles.i13[angles.nang][1] = i;
144     angles.i13[angles.nang][2] = id;
145     angles.i13[angles.nang][3] = 0;
146     angles.nang++;
147     angles.i13[angles.nang][0] = ib;
148     angles.i13[angles.nang][1] = i;
149     angles.i13[angles.nang][2] = ic;
150     angles.i13[angles.nang][3] = 0;
151     angles.nang++;
152     angles.i13[angles.nang][0] = ib;
153     angles.i13[angles.nang][1] = i;
154     angles.i13[angles.nang][2] = id;
155     angles.i13[angles.nang][3] = 0;
156     angles.nang++;
157     angles.i13[angles.nang][0] = ic;
158     angles.i13[angles.nang][1] = i;
159     angles.i13[angles.nang][2] = id;
160     angles.i13[angles.nang][3] = 0;
161     angles.nang++;
162     } else if (jj == 5 && atom[i].type < 300)
163     {
164     if (icoord == 0)
165     {
166     ia = atom[i].iat[0];
167     ib = atom[i].iat[1];
168     ic = atom[i].iat[2];
169     id = atom[i].iat[3];
170     ie = atom[i].iat[4];
171     } else
172     {
173     icoord = 0;
174     for (j=0; j < MAXIAT; j++)
175     {
176     if (atom[i].iat[j] != 0 && atom[i].bo[j] != 9)
177     {
178     itemp[icoord] = atom[i].iat[j];
179     icoord++;
180     }
181     }
182     ia = itemp[0];
183     ib = itemp[1];
184     ic = itemp[2];
185     id = itemp[3];
186     ie = itemp[4];
187     }
188     angles.i13[angles.nang][0] = ia;
189     angles.i13[angles.nang][1] = i;
190     angles.i13[angles.nang][2] = ib;
191     angles.i13[angles.nang][3] = 0;
192     angles.nang++;
193     angles.i13[angles.nang][0] = ia;
194     angles.i13[angles.nang][1] = i;
195     angles.i13[angles.nang][2] = ic;
196     angles.i13[angles.nang][3] = 0;
197     angles.nang++;
198     angles.i13[angles.nang][0] = ia;
199     angles.i13[angles.nang][1] = i;
200     angles.i13[angles.nang][2] = id;
201     angles.i13[angles.nang][3] = 0;
202     angles.nang++;
203     angles.i13[angles.nang][0] = ia;
204     angles.i13[angles.nang][1] = i;
205     angles.i13[angles.nang][2] = ie;
206     angles.i13[angles.nang][3] = 0;
207     angles.nang++;
208     angles.i13[angles.nang][0] = ib;
209     angles.i13[angles.nang][1] = i;
210     angles.i13[angles.nang][2] = ic;
211     angles.i13[angles.nang][3] = 0;
212     angles.nang++;
213     angles.i13[angles.nang][0] = ib;
214     angles.i13[angles.nang][1] = i;
215     angles.i13[angles.nang][2] = id;
216     angles.i13[angles.nang][3] = 0;
217     angles.nang++;
218     angles.i13[angles.nang][0] = ib;
219     angles.i13[angles.nang][1] = i;
220     angles.i13[angles.nang][2] = ie;
221     angles.i13[angles.nang][3] = 0;
222     angles.nang++;
223     angles.i13[angles.nang][0] = ic;
224     angles.i13[angles.nang][1] = i;
225     angles.i13[angles.nang][2] = id;
226     angles.i13[angles.nang][3] = 0;
227     angles.nang++;
228     angles.i13[angles.nang][0] = ic;
229     angles.i13[angles.nang][1] = i;
230     angles.i13[angles.nang][2] = ie;
231     angles.i13[angles.nang][3] = 0;
232     angles.nang++;
233     angles.i13[angles.nang][0] = id;
234     angles.i13[angles.nang][1] = i;
235     angles.i13[angles.nang][2] = ie;
236     angles.i13[angles.nang][3] = 0;
237     angles.nang++;
238     } else if (jj == 5)
239     {
240     if (icoord == 0)
241     {
242     ia = atom[i].iat[0];
243     ib = atom[i].iat[1];
244     ic = atom[i].iat[2];
245     id = atom[i].iat[3];
246     ie = atom[i].iat[4];
247     // ia angles
248     high_coord.i13[high_coord.ncoord][0] = ia;
249     high_coord.i13[high_coord.ncoord][1] = i;
250     high_coord.i13[high_coord.ncoord][2] = ib;
251     high_coord.ncoord++;
252     high_coord.i13[high_coord.ncoord][0] = ia;
253     high_coord.i13[high_coord.ncoord][1] = i;
254     high_coord.i13[high_coord.ncoord][2] = ic;
255     high_coord.ncoord++;
256     high_coord.i13[high_coord.ncoord][0] = ia;
257     high_coord.i13[high_coord.ncoord][1] = i;
258     high_coord.i13[high_coord.ncoord][2] = id;
259     high_coord.ncoord++;
260     high_coord.i13[high_coord.ncoord][0] = ia;
261     high_coord.i13[high_coord.ncoord][1] = i;
262     high_coord.i13[high_coord.ncoord][2] = ie;
263     high_coord.ncoord++;
264     // ib angles
265     high_coord.i13[high_coord.ncoord][0] = ib;
266     high_coord.i13[high_coord.ncoord][1] = i;
267     high_coord.i13[high_coord.ncoord][2] = ic;
268     high_coord.ncoord++;
269     high_coord.i13[high_coord.ncoord][0] = ib;
270     high_coord.i13[high_coord.ncoord][1] = i;
271     high_coord.i13[high_coord.ncoord][2] = id;
272     high_coord.ncoord++;
273     high_coord.i13[high_coord.ncoord][0] = ib;
274     high_coord.i13[high_coord.ncoord][1] = i;
275     high_coord.i13[high_coord.ncoord][2] = ie;
276     high_coord.ncoord++;
277     // ic angles
278     high_coord.i13[high_coord.ncoord][0] = ic;
279     high_coord.i13[high_coord.ncoord][1] = i;
280     high_coord.i13[high_coord.ncoord][2] = id;
281     high_coord.ncoord++;
282     high_coord.i13[high_coord.ncoord][0] = ic;
283     high_coord.i13[high_coord.ncoord][1] = i;
284     high_coord.i13[high_coord.ncoord][2] = ie;
285     high_coord.ncoord++;
286     // id angles
287     high_coord.i13[high_coord.ncoord][0] = id;
288     high_coord.i13[high_coord.ncoord][1] = i;
289     high_coord.i13[high_coord.ncoord][2] = ie;
290     high_coord.ncoord++;
291     } else
292     {
293     icoord = 0;
294     for (j=0; j < MAXIAT; j++)
295     {
296     if (atom[i].iat[j] != 0 && atom[i].bo[j] != 9)
297     {
298     itemp[icoord] = atom[i].iat[j];
299     icoord++;
300     }
301     }
302     ia = itemp[0];
303     ib = itemp[1];
304     ic = itemp[2];
305     id = itemp[3];
306     ie = itemp[4];
307     // ia angles
308     high_coord.i13[high_coord.ncoord][0] = ia;
309     high_coord.i13[high_coord.ncoord][1] = i;
310     high_coord.i13[high_coord.ncoord][2] = ib;
311     high_coord.ncoord++;
312     high_coord.i13[high_coord.ncoord][0] = ia;
313     high_coord.i13[high_coord.ncoord][1] = i;
314     high_coord.i13[high_coord.ncoord][2] = ic;
315     high_coord.ncoord++;
316     high_coord.i13[high_coord.ncoord][0] = ia;
317     high_coord.i13[high_coord.ncoord][1] = i;
318     high_coord.i13[high_coord.ncoord][2] = id;
319     high_coord.ncoord++;
320     high_coord.i13[high_coord.ncoord][0] = ia;
321     high_coord.i13[high_coord.ncoord][1] = i;
322     high_coord.i13[high_coord.ncoord][2] = ie;
323     high_coord.ncoord++;
324     // ib angles
325     high_coord.i13[high_coord.ncoord][0] = ib;
326     high_coord.i13[high_coord.ncoord][1] = i;
327     high_coord.i13[high_coord.ncoord][2] = ic;
328     high_coord.ncoord++;
329     high_coord.i13[high_coord.ncoord][0] = ib;
330     high_coord.i13[high_coord.ncoord][1] = i;
331     high_coord.i13[high_coord.ncoord][2] = id;
332     high_coord.ncoord++;
333     high_coord.i13[high_coord.ncoord][0] = ib;
334     high_coord.i13[high_coord.ncoord][1] = i;
335     high_coord.i13[high_coord.ncoord][2] = ie;
336     high_coord.ncoord++;
337     // ic angles
338     high_coord.i13[high_coord.ncoord][0] = ic;
339     high_coord.i13[high_coord.ncoord][1] = i;
340     high_coord.i13[high_coord.ncoord][2] = id;
341     high_coord.ncoord++;
342     high_coord.i13[high_coord.ncoord][0] = ic;
343     high_coord.i13[high_coord.ncoord][1] = i;
344     high_coord.i13[high_coord.ncoord][2] = ie;
345     high_coord.ncoord++;
346     // id angles
347     high_coord.i13[high_coord.ncoord][0] = id;
348     high_coord.i13[high_coord.ncoord][1] = i;
349     high_coord.i13[high_coord.ncoord][2] = ie;
350     high_coord.ncoord++;
351     }
352     } else if (jj > 5)
353     {
354     for (j=0; j < MAXIAT; j++)
355     {
356     if (atom[i].iat[j] != 0 && atom[i].bo[j] != 9)
357     {
358     ia = atom[i].iat[j];
359     for (k=j+1; k < MAXIAT; k++)
360     {
361     if (atom[i].iat[k] != 0 && atom[i].bo[k] != 9)
362     {
363     high_coord.i13[high_coord.ncoord][0] = ia;
364     high_coord.i13[high_coord.ncoord][1] = i;
365     high_coord.i13[high_coord.ncoord][2] = atom[i].iat[k];
366     high_coord.ncoord++;
367     }
368     }
369     }
370     }
371     }
372    
373     if (angles.nang > MAXANG)
374     {
375     message_alert("Too many angles. PCMODEL will now exit","Angle Setup");
376     fprintf(pcmoutfile,"Too many angles. PCMODEL will now exit\n");
377     exit(0);
378     }
379     }
380     if (high_coord.ncoord > 0)
381     pot.use_highcoord = TRUE;
382    
383     for (i=0; i < angles.nang; i++)
384     angles.angin[i] = FALSE;
385     }
386    
387     int isangle(int i, int j)
388     {
389     int k,l,katm;
390     for (k=0; k < MAXIAT; k++)
391     {
392     if (atom[i].iat[k] != 0 && atom[i].bo[k] != 9)
393     {
394     katm = atom[i].iat[k];
395     for (l=0; l < MAXIAT; l++)
396     {
397     if (atom[katm].iat[l] == j)
398     return TRUE;
399     }
400     }
401     }
402     return FALSE;
403     }