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

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