ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/freemol/branches/sync4pymol12/src/mengine/src/get_mem.c
Revision: 99
Committed: Mon Jan 19 04:31:29 2009 UTC (10 years, 9 months ago) by wdelano
File size: 8380 byte(s)
Log Message:
synchronized with trunk, less openmp lib/include
Line File contents
1 #define EXTERN extern
2
3 #include "pcwin.h"
4 #include "pcmod.h"
5 #include "attached.h"
6 #include "derivs.h"
7 #include "hess.h"
8 #include "rings.h"
9 #include "utility.h"
10 #include "nonbond.h"
11 #include "torsions.h"
12 #include "solv.h"
13 #include "pot.h"
14
15 void max_torsions(void);
16
17
18 #define STILL 1
19 #define HCT 2
20
21 EXTERN struct t_solvent {
22 int type;
23 double doffset, p1,p2,p3,p4,p5;
24 double *shct,*asolv,*rsolv,*vsolv,*gpol,*rborn;
25 } solvent;
26
27
28 /* ================================================================ */
29 void get_memory()
30 {
31 int i, j;
32 int ntor;
33 int ntypes, found, itype[MAXATOMTYPE];
34
35 skip = imatrix(0,natom+1,0,natom+1);
36 for (i=1; i <= natom; i++)
37 {
38 for (j=1; j <=natom; j++)
39 skip[i][j] = 0;
40 }
41
42 deriv.d1 = dmatrix(0,natom+1, 0,3);
43 deriv.deb = dmatrix(0,natom+1, 0,3);
44 deriv.dea = dmatrix(0,natom+1, 0,3);
45 deriv.destb = dmatrix(0,natom+1, 0,3);
46 deriv.deopb = dmatrix(0,natom+1, 0,3);
47 deriv.detor = dmatrix(0,natom+1, 0,3);
48 deriv.de14 = dmatrix(0,natom+1, 0,3);
49 deriv.devdw = dmatrix(0,natom+1, 0,3);
50 deriv.deqq = dmatrix(0,natom+1, 0,3);
51 deriv.deaa = dmatrix(0,natom+1, 0,3);
52 deriv.destor = dmatrix(0,natom+1, 0,3);
53 deriv.dehb = dmatrix(0,natom+1, 0,3);
54 deriv.deimprop = dmatrix(0,natom+1, 0,3);
55 deriv.deub = dmatrix(0,natom+1, 0,3);
56 deriv.desolv = dmatrix(0,natom+1, 0,3);
57 deriv.degeom = dmatrix(0,natom+1, 0,3);
58 deriv.drb = dvector(0,natom+1);
59
60 ntypes = 0;
61 nonbond.maxnbtype = 0;
62
63 for (i=1; i <= natom; i++)
64 {
65 found = FALSE;
66 if (atom[i].type > nonbond.maxnbtype)
67 nonbond.maxnbtype = atom[i].type;
68 for (j=0; j < ntypes; j++)
69 {
70 if (atom[i].type == itype[j])
71 {
72 found = TRUE;
73 break;
74 }
75 }
76 if (found == FALSE)
77 {
78 itype[ntypes] = atom[i].type;
79 ntypes++;
80 }
81 }
82
83 j=0;
84 for (i=0; i <= ntypes; i++)
85 j+= i;
86
87 nonbond.nonbond = j;
88 nonbond.iNBtype = imatrix(0,nonbond.maxnbtype+1, 0,nonbond.maxnbtype+1);
89 nonbond.ipif = imatrix(0,nonbond.maxnbtype+1, 0,nonbond.maxnbtype+1);
90 nonbond.vrad = matrix(0,nonbond.maxnbtype+1, 0,nonbond.maxnbtype+1);
91 nonbond.veps = matrix(0,nonbond.maxnbtype+1, 0,nonbond.maxnbtype+1);
92 nonbond.vrad14 = matrix(0,nonbond.maxnbtype+1, 0,nonbond.maxnbtype+1);
93 nonbond.veps14 = matrix(0,nonbond.maxnbtype+1, 0,nonbond.maxnbtype+1);
94
95 max_torsions();
96 ntor = torsions.ntor;
97 if (ntor > 0)
98 {
99 torsions.i14 = imatrix(0,ntor,0,4);
100 torsions.v1 = vector(0,ntor);
101 torsions.v2 = vector(0,ntor);
102 torsions.v3 = vector(0,ntor);
103 torsions.v4 = vector(0,ntor);
104 torsions.v5 = vector(0,ntor);
105 torsions.v6 = vector(0,ntor);
106 torsions.ph1 = ivector(0,ntor);
107 torsions.ph2 = ivector(0,ntor);
108 torsions.ph3 = ivector(0,ntor);
109 torsions.ph4 = ivector(0,ntor);
110 torsions.ph5 = ivector(0,ntor);
111 torsions.ph6 = ivector(0,ntor);
112 for (i=0; i < ntor; i++)
113 {
114 torsions.v1[i] = 0.0;
115 torsions.v2[i] = 0.0;
116 torsions.v3[i] = 0.0;
117 torsions.v4[i] = 0.0;
118 torsions.v5[i] = 0.0;
119 torsions.v6[i] = 0.0;
120 torsions.ph1[i] = 0;
121 torsions.ph2[i] = 0;
122 torsions.ph3[i] = 0;
123 torsions.ph4[i] = 0;
124 torsions.ph5[i] = 0;
125 torsions.ph6[i] = 0;
126 }
127 }
128 hess.hessx = matrix(0,natom+1, 0,3);
129 hess.hessy = matrix(0,natom+1, 0,3);
130 hess.hessz = matrix(0,natom+1, 0,3);
131
132 rings.r13 = imatrix(0,natom+1, 0,3);
133 rings.r14 = imatrix(0,natom+1, 0,4);
134 rings.r15 = imatrix(0,natom+1, 0,5);
135 rings.r16 = imatrix(0,natom+1, 0,6);
136
137 attached.n13 = ivector(0,natom+1);
138 attached.n14 = ivector(0,natom+1);
139 attached.i13 = imatrix(0, 20, 0,natom+1);
140 attached.i14 = imatrix(0,144, 0,natom+1);
141
142 for(i=0; i <= natom; i++)
143 {
144 for (j=0; j < 3; j++)
145 {
146 deriv.d1[i][j] = 0.0;
147 deriv.deb[i][j] = 0.0;
148 deriv.dea[i][j] = 0.0;
149 deriv.destb[i][j] = 0.0;
150 deriv.deopb[i][j] = 0.0;
151 deriv.detor[i][j] = 0.0;
152 deriv.de14[i][j] = 0.0;
153 deriv.devdw[i][j] = 0.0;
154 deriv.deqq[i][j] = 0.0;
155 deriv.deaa[i][j] = 0.0;
156 deriv.destor[i][j] = 0.0;
157 deriv.dehb[i][j] = 0.0;
158 deriv.deimprop[i][j] = 0.0;
159 deriv.deub[i][j] = 0.0;
160
161 hess.hessx[i][j] = 0.0;
162 hess.hessy[i][j] = 0.0;
163 hess.hessz[i][j] = 0.0;
164 }
165 }
166 if (pot.use_solv)
167 {
168 solvent.asolv = dvector(0,natom+1);
169 solvent.rsolv = dvector(0,natom+1);
170 solvent.rborn = dvector(0,natom+1);
171 if (solvent.type == STILL)
172 {
173 solvent.vsolv = dvector(0,natom+1);
174 solvent.gpol = dvector(0,natom+1);
175 } else if (solvent.type == HCT)
176 {
177 solvent.shct = dvector(0,natom+1);
178 }
179 }
180 }
181
182 void free_memory()
183 {
184 int ntor;
185 free_imatrix(skip, 0, natom+1,0,natom+1);
186 free_dmatrix(deriv.d1, 0,natom+1, 0,3);
187 free_dmatrix(deriv.deb, 0,natom+1, 0,3);
188 free_dmatrix(deriv.dea, 0,natom+1, 0,3);
189 free_dmatrix(deriv.destb, 0,natom+1, 0,3);
190 free_dmatrix(deriv.deopb, 0,natom+1, 0,3);
191 free_dmatrix(deriv.detor, 0,natom+1, 0,3);
192 free_dmatrix(deriv.de14, 0,natom+1, 0,3);
193 free_dmatrix(deriv.devdw, 0,natom+1, 0,3);
194 free_dmatrix(deriv.deqq, 0,natom+1, 0,3);
195 free_dmatrix(deriv.deaa, 0,natom+1, 0,3);
196 free_dmatrix(deriv.destor, 0,natom+1, 0,3);
197 free_dmatrix(deriv.dehb, 0,natom+1, 0,3);
198 free_dmatrix(deriv.deimprop,0,natom+1, 0,3);
199 free_dmatrix(deriv.deub, 0,natom+1, 0,3);
200 free_dmatrix(deriv.desolv ,0,natom+1, 0,3);
201 free_dmatrix(deriv.degeom ,0,natom+1, 0,3);
202 free_dvector(deriv.drb ,0,natom+1);
203
204 free_imatrix(nonbond.iNBtype ,0,nonbond.maxnbtype+1, 0,nonbond.maxnbtype+1);
205 free_imatrix(nonbond.ipif ,0,nonbond.maxnbtype+1, 0,nonbond.maxnbtype+1);
206 free_matrix(nonbond.vrad ,0,nonbond.maxnbtype+1, 0,nonbond.maxnbtype+1);
207 free_matrix(nonbond.veps ,0,nonbond.maxnbtype+1, 0,nonbond.maxnbtype+1);
208 free_matrix(nonbond.vrad14 ,0,nonbond.maxnbtype+1, 0,nonbond.maxnbtype+1);
209 free_matrix(nonbond.veps14 ,0,nonbond.maxnbtype+1, 0,nonbond.maxnbtype+1);
210
211 // ntor = 9*natom;
212 ntor = torsions.ntor;
213 if (ntor > 0)
214 {
215 free_imatrix(torsions.i14 ,0,ntor,0,4);
216 free_vector(torsions.v1 ,0,ntor);
217 free_vector(torsions.v2 ,0,ntor);
218 free_vector(torsions.v3 ,0,ntor);
219 free_vector(torsions.v4 ,0,ntor);
220 free_vector(torsions.v5 ,0,ntor);
221 free_vector(torsions.v6 ,0,ntor);
222 free_ivector(torsions.ph1 ,0,ntor);
223 free_ivector(torsions.ph2 ,0,ntor);
224 free_ivector(torsions.ph3 ,0,ntor);
225 free_ivector(torsions.ph4 ,0,ntor);
226 free_ivector(torsions.ph5 ,0,ntor);
227 free_ivector(torsions.ph6 ,0,ntor);
228 }
229
230 free_matrix(hess.hessx, 0,natom+1, 0,3);
231 free_matrix(hess.hessy, 0,natom+1, 0,3);
232 free_matrix(hess.hessz, 0,natom+1, 0,3);
233
234 free_imatrix(rings.r13, 0,natom+1, 0,3);
235 free_imatrix(rings.r14, 0,natom+1, 0,4);
236 free_imatrix(rings.r15, 0,natom+1, 0,5);
237 free_imatrix(rings.r16, 0,natom+1, 0,6);
238 free_ivector(attached.n13 ,0,natom+1);
239 free_ivector(attached.n14 ,0,natom+1);
240 free_imatrix(attached.i13 ,0, 20, 0,natom+1);
241 free_imatrix(attached.i14 ,0,144, 0,natom+1);
242
243 if (pot.use_solv)
244 {
245 free_dvector(solvent.asolv ,0,natom+1);
246 free_dvector(solvent.rsolv ,0,natom+1);
247 free_dvector(solvent.rborn ,0,natom+1);
248 if (solvent.type == STILL)
249 {
250 free_dvector(solvent.vsolv ,0,natom+1);
251 free_dvector(solvent.gpol ,0,natom+1);
252 } else if (solvent.type == HCT)
253 {
254 free_dvector(solvent.shct ,0,natom+1);
255 }
256 }
257 }
258