ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/freemol/trunk/src/mengine/src/angles.c
Revision: 85
Committed: Mon Jan 12 15:05:44 2009 UTC (10 years, 9 months ago) by gilbertke
File size: 8453 byte(s)
Log Message:
more cleanup and code removal
Line File contents
1 #define EXTERN extern
2
3 #include "pcwin.h"
4 #include "pcmod.h"
5
6 #include "angles.h"
7 #include "field.h"
8 #include "pot.h"
9
10 static int isangle(int, int);
11
12 void get_angles()
13 {
14 int i,j,k,icount;
15 int ia, ib, ic, id, ie;
16 int jj, icoord;
17 int itemp[5];
18
19 angles.nang = 0;
20 for (i=0; i < MAXANG; i++)
21 {
22 angles.i13[i][0] = 0;
23 angles.i13[i][1] = 0;
24 angles.i13[i][2] = 0;
25 angles.i13[i][3] = 0;
26 }
27 //
28 for (i = 1; i <= natom; i++)
29 {
30 jj = 0;
31 icoord = 0;
32 for (j=0; j < MAXIAT; j++)
33 {
34 if (atom[i].iat[j] != 0 && atom[i].bo[j] != 9)
35 jj++;
36 if (atom[i].bo[j] == 9)
37 icoord++;
38 }
39
40 if (jj == 2 && atom[i].type < 300)
41 {
42 icount = 0;
43 for (j=0; j < MAXIAT; j++)
44 {
45 if (atom[i].iat[j] != 0 && atom[i].bo[j] != 9)
46 {
47 icount++;
48 if (icount == 1)
49 ia = atom[i].iat[j];
50 else if (icount == 2)
51 {
52 ib = atom[i].iat[j];
53 break;
54 }
55 }
56 }
57 angles.i13[angles.nang][0] = ia;
58 angles.i13[angles.nang][1] = i;
59 angles.i13[angles.nang][2] = ib;
60 angles.i13[angles.nang][3] = 0;
61 angles.nang++;
62 } else if (jj == 3 && atom[i].type < 300)
63 {
64 if (icoord == 0)
65 {
66 ia = atom[i].iat[0];
67 ib = atom[i].iat[1];
68 ic = atom[i].iat[2];
69 } else
70 {
71 icoord = 0;
72 for(j=0; j < MAXIAT; j++)
73 {
74 if (atom[i].iat[j] !=0 && atom[i].bo[j] != 9)
75 {
76 itemp[icoord] = atom[i].iat[j];
77 icoord++;
78 }
79 }
80 ia = itemp[0];
81 ib = itemp[1];
82 ic = itemp[2];
83 }
84 angles.i13[angles.nang][0] = ia;
85 angles.i13[angles.nang][1] = i;
86 angles.i13[angles.nang][2] = ib;
87 angles.i13[angles.nang][3] = ic;
88 angles.nang++;
89 angles.i13[angles.nang][0] = ia;
90 angles.i13[angles.nang][1] = i;
91 angles.i13[angles.nang][2] = ic;
92 angles.i13[angles.nang][3] = ib;
93 angles.nang++;
94 angles.i13[angles.nang][0] = ib;
95 angles.i13[angles.nang][1] = i;
96 angles.i13[angles.nang][2] = ic;
97 angles.i13[angles.nang][3] = ia;
98 angles.nang++;
99 } else if (jj == 4 && atom[i].type < 300)
100 {
101 if (icoord == 0)
102 {
103 ia = atom[i].iat[0];
104 ib = atom[i].iat[1];
105 ic = atom[i].iat[2];
106 id = atom[i].iat[3];
107 } else
108 {
109 icoord = 0;
110 for (j=0; j < MAXIAT; j++)
111 {
112 if (atom[i].iat[j] != 0 && atom[i].bo[j] != 9)
113 {
114 itemp[icoord] = atom[i].iat[j];
115 icoord++;
116 }
117 }
118 ia = itemp[0];
119 ib = itemp[1];
120 ic = itemp[2];
121 id = itemp[3];
122 }
123 angles.i13[angles.nang][0] = ia;
124 angles.i13[angles.nang][1] = i;
125 angles.i13[angles.nang][2] = ib;
126 angles.i13[angles.nang][3] = 0;
127 angles.nang++;
128 angles.i13[angles.nang][0] = ia;
129 angles.i13[angles.nang][1] = i;
130 angles.i13[angles.nang][2] = ic;
131 angles.i13[angles.nang][3] = 0;
132 angles.nang++;
133 angles.i13[angles.nang][0] = ia;
134 angles.i13[angles.nang][1] = i;
135 angles.i13[angles.nang][2] = id;
136 angles.i13[angles.nang][3] = 0;
137 angles.nang++;
138 angles.i13[angles.nang][0] = ib;
139 angles.i13[angles.nang][1] = i;
140 angles.i13[angles.nang][2] = ic;
141 angles.i13[angles.nang][3] = 0;
142 angles.nang++;
143 angles.i13[angles.nang][0] = ib;
144 angles.i13[angles.nang][1] = i;
145 angles.i13[angles.nang][2] = id;
146 angles.i13[angles.nang][3] = 0;
147 angles.nang++;
148 angles.i13[angles.nang][0] = ic;
149 angles.i13[angles.nang][1] = i;
150 angles.i13[angles.nang][2] = id;
151 angles.i13[angles.nang][3] = 0;
152 angles.nang++;
153 } else if (jj == 5 && atom[i].type < 300)
154 {
155 if (icoord == 0)
156 {
157 ia = atom[i].iat[0];
158 ib = atom[i].iat[1];
159 ic = atom[i].iat[2];
160 id = atom[i].iat[3];
161 ie = atom[i].iat[4];
162 } else
163 {
164 icoord = 0;
165 for (j=0; j < MAXIAT; j++)
166 {
167 if (atom[i].iat[j] != 0 && atom[i].bo[j] != 9)
168 {
169 itemp[icoord] = atom[i].iat[j];
170 icoord++;
171 }
172 }
173 ia = itemp[0];
174 ib = itemp[1];
175 ic = itemp[2];
176 id = itemp[3];
177 ie = itemp[4];
178 }
179 angles.i13[angles.nang][0] = ia;
180 angles.i13[angles.nang][1] = i;
181 angles.i13[angles.nang][2] = ib;
182 angles.i13[angles.nang][3] = 0;
183 angles.nang++;
184 angles.i13[angles.nang][0] = ia;
185 angles.i13[angles.nang][1] = i;
186 angles.i13[angles.nang][2] = ic;
187 angles.i13[angles.nang][3] = 0;
188 angles.nang++;
189 angles.i13[angles.nang][0] = ia;
190 angles.i13[angles.nang][1] = i;
191 angles.i13[angles.nang][2] = id;
192 angles.i13[angles.nang][3] = 0;
193 angles.nang++;
194 angles.i13[angles.nang][0] = ia;
195 angles.i13[angles.nang][1] = i;
196 angles.i13[angles.nang][2] = ie;
197 angles.i13[angles.nang][3] = 0;
198 angles.nang++;
199 angles.i13[angles.nang][0] = ib;
200 angles.i13[angles.nang][1] = i;
201 angles.i13[angles.nang][2] = ic;
202 angles.i13[angles.nang][3] = 0;
203 angles.nang++;
204 angles.i13[angles.nang][0] = ib;
205 angles.i13[angles.nang][1] = i;
206 angles.i13[angles.nang][2] = id;
207 angles.i13[angles.nang][3] = 0;
208 angles.nang++;
209 angles.i13[angles.nang][0] = ib;
210 angles.i13[angles.nang][1] = i;
211 angles.i13[angles.nang][2] = ie;
212 angles.i13[angles.nang][3] = 0;
213 angles.nang++;
214 angles.i13[angles.nang][0] = ic;
215 angles.i13[angles.nang][1] = i;
216 angles.i13[angles.nang][2] = id;
217 angles.i13[angles.nang][3] = 0;
218 angles.nang++;
219 angles.i13[angles.nang][0] = ic;
220 angles.i13[angles.nang][1] = i;
221 angles.i13[angles.nang][2] = ie;
222 angles.i13[angles.nang][3] = 0;
223 angles.nang++;
224 angles.i13[angles.nang][0] = id;
225 angles.i13[angles.nang][1] = i;
226 angles.i13[angles.nang][2] = ie;
227 angles.i13[angles.nang][3] = 0;
228 angles.nang++;
229 }
230
231 if (angles.nang > MAXANG)
232 {
233 message_alert("Too many angles. PCMODEL will now exit","Angle Setup");
234 fprintf(pcmlogfile,"Too many angles. PCMODEL will now exit\n");
235 exit(0);
236 }
237 }
238
239 for (i=0; i < angles.nang; i++)
240 angles.angin[i] = FALSE;
241 }
242
243 int isangle(int i, int j)
244 {
245 int k,l,katm;
246 for (k=0; k < MAXIAT; k++)
247 {
248 if (atom[i].iat[k] != 0 && atom[i].bo[k] != 9)
249 {
250 katm = atom[i].iat[k];
251 for (l=0; l < MAXIAT; l++)
252 {
253 if (atom[katm].iat[l] == j)
254 return TRUE;
255 }
256 }
257 }
258 return FALSE;
259 }