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

Line File contents
1 #define EXTERN extern
2 #include "pcwin.h"
3 #include "pcmod.h"
4
5 #include "angles.h"
6 #include "pot.h"
7 #include "field.h"
8
9 EXTERN struct t_ooplane_k {
10 int nopbend;
11 char iopb[MAXOOP][13];
12 float copb[MAXOOP];
13 } ooplane_k;
14
15 void numeral(int,char *,int);
16 EXTERN int Missing_constants;
17 EXTERN FILE *errfile;
18
19 void kopbend()
20 {
21 int i, j, ia,ib,ic,id, jj, ierr;
22 int ita,itb, itc,itd, itd_class;
23 int it, it1;
24 long mask5, mask6, mask8;
25 char pa[4],pb[4],pc[4],pd[4],pdc[4],pt[13],pt1[13],pt2[13];
26
27 mask5 = 1L << SATMET_MASK;
28 mask6 = 1L << GT18e_MASK;
29 mask8 = 1L << SQPLAN_MASK;
30
31 if (ooplane_k.nopbend <= 0)
32 {
33 pot.use_opbend = FALSE;
34 return;
35 }
36 angles.nopb = 0;
37 for (i=0; i < angles.nang; i++)
38 {
39 ia = angles.i13[i][0];
40 ib = angles.i13[i][1];
41 ic = angles.i13[i][2];
42 ita = atom[ia].type;
43 itb = atom[ib].type;
44 itc = atom[ic].type;
45 ierr = FALSE;
46 if (angles.i13[i][3] != 0 )
47 {
48 // angle ia-ib-id-ic
49 id = angles.i13[i][3];
50 itd = atom[id].type;
51 itd_class = atom[id].tclass;
52 numeral(ita,pa,3);
53 numeral(itb,pb,3);
54 numeral(itc,pc,3);
55 numeral(itd,pd,3);
56 numeral(itd_class,pdc,3);
57 if (field.type == MMX || field.type == MM3)
58 {
59 strcpy(pt," 0"); strcat(pt,pb); strcat(pt,pd); strcat(pt," 0");
60 }else if (field.type == MMFF94)
61 {
62 if (ita <= itc && ita <= itd)
63 {
64 if (itc <= itd)
65 {
66 strcpy(pt,pa); strcat(pt,pb); strcat(pt,pc); strcat(pt,pd);
67 } else
68 {
69 strcpy(pt,pa); strcat(pt,pb); strcat(pt,pd); strcat(pt,pc);
70 }
71 } else if ( itc <= ita && itc <= itd)
72 {
73 if (ita <= itd)
74 {
75 strcpy(pt,pc); strcat(pt,pb); strcat(pt,pa); strcat(pt,pd);
76 } else
77 {
78 strcpy(pt,pc); strcat(pt,pb); strcat(pt,pd); strcat(pt,pa);
79 }
80 } else if (itd <= ita && itd <= itc)
81 {
82 if ( ita <= itc)
83 {
84 strcpy(pt,pd); strcat(pt,pb); strcat(pt,pa); strcat(pt,pc);
85 } else
86 {
87 strcpy(pt,pd); strcat(pt,pb); strcat(pt,pc); strcat(pt,pa);
88 }
89 }
90 }
91 strcpy(pt1," 0"); strcat(pt1,pb); strcat(pt1,pdc); strcat(pt1," 0");
92 strcpy(pt2," 0"); strcat(pt2,pb); strcat(pt2," 0"); strcat(pt2," 0");
93 it = itb*100 + itd;
94 it1 = itb*100;
95 ierr = FALSE;
96 for (j=0; j < ooplane_k.nopbend; j++)
97 {
98 if (strcmp(pt,ooplane_k.iopb[j]) == 0 || strcmp(pt1,ooplane_k.iopb[j]) == 0 || strcmp(pt2,ooplane_k.iopb[j]) == 0)
99 {
100 angles.copb[i] = ooplane_k.copb[j];
101 angles.angin[i] = TRUE;
102 angles.nopb++;
103 ierr = TRUE;
104 break;
105 }
106 }
107 }
108 }
109 // look for sq planar metals
110 for (i=1; i <= natom; i++)
111 {
112 if (atom[i].type >= 300)
113 {
114 jj = 0;
115 for (j=0; j < MAXIAT; j++)
116 {
117 if (atom[i].iat[j] != 0)
118 jj++;
119 }
120 if (jj == 4)
121 {
122 strcpy(pt1," 0"); strcat(pt1,"300"); strcat(pt1," 0"); strcat(pt1," 0");
123 if ( (atom[i].flags & mask5) && (atom[i].flags & mask6) && (atom[i].flags & mask8) )
124 {
125 for (j=0; j < ooplane_k.nopbend; j++)
126 {
127 if (strcmp(pt,ooplane_k.iopb[j]) == 0 || strcmp(pt1,ooplane_k.iopb[j]) == 0)
128 {
129 angles.i13[angles.nang][0] = atom[i].iat[0];
130 angles.i13[angles.nang][1] = i;
131 angles.i13[angles.nang][2] = atom[i].iat[1];
132 angles.i13[angles.nang][3] = atom[i].iat[2];
133 angles.copb[angles.nang] = ooplane_k.copb[j];
134 angles.angin[angles.nang] = TRUE;
135 angles.nang++;
136 angles.nopb++;
137 angles.i13[angles.nang][0] = atom[i].iat[0];
138 angles.i13[angles.nang][1] = i;
139 angles.i13[angles.nang][2] = atom[i].iat[2];
140 angles.i13[angles.nang][3] = atom[i].iat[1];
141 angles.copb[angles.nang] = ooplane_k.copb[j];
142 angles.angin[angles.nang] = TRUE;
143 angles.nang++;
144 angles.nopb++;
145 angles.i13[angles.nang][0] = atom[i].iat[0];
146 angles.i13[angles.nang][1] = i;
147 angles.i13[angles.nang][2] = atom[i].iat[3];
148 angles.i13[angles.nang][3] = atom[i].iat[1];
149 angles.copb[angles.nang] = ooplane_k.copb[j];
150 angles.angin[angles.nang] = TRUE;
151 angles.nang++;
152 angles.nopb++;
153
154 angles.i13[angles.nang][0] = atom[i].iat[1];
155 angles.i13[angles.nang][1] = i;
156 angles.i13[angles.nang][2] = atom[i].iat[2];
157 angles.i13[angles.nang][3] = atom[i].iat[0];
158 angles.copb[angles.nang] = ooplane_k.copb[j];
159 angles.angin[angles.nang] = TRUE;
160 angles.nang++;
161 angles.nopb++;
162 angles.i13[angles.nang][0] = atom[i].iat[1];
163 angles.i13[angles.nang][1] = i;
164 angles.i13[angles.nang][2] = atom[i].iat[3];
165 angles.i13[angles.nang][3] = atom[i].iat[0];
166 angles.copb[angles.nang] = ooplane_k.copb[j];
167 angles.angin[angles.nang] = TRUE;
168 angles.nang++;
169 angles.nopb++;
170
171 angles.i13[angles.nang][0] = atom[i].iat[2];
172 angles.i13[angles.nang][1] = i;
173 angles.i13[angles.nang][2] = atom[i].iat[3];
174 angles.i13[angles.nang][3] = atom[i].iat[0];
175 angles.copb[angles.nang] = ooplane_k.copb[j];
176 angles.angin[angles.nang] = TRUE;
177 angles.nang++;
178 angles.nopb++;
179 break;
180 }
181 }
182 }
183 }
184 }
185 }
186 //
187 if (angles.nopb == 0)
188 pot.use_opbend = FALSE;
189 }