ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/freemol/trunk/src/mengine/src/kdipole.c
Revision: 27
Committed: Tue Jul 8 19:10:25 2008 UTC (11 years, 10 months ago) by tjod
File size: 7924 byte(s)
Log Message:
move mengine src to reflect new freemol directory structure

Line User Rev File contents
1 tjod 3 #define EXTERN extern
2    
3     #include "pcwin.h"
4     #include "pcmod.h"
5     #include "bonds_ff.h"
6     #include "rings.h"
7     #include "pot.h"
8     #include "field.h"
9    
10     void numeral(int, char *, int);
11    
12    
13     EXTERN struct t_bondk1 {
14     int use_ring3, use_ring4, use_ring5, ndeloc;
15     int nbnd, nbnd3, nbnd4, nbnd5;
16     char kb[MAXBONDCONST][7], kb3[MAXBOND3CONST][7],kb4[MAXBOND4CONST][7],kb5[MAXBOND5CONST][7];
17     char kbdel[MAXBONDDELOC][7];
18     float s[MAXBONDCONST], t[MAXBONDCONST];
19     float s3[MAXBOND3CONST], t3[MAXBOND3CONST];
20     float s4[MAXBOND4CONST], t4[MAXBOND4CONST];
21     float s5[MAXBOND5CONST], t5[MAXBOND5CONST];
22     float sdel[MAXBONDDELOC], tdel[MAXBONDDELOC];
23     } bondk1;
24    
25    
26     EXTERN struct t_bondpk {
27     int npibond,npibond44i,npibond45i,npibond46i,npibond55i,npibond56i,npibond66i;
28     int npibond44o,npibond45o,npibond46o,npibond55o,npibond56o,npibond66o;
29     int npibond40,npibond50,npibond60;
30     int use_pibond,use_pibond44i,use_pibond45i,use_pibond46i,use_pibond55i,use_pibond56i,use_pibond66i;
31     int use_pibond44o,use_pibond45o,use_pibond46o,use_pibond55o,use_pibond56o,use_pibond66o;
32     int use_pibond40,use_pibond50,use_pibond60;
33     char kb[MAXPIBONDCONST][7],kb44i[20][7],kb45i[20][7],kb46i[20][7],kb55i[20][7],kb56i[20][7],kb66i[20][7];
34     char kb44o[20][7],kb45o[20][7],kb46o[20][7],kb55o[20][7],kb56o[20][7],kb66o[20][7];
35     char kb40[20][7],kb50[20][7],kb60[20][7];
36     float bk[MAXPIBONDCONST], bl[MAXPIBONDCONST], bmom[MAXPIBONDCONST],sslop[MAXPIBONDCONST], tslop[MAXPIBONDCONST], tslop2[MAXPIBONDCONST];
37     float bk44i[20], bl44i[20], bmom44i[20],sslop44i[20], tslop44i[20], tslop244i[20];
38     float bk45i[20], bl45i[20], bmom45i[20],sslop45i[20], tslop45i[20], tslop245i[20];
39     float bk46i[20], bl46i[20], bmom46i[20],sslop46i[20], tslop46i[20], tslop246i[20];
40     float bk55i[20], bl55i[20], bmom55i[20],sslop55i[20], tslop55i[20], tslop255i[20];
41     float bk56i[20], bl56i[20], bmom56i[20],sslop56i[20], tslop56i[20], tslop256i[20];
42     float bk66i[20], bl66i[20], bmom66i[20],sslop66i[20], tslop66i[20], tslop266i[20];
43     float bk44o[20], bl44o[20], bmom44o[20],sslop44o[20], tslop44o[20], tslop244o[20];
44     float bk45o[20], bl45o[20], bmom45o[20],sslop45o[20], tslop45o[20], tslop245o[20];
45     float bk46o[20], bl46o[20], bmom46o[20],sslop46o[20], tslop46o[20], tslop246o[20];
46     float bk55o[20], bl55o[20], bmom55o[20],sslop55o[20], tslop55o[20], tslop255o[20];
47     float bk56o[20], bl56o[20], bmom56o[20],sslop56o[20], tslop56o[20], tslop256o[20];
48     float bk66o[20], bl66o[20], bmom66o[20],sslop66o[20], tslop66o[20], tslop266o[20];
49     float bk40[20], bl40[20], bmom40[20],sslop40[20], tslop40[20], tslop240[20];
50     float bk50[20], bl50[20], bmom50[20],sslop50[20], tslop50[20], tslop250[20];
51     float bk60[20], bl60[20], bmom60[20],sslop60[20], tslop60[20], tslop260[20];
52     } bondpk;
53    
54     EXTERN struct t_dipole_k {
55     int ndipole,ndipole3,ndipole4,ndipole5;
56     char kb[MAXBONDCONST][7], kb3[MAXBOND3CONST][7], kb4[MAXBOND4CONST][7], kb5[MAXBOND5CONST][7];
57     float bmom[MAXBONDCONST],bmom3[MAXBOND3CONST],bmom4[MAXBOND4CONST],bmom5[MAXBOND5CONST];
58     } dipole_k;
59    
60     EXTERN int Missing_constants;
61     EXTERN FILE *errfile;
62    
63     void kdipole()
64     {
65     int i, j, ia, ib, ita, itb, it;
66     int ierr, use_dipole;
67     long int mask;
68     char pa[4],pb[4],pt[7];
69    
70     mask = 1L << 0;
71     use_dipole = FALSE;
72    
73     for (i=0; i < bonds_ff.nbnd; i++)
74     {
75     bonds_ff.bmom[i] = 0.0;
76     ia = bonds_ff.i12[i][0];
77     ib = bonds_ff.i12[i][1];
78     bonds_ff.idpl[i][0] = -1;
79     bonds_ff.idpl[i][1] = -1;
80     ita = atom[ia].type;
81     itb = atom[ib].type;
82     numeral(ita,pa,3);
83     numeral(itb,pb,3);
84     if(ita < itb )
85     {
86     it = ita*100+itb;
87     strcpy(pt,pa);
88     strcat(pt,pb);
89     } else
90     {
91     it = itb*100+ita;
92     strcpy(pt,pb);
93     strcat(pt,pa);
94     }
95    
96     ierr = FALSE;
97     // Do we need to check for transition state atoms
98     if (bondpk.use_pibond == TRUE)
99     {
100     if ( (atom[ia].flags & mask) && (atom[ib].flags & mask) )
101     {
102     for (j=0; j < bondpk.npibond; j++)
103     {
104     if (strcmp(pt,bondpk.kb[j]) == 0)
105     {
106     if (ita <= itb )
107     {
108     bonds_ff.idpl[i][0] = ia;
109     bonds_ff.idpl[i][1] = ib;
110     } else
111     {
112     bonds_ff.idpl[i][0] = ib;
113     bonds_ff.idpl[i][1] = ia;
114     }
115     bonds_ff.bmom[i] = bondpk.bmom[j];
116     ierr = TRUE;
117     use_dipole = TRUE;
118     break;
119     }
120     }
121     }
122     }
123     if (ierr == TRUE)
124     goto L_10;
125     // check for metals
126     // check 5 membered rings
127     if (rings.nring5 > 0 && bondk1.use_ring5 == TRUE)
128     {
129     for (j=0; j < dipole_k.ndipole5; j++)
130     {
131     if (strcmp(dipole_k.kb5[j],pt) == 0)
132     {
133     if (ita <= itb )
134     {
135     bonds_ff.idpl[i][0] = ia;
136     bonds_ff.idpl[i][1] = ib;
137     } else
138     {
139     bonds_ff.idpl[i][0] = ib;
140     bonds_ff.idpl[i][1] = ia;
141     }
142     bonds_ff.bmom[i] = dipole_k.bmom5[j];
143     ierr = TRUE;
144     use_dipole = TRUE;
145     break;
146     }
147     }
148     }
149     if (ierr == TRUE)
150     goto L_10;
151     // check 4 membered rings
152     if (rings.nring4 > 0 && bondk1.use_ring4 == TRUE)
153     {
154     for (j=0; j < dipole_k.ndipole4; j++)
155     {
156     if (strcmp(dipole_k.kb4[j],pt) == 0)
157     {
158     if (ita <= itb )
159     {
160     bonds_ff.idpl[i][0] = ia;
161     bonds_ff.idpl[i][1] = ib;
162     } else
163     {
164     bonds_ff.idpl[i][0] = ib;
165     bonds_ff.idpl[i][1] = ia;
166     }
167     bonds_ff.bmom[i] = dipole_k.bmom4[j];
168     ierr = TRUE;
169     use_dipole = TRUE;
170     break;
171     }
172     }
173     }
174     if (ierr == TRUE)
175     goto L_10;
176     // check 3 membered rings
177     if (rings.nring3 > 0 && bondk1.use_ring3 == TRUE)
178     {
179     for (j=0; j < dipole_k.ndipole3; j++)
180     {
181     if (strcmp(dipole_k.kb3[j],pt) == 0)
182     {
183     if (ita <= itb )
184     {
185     bonds_ff.idpl[i][0] = ia;
186     bonds_ff.idpl[i][1] = ib;
187     } else
188     {
189     bonds_ff.idpl[i][0] = ib;
190     bonds_ff.idpl[i][1] = ia;
191     }
192     bonds_ff.bmom[i] = dipole_k.bmom3[j];
193     ierr = TRUE;
194     use_dipole = TRUE;
195     break;
196     }
197     }
198     }
199     if (ierr == TRUE)
200     goto L_10;
201    
202     // regular constants
203     for (j=0; j < dipole_k.ndipole; j++)
204     {
205     if (strcmp(dipole_k.kb[j],pt) ==0)
206     {
207     if (ita <= itb )
208     {
209     bonds_ff.idpl[i][0] = ia;
210     bonds_ff.idpl[i][1] = ib;
211     } else
212     {
213     bonds_ff.idpl[i][0] = ib;
214     bonds_ff.idpl[i][1] = ia;
215     }
216     bonds_ff.bmom[i] = dipole_k.bmom[j];
217     ierr = TRUE;
218     use_dipole = TRUE;
219     break;
220     }
221     }
222     L_10:
223     continue;
224     }
225     // if (use_dipole == FALSE)
226     // pot.use_dipole = FALSE;
227    
228     }