1 |
< |
#include <cmath> |
1 |
> |
#include <math.h> |
2 |
|
#include <iostream> |
3 |
|
using namespace std; |
4 |
|
|
104 |
|
potential = potential_local; |
105 |
|
#endif // is_mpi |
106 |
|
|
107 |
– |
#ifdef IS_MPI |
108 |
– |
/* |
109 |
– |
std::cerr << "node " << worldRank << ": after pot = " << potential << "\n"; |
110 |
– |
*/ |
111 |
– |
#endif |
112 |
– |
|
107 |
|
return potential; |
108 |
|
} |
109 |
|
|
117 |
|
|
118 |
|
double Thermo::getTemperature(){ |
119 |
|
|
120 |
< |
const double kb = 1.9872179E-3; // boltzman's constant in kcal/(mol K) |
120 |
> |
const double kb = 1.9872156E-3; // boltzman's constant in kcal/(mol K) |
121 |
|
double temperature; |
122 |
|
|
123 |
|
temperature = ( 2.0 * this->getKinetic() ) / ((double)info->ndf * kb ); |
124 |
|
return temperature; |
125 |
|
} |
126 |
|
|
127 |
< |
double Thermo::getEnthalpy() { |
127 |
> |
double Thermo::getVolume() { |
128 |
|
|
129 |
< |
const double e_convert = 4.184E-4; // convert kcal/mol -> (amu A^2)/fs^2 |
130 |
< |
double u, p, v; |
137 |
< |
double press[3][3]; |
129 |
> |
return info->boxVol; |
130 |
> |
} |
131 |
|
|
132 |
< |
u = this->getTotalE(); |
132 |
> |
double Thermo::getPressure() { |
133 |
|
|
134 |
+ |
// Relies on the calculation of the full molecular pressure tensor |
135 |
+ |
|
136 |
+ |
const double p_convert = 1.63882576e8; |
137 |
+ |
double press[3][3]; |
138 |
+ |
double pressure; |
139 |
+ |
|
140 |
|
this->getPressureTensor(press); |
142 |
– |
p = (press[0][0] + press[1][1] + press[2][2]) / 3.0; |
141 |
|
|
142 |
< |
v = this->getVolume(); |
142 |
> |
pressure = p_convert * (press[0][0] + press[1][1] + press[2][2]) / 3.0; |
143 |
|
|
144 |
< |
return (u + (p*v)/e_convert); |
144 |
> |
return pressure; |
145 |
|
} |
146 |
|
|
147 |
< |
double Thermo::getVolume() { |
147 |
> |
double Thermo::getPressureX() { |
148 |
|
|
149 |
< |
return info->boxVol; |
149 |
> |
// Relies on the calculation of the full molecular pressure tensor |
150 |
> |
|
151 |
> |
const double p_convert = 1.63882576e8; |
152 |
> |
double press[3][3]; |
153 |
> |
double pressureX; |
154 |
> |
|
155 |
> |
this->getPressureTensor(press); |
156 |
> |
|
157 |
> |
pressureX = p_convert * press[0][0]; |
158 |
> |
|
159 |
> |
return pressureX; |
160 |
|
} |
161 |
|
|
162 |
< |
double Thermo::getPressure() { |
162 |
> |
double Thermo::getPressureY() { |
163 |
|
|
164 |
|
// Relies on the calculation of the full molecular pressure tensor |
165 |
|
|
166 |
|
const double p_convert = 1.63882576e8; |
167 |
|
double press[3][3]; |
168 |
< |
double pressure; |
168 |
> |
double pressureY; |
169 |
|
|
170 |
|
this->getPressureTensor(press); |
171 |
|
|
172 |
< |
pressure = p_convert * (press[0][0] + press[1][1] + press[2][2]) / 3.0; |
172 |
> |
pressureY = p_convert * press[1][1]; |
173 |
|
|
174 |
< |
return pressure; |
174 |
> |
return pressureY; |
175 |
> |
} |
176 |
> |
|
177 |
> |
double Thermo::getPressureZ() { |
178 |
> |
|
179 |
> |
// Relies on the calculation of the full molecular pressure tensor |
180 |
> |
|
181 |
> |
const double p_convert = 1.63882576e8; |
182 |
> |
double press[3][3]; |
183 |
> |
double pressureZ; |
184 |
> |
|
185 |
> |
this->getPressureTensor(press); |
186 |
> |
|
187 |
> |
pressureZ = p_convert * press[2][2]; |
188 |
> |
|
189 |
> |
return pressureZ; |
190 |
|
} |
191 |
|
|
192 |
|
|
250 |
|
|
251 |
|
void Thermo::velocitize() { |
252 |
|
|
230 |
– |
double x,y; |
253 |
|
double aVel[3], aJ[3], I[3][3]; |
254 |
|
int i, j, vr, vd; // velocity randomizer loop counters |
255 |
|
double vdrift[3]; |
270 |
|
n_oriented = info->n_oriented; |
271 |
|
n_constraints = info->n_constraints; |
272 |
|
|
273 |
< |
kebar = kb * temperature * (double)info->ndf / |
274 |
< |
( 2.0 * (double)info->ndfRaw ); |
273 |
> |
kebar = kb * temperature * (double)info->ndfRaw / |
274 |
> |
( 2.0 * (double)info->ndf ); |
275 |
|
|
276 |
|
for(vr = 0; vr < n_atoms; vr++){ |
277 |
|
|
279 |
|
|
280 |
|
av2 = 2.0 * kebar / atoms[vr]->getMass(); |
281 |
|
vbar = sqrt( av2 ); |
282 |
< |
|
261 |
< |
// vbar = sqrt( 8.31451e-7 * temperature / atoms[vr]->getMass() ); |
262 |
< |
|
282 |
> |
|
283 |
|
// picks random velocities from a gaussian distribution |
284 |
|
// centered on vbar |
285 |
|
|
375 |
|
|
376 |
|
} |
377 |
|
|
378 |
+ |
void Thermo::getCOM(double COM[3]){ |
379 |
+ |
|
380 |
+ |
double mtot, mtot_local; |
381 |
+ |
double aPos[3], amass; |
382 |
+ |
double COM_local[3]; |
383 |
+ |
int i, n_atoms, j; |
384 |
+ |
Atom** atoms; |
385 |
+ |
|
386 |
+ |
// We are very careless here with the distinction between n_atoms and n_local |
387 |
+ |
// We should really fix this before someone pokes an eye out. |
388 |
+ |
|
389 |
+ |
n_atoms = info->n_atoms; |
390 |
+ |
atoms = info->atoms; |
391 |
+ |
|
392 |
+ |
mtot_local = 0.0; |
393 |
+ |
COM_local[0] = 0.0; |
394 |
+ |
COM_local[1] = 0.0; |
395 |
+ |
COM_local[2] = 0.0; |
396 |
+ |
|
397 |
+ |
for(i = 0; i < n_atoms; i++){ |
398 |
+ |
|
399 |
+ |
amass = atoms[i]->getMass(); |
400 |
+ |
atoms[i]->getPos( aPos ); |
401 |
+ |
|
402 |
+ |
for(j = 0; j < 3; j++) |
403 |
+ |
COM_local[j] += aPos[j] * amass; |
404 |
+ |
|
405 |
+ |
mtot_local += amass; |
406 |
+ |
} |
407 |
+ |
|
408 |
+ |
#ifdef IS_MPI |
409 |
+ |
MPI_Allreduce(&mtot_local,&mtot,1,MPI_DOUBLE,MPI_SUM, MPI_COMM_WORLD); |
410 |
+ |
MPI_Allreduce(COM_local,COM,3,MPI_DOUBLE,MPI_SUM, MPI_COMM_WORLD); |
411 |
+ |
#else |
412 |
+ |
mtot = mtot_local; |
413 |
+ |
for(i = 0; i < 3; i++) { |
414 |
+ |
COM[i] = COM_local[i]; |
415 |
+ |
} |
416 |
+ |
#endif |
417 |
+ |
|
418 |
+ |
for (i = 0; i < 3; i++) { |
419 |
+ |
COM[i] = COM[i] / mtot; |
420 |
+ |
} |
421 |
+ |
} |