26 |
|
SimInfo::SimInfo(){ |
27 |
|
excludes = NULL; |
28 |
|
n_constraints = 0; |
29 |
+ |
nZconstraints = 0; |
30 |
|
n_oriented = 0; |
31 |
|
n_dipoles = 0; |
32 |
|
ndf = 0; |
33 |
|
ndfRaw = 0; |
34 |
+ |
nZconstraints = 0; |
35 |
|
the_integrator = NULL; |
36 |
|
setTemp = 0; |
37 |
|
thermalTime = 0.0; |
38 |
+ |
currentTime = 0.0; |
39 |
|
rCut = 0.0; |
40 |
+ |
origRcut = -1.0; |
41 |
+ |
ecr = 0.0; |
42 |
+ |
origEcr = -1.0; |
43 |
+ |
est = 0.0; |
44 |
+ |
oldEcr = 0.0; |
45 |
+ |
oldRcut = 0.0; |
46 |
|
|
47 |
+ |
haveOrigRcut = 0; |
48 |
+ |
haveOrigEcr = 0; |
49 |
+ |
boxIsInit = 0; |
50 |
+ |
|
51 |
+ |
|
52 |
+ |
|
53 |
|
usePBC = 0; |
54 |
|
useLJ = 0; |
55 |
|
useSticky = 0; |
58 |
|
useGB = 0; |
59 |
|
useEAM = 0; |
60 |
|
|
61 |
+ |
myConfiguration = new SimState(); |
62 |
+ |
|
63 |
|
wrapMeSimInfo( this ); |
64 |
|
} |
65 |
|
|
49 |
– |
void SimInfo::setBox(double newBox[3]) { |
66 |
|
|
67 |
< |
double smallestBoxL, maxCutoff; |
52 |
< |
int status; |
53 |
< |
int i; |
67 |
> |
SimInfo::~SimInfo(){ |
68 |
|
|
69 |
< |
for(i=0; i<9; i++) Hmat[i] = 0.0;; |
69 |
> |
delete myConfiguration; |
70 |
|
|
71 |
< |
Hmat[0] = newBox[0]; |
72 |
< |
Hmat[4] = newBox[1]; |
73 |
< |
Hmat[8] = newBox[2]; |
71 |
> |
map<string, GenericData*>::iterator i; |
72 |
> |
|
73 |
> |
for(i = properties.begin(); i != properties.end(); i++) |
74 |
> |
delete (*i).second; |
75 |
> |
|
76 |
> |
} |
77 |
|
|
78 |
< |
calcHmatI(); |
79 |
< |
calcBoxL(); |
78 |
> |
void SimInfo::setBox(double newBox[3]) { |
79 |
> |
|
80 |
> |
int i, j; |
81 |
> |
double tempMat[3][3]; |
82 |
|
|
83 |
< |
setFortranBoxSize(Hmat, HmatI, &orthoRhombic); |
83 |
> |
for(i=0; i<3; i++) |
84 |
> |
for (j=0; j<3; j++) tempMat[i][j] = 0.0;; |
85 |
|
|
86 |
< |
smallestBoxL = boxLx; |
87 |
< |
if (boxLy < smallestBoxL) smallestBoxL = boxLy; |
88 |
< |
if (boxLz < smallestBoxL) smallestBoxL = boxLz; |
86 |
> |
tempMat[0][0] = newBox[0]; |
87 |
> |
tempMat[1][1] = newBox[1]; |
88 |
> |
tempMat[2][2] = newBox[2]; |
89 |
|
|
90 |
< |
maxCutoff = smallestBoxL / 2.0; |
90 |
> |
setBoxM( tempMat ); |
91 |
|
|
72 |
– |
if (rList > maxCutoff) { |
73 |
– |
sprintf( painCave.errMsg, |
74 |
– |
"New Box size is forcing neighborlist radius down to %lf\n", |
75 |
– |
maxCutoff ); |
76 |
– |
painCave.isFatal = 0; |
77 |
– |
simError(); |
78 |
– |
|
79 |
– |
rList = maxCutoff; |
80 |
– |
|
81 |
– |
sprintf( painCave.errMsg, |
82 |
– |
"New Box size is forcing cutoff radius down to %lf\n", |
83 |
– |
maxCutoff - 1.0 ); |
84 |
– |
painCave.isFatal = 0; |
85 |
– |
simError(); |
86 |
– |
|
87 |
– |
rCut = rList - 1.0; |
88 |
– |
|
89 |
– |
// list radius changed so we have to refresh the simulation structure. |
90 |
– |
refreshSim(); |
91 |
– |
} |
92 |
– |
|
93 |
– |
if (rCut > maxCutoff) { |
94 |
– |
sprintf( painCave.errMsg, |
95 |
– |
"New Box size is forcing cutoff radius down to %lf\n", |
96 |
– |
maxCutoff ); |
97 |
– |
painCave.isFatal = 0; |
98 |
– |
simError(); |
99 |
– |
|
100 |
– |
status = 0; |
101 |
– |
LJ_new_rcut(&rCut, &status); |
102 |
– |
if (status != 0) { |
103 |
– |
sprintf( painCave.errMsg, |
104 |
– |
"Error in recomputing LJ shifts based on new rcut\n"); |
105 |
– |
painCave.isFatal = 1; |
106 |
– |
simError(); |
107 |
– |
} |
108 |
– |
} |
92 |
|
} |
93 |
|
|
94 |
< |
void SimInfo::setBoxM( double theBox[9] ){ |
94 |
> |
void SimInfo::setBoxM( double theBox[3][3] ){ |
95 |
|
|
96 |
< |
int i, status; |
96 |
> |
int i, j, status; |
97 |
|
double smallestBoxL, maxCutoff; |
98 |
+ |
double FortranHmat[9]; // to preserve compatibility with Fortran the |
99 |
+ |
// ordering in the array is as follows: |
100 |
+ |
// [ 0 3 6 ] |
101 |
+ |
// [ 1 4 7 ] |
102 |
+ |
// [ 2 5 8 ] |
103 |
+ |
double FortranHmatInv[9]; // the inverted Hmat (for Fortran); |
104 |
|
|
105 |
< |
for(i=0; i<9; i++) Hmat[i] = theBox[i]; |
106 |
< |
calcHmatI(); |
105 |
> |
|
106 |
> |
if( !boxIsInit ) boxIsInit = 1; |
107 |
> |
|
108 |
> |
for(i=0; i < 3; i++) |
109 |
> |
for (j=0; j < 3; j++) Hmat[i][j] = theBox[i][j]; |
110 |
> |
|
111 |
|
calcBoxL(); |
112 |
+ |
calcHmatInv(); |
113 |
|
|
114 |
< |
setFortranBoxSize(Hmat, HmatI, &orthoRhombic); |
115 |
< |
|
116 |
< |
smallestBoxL = boxLx; |
117 |
< |
if (boxLy < smallestBoxL) smallestBoxL = boxLy; |
124 |
< |
if (boxLz < smallestBoxL) smallestBoxL = boxLz; |
125 |
< |
|
126 |
< |
maxCutoff = smallestBoxL / 2.0; |
127 |
< |
|
128 |
< |
if (rList > maxCutoff) { |
129 |
< |
sprintf( painCave.errMsg, |
130 |
< |
"New Box size is forcing neighborlist radius down to %lf\n", |
131 |
< |
maxCutoff ); |
132 |
< |
painCave.isFatal = 0; |
133 |
< |
simError(); |
134 |
< |
|
135 |
< |
rList = maxCutoff; |
136 |
< |
|
137 |
< |
sprintf( painCave.errMsg, |
138 |
< |
"New Box size is forcing cutoff radius down to %lf\n", |
139 |
< |
maxCutoff - 1.0 ); |
140 |
< |
painCave.isFatal = 0; |
141 |
< |
simError(); |
142 |
< |
|
143 |
< |
rCut = rList - 1.0; |
144 |
< |
|
145 |
< |
// list radius changed so we have to refresh the simulation structure. |
146 |
< |
refreshSim(); |
147 |
< |
} |
148 |
< |
|
149 |
< |
if (rCut > maxCutoff) { |
150 |
< |
sprintf( painCave.errMsg, |
151 |
< |
"New Box size is forcing cutoff radius down to %lf\n", |
152 |
< |
maxCutoff ); |
153 |
< |
painCave.isFatal = 0; |
154 |
< |
simError(); |
155 |
< |
|
156 |
< |
status = 0; |
157 |
< |
LJ_new_rcut(&rCut, &status); |
158 |
< |
if (status != 0) { |
159 |
< |
sprintf( painCave.errMsg, |
160 |
< |
"Error in recomputing LJ shifts based on new rcut\n"); |
161 |
< |
painCave.isFatal = 1; |
162 |
< |
simError(); |
114 |
> |
for(i=0; i < 3; i++) { |
115 |
> |
for (j=0; j < 3; j++) { |
116 |
> |
FortranHmat[3*j + i] = Hmat[i][j]; |
117 |
> |
FortranHmatInv[3*j + i] = HmatInv[i][j]; |
118 |
|
} |
119 |
|
} |
120 |
+ |
|
121 |
+ |
setFortranBoxSize(FortranHmat, FortranHmatInv, &orthoRhombic); |
122 |
+ |
|
123 |
|
} |
124 |
|
|
125 |
|
|
126 |
< |
void SimInfo::getBoxM (double theBox[9]) { |
126 |
> |
void SimInfo::getBoxM (double theBox[3][3]) { |
127 |
|
|
128 |
< |
int i; |
129 |
< |
for(i=0; i<9; i++) theBox[i] = Hmat[i]; |
128 |
> |
int i, j; |
129 |
> |
for(i=0; i<3; i++) |
130 |
> |
for (j=0; j<3; j++) theBox[i][j] = Hmat[i][j]; |
131 |
|
} |
132 |
|
|
133 |
|
|
134 |
|
void SimInfo::scaleBox(double scale) { |
135 |
< |
double theBox[9]; |
136 |
< |
int i; |
135 |
> |
double theBox[3][3]; |
136 |
> |
int i, j; |
137 |
|
|
138 |
< |
for(i=0; i<9; i++) theBox[i] = Hmat[i]*scale; |
138 |
> |
// cerr << "Scaling box by " << scale << "\n"; |
139 |
|
|
140 |
+ |
for(i=0; i<3; i++) |
141 |
+ |
for (j=0; j<3; j++) theBox[i][j] = Hmat[i][j]*scale; |
142 |
+ |
|
143 |
|
setBoxM(theBox); |
144 |
|
|
145 |
|
} |
146 |
|
|
147 |
< |
void SimInfo::calcHmatI( void ) { |
148 |
< |
|
149 |
< |
double C[3][3]; |
188 |
< |
double detHmat; |
189 |
< |
int i, j, k; |
147 |
> |
void SimInfo::calcHmatInv( void ) { |
148 |
> |
|
149 |
> |
int i,j; |
150 |
|
double smallDiag; |
151 |
|
double tol; |
152 |
|
double sanity[3][3]; |
153 |
|
|
154 |
< |
// calculate the adjunct of Hmat; |
154 |
> |
invertMat3( Hmat, HmatInv ); |
155 |
|
|
156 |
< |
C[0][0] = ( Hmat[4]*Hmat[8]) - (Hmat[7]*Hmat[5]); |
197 |
< |
C[1][0] = -( Hmat[1]*Hmat[8]) + (Hmat[7]*Hmat[2]); |
198 |
< |
C[2][0] = ( Hmat[1]*Hmat[5]) - (Hmat[4]*Hmat[2]); |
156 |
> |
// Check the inverse to make sure it is sane: |
157 |
|
|
158 |
< |
C[0][1] = -( Hmat[3]*Hmat[8]) + (Hmat[6]*Hmat[5]); |
159 |
< |
C[1][1] = ( Hmat[0]*Hmat[8]) - (Hmat[6]*Hmat[2]); |
160 |
< |
C[2][1] = -( Hmat[0]*Hmat[5]) + (Hmat[3]*Hmat[2]); |
203 |
< |
|
204 |
< |
C[0][2] = ( Hmat[3]*Hmat[7]) - (Hmat[6]*Hmat[4]); |
205 |
< |
C[1][2] = -( Hmat[0]*Hmat[7]) + (Hmat[6]*Hmat[1]); |
206 |
< |
C[2][2] = ( Hmat[0]*Hmat[4]) - (Hmat[3]*Hmat[1]); |
207 |
< |
|
208 |
< |
// calcutlate the determinant of Hmat |
158 |
> |
matMul3( Hmat, HmatInv, sanity ); |
159 |
> |
|
160 |
> |
// check to see if Hmat is orthorhombic |
161 |
|
|
162 |
< |
detHmat = 0.0; |
163 |
< |
for(i=0; i<3; i++) detHmat += Hmat[i] * C[i][0]; |
162 |
> |
smallDiag = Hmat[0][0]; |
163 |
> |
if(smallDiag > Hmat[1][1]) smallDiag = Hmat[1][1]; |
164 |
> |
if(smallDiag > Hmat[2][2]) smallDiag = Hmat[2][2]; |
165 |
> |
tol = smallDiag * 1E-6; |
166 |
|
|
167 |
+ |
orthoRhombic = 1; |
168 |
|
|
169 |
< |
// H^-1 = C^T / det(H) |
170 |
< |
|
171 |
< |
i=0; |
172 |
< |
for(j=0; j<3; j++){ |
173 |
< |
for(k=0; k<3; k++){ |
174 |
< |
|
175 |
< |
HmatI[i] = C[j][k] / detHmat; |
221 |
< |
i++; |
169 |
> |
for (i = 0; i < 3; i++ ) { |
170 |
> |
for (j = 0 ; j < 3; j++) { |
171 |
> |
if (i != j) { |
172 |
> |
if (orthoRhombic) { |
173 |
> |
if (Hmat[i][j] >= tol) orthoRhombic = 0; |
174 |
> |
} |
175 |
> |
} |
176 |
|
} |
177 |
|
} |
178 |
+ |
} |
179 |
|
|
180 |
< |
// sanity check |
180 |
> |
double SimInfo::matDet3(double a[3][3]) { |
181 |
> |
int i, j, k; |
182 |
> |
double determinant; |
183 |
|
|
184 |
< |
for(i=0; i<3; i++){ |
185 |
< |
for(j=0; j<3; j++){ |
184 |
> |
determinant = 0.0; |
185 |
> |
|
186 |
> |
for(i = 0; i < 3; i++) { |
187 |
> |
j = (i+1)%3; |
188 |
> |
k = (i+2)%3; |
189 |
> |
|
190 |
> |
determinant += a[0][i] * (a[1][j]*a[2][k] - a[1][k]*a[2][j]); |
191 |
> |
} |
192 |
> |
|
193 |
> |
return determinant; |
194 |
> |
} |
195 |
> |
|
196 |
> |
void SimInfo::invertMat3(double a[3][3], double b[3][3]) { |
197 |
> |
|
198 |
> |
int i, j, k, l, m, n; |
199 |
> |
double determinant; |
200 |
> |
|
201 |
> |
determinant = matDet3( a ); |
202 |
> |
|
203 |
> |
if (determinant == 0.0) { |
204 |
> |
sprintf( painCave.errMsg, |
205 |
> |
"Can't invert a matrix with a zero determinant!\n"); |
206 |
> |
painCave.isFatal = 1; |
207 |
> |
simError(); |
208 |
> |
} |
209 |
> |
|
210 |
> |
for (i=0; i < 3; i++) { |
211 |
> |
j = (i+1)%3; |
212 |
> |
k = (i+2)%3; |
213 |
> |
for(l = 0; l < 3; l++) { |
214 |
> |
m = (l+1)%3; |
215 |
> |
n = (l+2)%3; |
216 |
|
|
217 |
< |
sanity[i][j] = 0.0; |
231 |
< |
for(k=0; k<3; k++){ |
232 |
< |
sanity[i][j] += Hmat[3*k+i] * HmatI[3*j+k]; |
233 |
< |
} |
217 |
> |
b[l][i] = (a[j][m]*a[k][n] - a[j][n]*a[k][m]) / determinant; |
218 |
|
} |
219 |
|
} |
220 |
+ |
} |
221 |
|
|
222 |
< |
cerr << "sanity => \n" |
223 |
< |
<< sanity[0][0] << "\t" << sanity[0][1] << "\t" << sanity [0][2] << "\n" |
239 |
< |
<< sanity[1][0] << "\t" << sanity[1][1] << "\t" << sanity [1][2] << "\n" |
240 |
< |
<< sanity[2][0] << "\t" << sanity[2][1] << "\t" << sanity [2][2] |
241 |
< |
<< "\n"; |
242 |
< |
|
222 |
> |
void SimInfo::matMul3(double a[3][3], double b[3][3], double c[3][3]) { |
223 |
> |
double r00, r01, r02, r10, r11, r12, r20, r21, r22; |
224 |
|
|
225 |
< |
// check to see if Hmat is orthorhombic |
225 |
> |
r00 = a[0][0]*b[0][0] + a[0][1]*b[1][0] + a[0][2]*b[2][0]; |
226 |
> |
r01 = a[0][0]*b[0][1] + a[0][1]*b[1][1] + a[0][2]*b[2][1]; |
227 |
> |
r02 = a[0][0]*b[0][2] + a[0][1]*b[1][2] + a[0][2]*b[2][2]; |
228 |
|
|
229 |
< |
smallDiag = Hmat[0]; |
230 |
< |
if(smallDiag > Hmat[4]) smallDiag = Hmat[4]; |
231 |
< |
if(smallDiag > Hmat[8]) smallDiag = Hmat[8]; |
232 |
< |
tol = smallDiag * 1E-6; |
229 |
> |
r10 = a[1][0]*b[0][0] + a[1][1]*b[1][0] + a[1][2]*b[2][0]; |
230 |
> |
r11 = a[1][0]*b[0][1] + a[1][1]*b[1][1] + a[1][2]*b[2][1]; |
231 |
> |
r12 = a[1][0]*b[0][2] + a[1][1]*b[1][2] + a[1][2]*b[2][2]; |
232 |
> |
|
233 |
> |
r20 = a[2][0]*b[0][0] + a[2][1]*b[1][0] + a[2][2]*b[2][0]; |
234 |
> |
r21 = a[2][0]*b[0][1] + a[2][1]*b[1][1] + a[2][2]*b[2][1]; |
235 |
> |
r22 = a[2][0]*b[0][2] + a[2][1]*b[1][2] + a[2][2]*b[2][2]; |
236 |
> |
|
237 |
> |
c[0][0] = r00; c[0][1] = r01; c[0][2] = r02; |
238 |
> |
c[1][0] = r10; c[1][1] = r11; c[1][2] = r12; |
239 |
> |
c[2][0] = r20; c[2][1] = r21; c[2][2] = r22; |
240 |
> |
} |
241 |
|
|
242 |
< |
orthoRhombic = 1; |
243 |
< |
for(i=0; (i<9) && orthoRhombic; i++){ |
244 |
< |
|
245 |
< |
if( (i%4) ){ // ignore the diagonals (0, 4, and 8) |
246 |
< |
orthoRhombic = (Hmat[i] <= tol); |
242 |
> |
void SimInfo::matVecMul3(double m[3][3], double inVec[3], double outVec[3]) { |
243 |
> |
double a0, a1, a2; |
244 |
> |
|
245 |
> |
a0 = inVec[0]; a1 = inVec[1]; a2 = inVec[2]; |
246 |
> |
|
247 |
> |
outVec[0] = m[0][0]*a0 + m[0][1]*a1 + m[0][2]*a2; |
248 |
> |
outVec[1] = m[1][0]*a0 + m[1][1]*a1 + m[1][2]*a2; |
249 |
> |
outVec[2] = m[2][0]*a0 + m[2][1]*a1 + m[2][2]*a2; |
250 |
> |
} |
251 |
> |
|
252 |
> |
void SimInfo::transposeMat3(double in[3][3], double out[3][3]) { |
253 |
> |
double temp[3][3]; |
254 |
> |
int i, j; |
255 |
> |
|
256 |
> |
for (i = 0; i < 3; i++) { |
257 |
> |
for (j = 0; j < 3; j++) { |
258 |
> |
temp[j][i] = in[i][j]; |
259 |
|
} |
260 |
|
} |
261 |
< |
|
261 |
> |
for (i = 0; i < 3; i++) { |
262 |
> |
for (j = 0; j < 3; j++) { |
263 |
> |
out[i][j] = temp[i][j]; |
264 |
> |
} |
265 |
> |
} |
266 |
|
} |
267 |
+ |
|
268 |
+ |
void SimInfo::printMat3(double A[3][3] ){ |
269 |
|
|
270 |
+ |
std::cerr |
271 |
+ |
<< "[ " << A[0][0] << ", " << A[0][1] << ", " << A[0][2] << " ]\n" |
272 |
+ |
<< "[ " << A[1][0] << ", " << A[1][1] << ", " << A[1][2] << " ]\n" |
273 |
+ |
<< "[ " << A[2][0] << ", " << A[2][1] << ", " << A[2][2] << " ]\n"; |
274 |
+ |
} |
275 |
+ |
|
276 |
+ |
void SimInfo::printMat9(double A[9] ){ |
277 |
+ |
|
278 |
+ |
std::cerr |
279 |
+ |
<< "[ " << A[0] << ", " << A[1] << ", " << A[2] << " ]\n" |
280 |
+ |
<< "[ " << A[3] << ", " << A[4] << ", " << A[5] << " ]\n" |
281 |
+ |
<< "[ " << A[6] << ", " << A[7] << ", " << A[8] << " ]\n"; |
282 |
+ |
} |
283 |
+ |
|
284 |
|
void SimInfo::calcBoxL( void ){ |
285 |
|
|
286 |
|
double dx, dy, dz, dsq; |
287 |
|
int i; |
288 |
|
|
289 |
< |
// boxVol = h1 (dot) h2 (cross) h3 |
289 |
> |
// boxVol = Determinant of Hmat |
290 |
|
|
291 |
< |
boxVol = Hmat[0] * ( (Hmat[4]*Hmat[8]) - (Hmat[7]*Hmat[5]) ) |
269 |
< |
+ Hmat[1] * ( (Hmat[5]*Hmat[6]) - (Hmat[8]*Hmat[3]) ) |
270 |
< |
+ Hmat[2] * ( (Hmat[3]*Hmat[7]) - (Hmat[6]*Hmat[4]) ); |
291 |
> |
boxVol = matDet3( Hmat ); |
292 |
|
|
272 |
– |
|
293 |
|
// boxLx |
294 |
|
|
295 |
< |
dx = Hmat[0]; dy = Hmat[1]; dz = Hmat[2]; |
295 |
> |
dx = Hmat[0][0]; dy = Hmat[1][0]; dz = Hmat[2][0]; |
296 |
|
dsq = dx*dx + dy*dy + dz*dz; |
297 |
< |
boxLx = sqrt( dsq ); |
297 |
> |
boxL[0] = sqrt( dsq ); |
298 |
> |
maxCutoff = 0.5 * boxL[0]; |
299 |
|
|
300 |
|
// boxLy |
301 |
|
|
302 |
< |
dx = Hmat[3]; dy = Hmat[4]; dz = Hmat[5]; |
302 |
> |
dx = Hmat[0][1]; dy = Hmat[1][1]; dz = Hmat[2][1]; |
303 |
|
dsq = dx*dx + dy*dy + dz*dz; |
304 |
< |
boxLy = sqrt( dsq ); |
304 |
> |
boxL[1] = sqrt( dsq ); |
305 |
> |
if( (0.5 * boxL[1]) < maxCutoff ) maxCutoff = 0.5 * boxL[1]; |
306 |
|
|
307 |
|
// boxLz |
308 |
|
|
309 |
< |
dx = Hmat[6]; dy = Hmat[7]; dz = Hmat[8]; |
309 |
> |
dx = Hmat[0][2]; dy = Hmat[1][2]; dz = Hmat[2][2]; |
310 |
|
dsq = dx*dx + dy*dy + dz*dz; |
311 |
< |
boxLz = sqrt( dsq ); |
311 |
> |
boxL[2] = sqrt( dsq ); |
312 |
> |
if( (0.5 * boxL[2]) < maxCutoff ) maxCutoff = 0.5 * boxL[2]; |
313 |
|
|
314 |
+ |
checkCutOffs(); |
315 |
+ |
|
316 |
|
} |
317 |
|
|
318 |
|
|
323 |
|
|
324 |
|
if( !orthoRhombic ){ |
325 |
|
// calc the scaled coordinates. |
326 |
+ |
|
327 |
+ |
|
328 |
+ |
matVecMul3(HmatInv, thePos, scaled); |
329 |
|
|
330 |
|
for(i=0; i<3; i++) |
303 |
– |
scaled[i] = |
304 |
– |
thePos[0]*HmatI[i] + thePos[1]*HmatI[i+3] + thePos[3]*HmatI[i+6]; |
305 |
– |
|
306 |
– |
// wrap the scaled coordinates |
307 |
– |
|
308 |
– |
for(i=0; i<3; i++) |
331 |
|
scaled[i] -= roundMe(scaled[i]); |
332 |
|
|
333 |
|
// calc the wrapped real coordinates from the wrapped scaled coordinates |
334 |
|
|
335 |
< |
for(i=0; i<3; i++) |
336 |
< |
thePos[i] = |
315 |
< |
scaled[0]*Hmat[i] + scaled[1]*Hmat[i+3] + scaled[2]*Hmat[i+6]; |
335 |
> |
matVecMul3(Hmat, scaled, thePos); |
336 |
> |
|
337 |
|
} |
338 |
|
else{ |
339 |
|
// calc the scaled coordinates. |
340 |
|
|
341 |
|
for(i=0; i<3; i++) |
342 |
< |
scaled[i] = thePos[i]*HmatI[i*4]; |
342 |
> |
scaled[i] = thePos[i]*HmatInv[i][i]; |
343 |
|
|
344 |
|
// wrap the scaled coordinates |
345 |
|
|
349 |
|
// calc the wrapped real coordinates from the wrapped scaled coordinates |
350 |
|
|
351 |
|
for(i=0; i<3; i++) |
352 |
< |
thePos[i] = scaled[i]*Hmat[i*4]; |
352 |
> |
thePos[i] = scaled[i]*Hmat[i][i]; |
353 |
|
} |
354 |
|
|
334 |
– |
|
355 |
|
} |
356 |
|
|
357 |
|
|
366 |
|
ndf = ndf_local; |
367 |
|
#endif |
368 |
|
|
369 |
< |
ndf = ndf - 3; |
369 |
> |
ndf = ndf - 3 - nZconstraints; |
370 |
|
|
371 |
|
return ndf; |
372 |
|
} |
392 |
|
int isError; |
393 |
|
int n_global; |
394 |
|
int* excl; |
395 |
< |
|
376 |
< |
fInfo.rrf = 0.0; |
377 |
< |
fInfo.rt = 0.0; |
395 |
> |
|
396 |
|
fInfo.dielect = 0.0; |
397 |
|
|
380 |
– |
fInfo.rlist = rList; |
381 |
– |
fInfo.rcut = rCut; |
382 |
– |
|
398 |
|
if( useDipole ){ |
384 |
– |
fInfo.rrf = ecr; |
385 |
– |
fInfo.rt = ecr - est; |
399 |
|
if( useReactionField )fInfo.dielect = dielectric; |
400 |
|
} |
401 |
|
|
441 |
|
|
442 |
|
this->ndf = this->getNDF(); |
443 |
|
this->ndfRaw = this->getNDFraw(); |
444 |
+ |
|
445 |
+ |
} |
446 |
+ |
|
447 |
+ |
|
448 |
+ |
void SimInfo::setRcut( double theRcut ){ |
449 |
+ |
|
450 |
+ |
if( !haveOrigRcut ){ |
451 |
+ |
haveOrigRcut = 1; |
452 |
+ |
origRcut = theRcut; |
453 |
+ |
} |
454 |
+ |
|
455 |
+ |
rCut = theRcut; |
456 |
+ |
checkCutOffs(); |
457 |
+ |
} |
458 |
+ |
|
459 |
+ |
void SimInfo::setEcr( double theEcr ){ |
460 |
+ |
|
461 |
+ |
if( !haveOrigEcr ){ |
462 |
+ |
haveOrigEcr = 1; |
463 |
+ |
origEcr = theEcr; |
464 |
+ |
} |
465 |
+ |
|
466 |
+ |
ecr = theEcr; |
467 |
+ |
checkCutOffs(); |
468 |
+ |
} |
469 |
+ |
|
470 |
+ |
void SimInfo::setEcr( double theEcr, double theEst ){ |
471 |
+ |
|
472 |
+ |
est = theEst; |
473 |
+ |
setEcr( theEcr ); |
474 |
+ |
} |
475 |
|
|
476 |
+ |
|
477 |
+ |
void SimInfo::checkCutOffs( void ){ |
478 |
+ |
|
479 |
+ |
int cutChanged = 0; |
480 |
+ |
|
481 |
+ |
|
482 |
+ |
|
483 |
+ |
if( boxIsInit ){ |
484 |
+ |
|
485 |
+ |
//we need to check cutOffs against the box |
486 |
+ |
|
487 |
+ |
if(( maxCutoff > rCut )&&(usePBC)){ |
488 |
+ |
if( rCut < origRcut ){ |
489 |
+ |
rCut = origRcut; |
490 |
+ |
if (rCut > maxCutoff) rCut = maxCutoff; |
491 |
+ |
|
492 |
+ |
sprintf( painCave.errMsg, |
493 |
+ |
"New Box size is setting the long range cutoff radius " |
494 |
+ |
"to %lf\n", |
495 |
+ |
rCut ); |
496 |
+ |
painCave.isFatal = 0; |
497 |
+ |
simError(); |
498 |
+ |
} |
499 |
+ |
} |
500 |
+ |
|
501 |
+ |
if( maxCutoff > ecr ){ |
502 |
+ |
if( ecr < origEcr ){ |
503 |
+ |
rCut = origEcr; |
504 |
+ |
if (ecr > maxCutoff) ecr = maxCutoff; |
505 |
+ |
|
506 |
+ |
sprintf( painCave.errMsg, |
507 |
+ |
"New Box size is setting the electrostaticCutoffRadius " |
508 |
+ |
"to %lf\n", |
509 |
+ |
ecr ); |
510 |
+ |
painCave.isFatal = 0; |
511 |
+ |
simError(); |
512 |
+ |
} |
513 |
+ |
} |
514 |
+ |
|
515 |
+ |
|
516 |
+ |
if ((rCut > maxCutoff)&&(usePBC)) { |
517 |
+ |
sprintf( painCave.errMsg, |
518 |
+ |
"New Box size is setting the long range cutoff radius " |
519 |
+ |
"to %lf\n", |
520 |
+ |
maxCutoff ); |
521 |
+ |
painCave.isFatal = 0; |
522 |
+ |
simError(); |
523 |
+ |
rCut = maxCutoff; |
524 |
+ |
} |
525 |
+ |
|
526 |
+ |
if( ecr > maxCutoff){ |
527 |
+ |
sprintf( painCave.errMsg, |
528 |
+ |
"New Box size is setting the electrostaticCutoffRadius " |
529 |
+ |
"to %lf\n", |
530 |
+ |
maxCutoff ); |
531 |
+ |
painCave.isFatal = 0; |
532 |
+ |
simError(); |
533 |
+ |
ecr = maxCutoff; |
534 |
+ |
} |
535 |
+ |
|
536 |
+ |
|
537 |
+ |
} |
538 |
+ |
|
539 |
+ |
|
540 |
+ |
if( (oldEcr != ecr) || ( oldRcut != rCut ) ) cutChanged = 1; |
541 |
+ |
|
542 |
+ |
// rlist is the 1.0 plus max( rcut, ecr ) |
543 |
+ |
|
544 |
+ |
( rCut > ecr )? rList = rCut + 1.0: rList = ecr + 1.0; |
545 |
+ |
|
546 |
+ |
if( cutChanged ){ |
547 |
+ |
|
548 |
+ |
notifyFortranCutOffs( &rCut, &rList, &ecr, &est ); |
549 |
+ |
} |
550 |
+ |
|
551 |
+ |
oldEcr = ecr; |
552 |
+ |
oldRcut = rCut; |
553 |
|
} |
554 |
|
|
555 |
+ |
void SimInfo::addProperty(GenericData* prop){ |
556 |
+ |
|
557 |
+ |
map<string, GenericData*>::iterator result; |
558 |
+ |
result = properties.find(prop->getID()); |
559 |
+ |
|
560 |
+ |
//we can't simply use properties[prop->getID()] = prop, |
561 |
+ |
//it will cause memory leak if we already contain a propery which has the same name of prop |
562 |
+ |
|
563 |
+ |
if(result != properties.end()){ |
564 |
+ |
|
565 |
+ |
delete (*result).second; |
566 |
+ |
(*result).second = prop; |
567 |
+ |
|
568 |
+ |
} |
569 |
+ |
else{ |
570 |
+ |
|
571 |
+ |
properties[prop->getID()] = prop; |
572 |
+ |
|
573 |
+ |
} |
574 |
+ |
|
575 |
+ |
} |
576 |
+ |
|
577 |
+ |
GenericData* SimInfo::getProperty(const string& propName){ |
578 |
+ |
|
579 |
+ |
map<string, GenericData*>::iterator result; |
580 |
+ |
|
581 |
+ |
//string lowerCaseName = (); |
582 |
+ |
|
583 |
+ |
result = properties.find(propName); |
584 |
+ |
|
585 |
+ |
if(result != properties.end()) |
586 |
+ |
return (*result).second; |
587 |
+ |
else |
588 |
+ |
return NULL; |
589 |
+ |
} |
590 |
+ |
|
591 |
+ |
vector<GenericData*> SimInfo::getProperties(){ |
592 |
+ |
|
593 |
+ |
vector<GenericData*> result; |
594 |
+ |
map<string, GenericData*>::iterator i; |
595 |
+ |
|
596 |
+ |
for(i = properties.begin(); i != properties.end(); i++) |
597 |
+ |
result.push_back((*i).second); |
598 |
+ |
|
599 |
+ |
return result; |
600 |
+ |
} |
601 |
+ |
|
602 |
+ |
double SimInfo::matTrace3(double m[3][3]){ |
603 |
+ |
double trace; |
604 |
+ |
trace = m[0][0] + m[1][1] + m[2][2]; |
605 |
+ |
|
606 |
+ |
return trace; |
607 |
+ |
} |