1 |
< |
#include <cmath> |
1 |
> |
#include <math.h> |
2 |
|
#include <iostream> |
3 |
|
using namespace std; |
4 |
|
|
33 |
|
double kinetic; |
34 |
|
double amass; |
35 |
|
double aVel[3], aJ[3], I[3][3]; |
36 |
< |
int j, kl; |
36 |
> |
int i, j, k, kl; |
37 |
|
|
38 |
– |
DirectionalAtom *dAtom; |
39 |
– |
|
40 |
– |
int n_atoms; |
38 |
|
double kinetic_global; |
39 |
< |
Atom** atoms; |
43 |
< |
|
39 |
> |
vector<StuntDouble *> integrableObjects = info->integrableObjects; |
40 |
|
|
45 |
– |
n_atoms = info->n_atoms; |
46 |
– |
atoms = info->atoms; |
47 |
– |
|
41 |
|
kinetic = 0.0; |
42 |
|
kinetic_global = 0.0; |
50 |
– |
for( kl=0; kl < n_atoms; kl++ ){ |
51 |
– |
|
52 |
– |
atoms[kl]->getVel(aVel); |
53 |
– |
amass = atoms[kl]->getMass(); |
54 |
– |
|
55 |
– |
for (j=0; j < 3; j++) |
56 |
– |
kinetic += amass * aVel[j] * aVel[j]; |
43 |
|
|
44 |
< |
if( atoms[kl]->isDirectional() ){ |
45 |
< |
|
46 |
< |
dAtom = (DirectionalAtom *)atoms[kl]; |
44 |
> |
for (kl=0; kl<integrableObjects.size(); kl++) { |
45 |
> |
integrableObjects[kl]->getVel(aVel); |
46 |
> |
amass = integrableObjects[kl]->getMass(); |
47 |
|
|
48 |
< |
dAtom->getJ( aJ ); |
49 |
< |
dAtom->getI( I ); |
50 |
< |
|
51 |
< |
for (j=0; j<3; j++) |
52 |
< |
kinetic += aJ[j]*aJ[j] / I[j][j]; |
53 |
< |
|
54 |
< |
} |
48 |
> |
for(j=0; j<3; j++) |
49 |
> |
kinetic += amass*aVel[j]*aVel[j]; |
50 |
> |
|
51 |
> |
if (integrableObjects[kl]->isDirectional()){ |
52 |
> |
|
53 |
> |
integrableObjects[kl]->getJ( aJ ); |
54 |
> |
integrableObjects[kl]->getI( I ); |
55 |
> |
|
56 |
> |
if (integrableObjects[kl]->isLinear()) { |
57 |
> |
i = integrableObjects[kl]->linearAxis(); |
58 |
> |
j = (i+1)%3; |
59 |
> |
k = (i+2)%3; |
60 |
> |
kinetic += aJ[j]*aJ[j]/I[j][j] + aJ[k]*aJ[k]/I[k][k]; |
61 |
> |
} else { |
62 |
> |
for (j=0; j<3; j++) |
63 |
> |
kinetic += aJ[j]*aJ[j] / I[j][j]; |
64 |
> |
} |
65 |
> |
} |
66 |
|
} |
67 |
|
#ifdef IS_MPI |
68 |
|
MPI_Allreduce(&kinetic,&kinetic_global,1,MPI_DOUBLE, |
69 |
|
MPI_SUM, MPI_COMM_WORLD); |
70 |
|
kinetic = kinetic_global; |
71 |
|
#endif //is_mpi |
72 |
< |
|
72 |
> |
|
73 |
|
kinetic = kinetic * 0.5 / e_convert; |
74 |
|
|
75 |
|
return kinetic; |
101 |
|
potential = potential_local; |
102 |
|
#endif // is_mpi |
103 |
|
|
107 |
– |
#ifdef IS_MPI |
108 |
– |
/* |
109 |
– |
std::cerr << "node " << worldRank << ": after pot = " << potential << "\n"; |
110 |
– |
*/ |
111 |
– |
#endif |
112 |
– |
|
104 |
|
return potential; |
105 |
|
} |
106 |
|
|
116 |
|
|
117 |
|
const double kb = 1.9872156E-3; // boltzman's constant in kcal/(mol K) |
118 |
|
double temperature; |
119 |
< |
|
119 |
> |
|
120 |
|
temperature = ( 2.0 * this->getKinetic() ) / ((double)info->ndf * kb ); |
121 |
|
return temperature; |
131 |
– |
} |
132 |
– |
|
133 |
– |
double Thermo::getEnthalpy() { |
134 |
– |
|
135 |
– |
const double e_convert = 4.184E-4; // convert kcal/mol -> (amu A^2)/fs^2 |
136 |
– |
double u, p, v; |
137 |
– |
double press[3][3]; |
138 |
– |
|
139 |
– |
u = this->getTotalE(); |
140 |
– |
|
141 |
– |
this->getPressureTensor(press); |
142 |
– |
p = (press[0][0] + press[1][1] + press[2][2]) / 3.0; |
143 |
– |
|
144 |
– |
v = this->getVolume(); |
145 |
– |
|
146 |
– |
return (u + (p*v)/e_convert); |
122 |
|
} |
123 |
|
|
124 |
|
double Thermo::getVolume() { |
276 |
|
|
277 |
|
av2 = 2.0 * kebar / atoms[vr]->getMass(); |
278 |
|
vbar = sqrt( av2 ); |
279 |
< |
|
305 |
< |
// vbar = sqrt( 8.31451e-7 * temperature / atoms[vr]->getMass() ); |
306 |
< |
|
279 |
> |
|
280 |
|
// picks random velocities from a gaussian distribution |
281 |
|
// centered on vbar |
282 |
|
|