| 16 |
|
#include "mpiSimulation.hpp" |
| 17 |
|
#endif // is_mpi |
| 18 |
|
|
| 19 |
< |
|
| 20 |
< |
#define BASE_SEED 123456789 |
| 21 |
< |
|
| 22 |
< |
Thermo::Thermo( SimInfo* the_entry_plug ) { |
| 23 |
< |
entry_plug = the_entry_plug; |
| 24 |
< |
int baseSeed = BASE_SEED; |
| 19 |
> |
Thermo::Thermo( SimInfo* the_info ) { |
| 20 |
> |
info = the_info; |
| 21 |
> |
int baseSeed = the_info->getSeed(); |
| 22 |
|
|
| 23 |
|
gaussStream = new gaussianSPRNG( baseSeed ); |
| 24 |
|
} |
| 42 |
|
Atom** atoms; |
| 43 |
|
|
| 44 |
|
|
| 45 |
< |
n_atoms = entry_plug->n_atoms; |
| 46 |
< |
atoms = entry_plug->atoms; |
| 45 |
> |
n_atoms = info->n_atoms; |
| 46 |
> |
atoms = info->atoms; |
| 47 |
|
|
| 48 |
|
kinetic = 0.0; |
| 49 |
|
kinetic_global = 0.0; |
| 85 |
|
int el, nSRI; |
| 86 |
|
Molecule* molecules; |
| 87 |
|
|
| 88 |
< |
molecules = entry_plug->molecules; |
| 89 |
< |
nSRI = entry_plug->n_SRI; |
| 88 |
> |
molecules = info->molecules; |
| 89 |
> |
nSRI = info->n_SRI; |
| 90 |
|
|
| 91 |
|
potential_local = 0.0; |
| 92 |
|
potential = 0.0; |
| 93 |
< |
potential_local += entry_plug->lrPot; |
| 93 |
> |
potential_local += info->lrPot; |
| 94 |
|
|
| 95 |
< |
for( el=0; el<entry_plug->n_mol; el++ ){ |
| 95 |
> |
for( el=0; el<info->n_mol; el++ ){ |
| 96 |
|
potential_local += molecules[el].getPotential(); |
| 97 |
|
} |
| 98 |
|
|
| 126 |
|
const double kb = 1.9872179E-3; // boltzman's constant in kcal/(mol K) |
| 127 |
|
double temperature; |
| 128 |
|
|
| 129 |
< |
temperature = ( 2.0 * this->getKinetic() ) / ((double)entry_plug->ndf * kb ); |
| 129 |
> |
temperature = ( 2.0 * this->getKinetic() ) / ((double)info->ndf * kb ); |
| 130 |
|
return temperature; |
| 131 |
|
} |
| 132 |
|
|
| 148 |
|
|
| 149 |
|
double Thermo::getVolume() { |
| 150 |
|
|
| 151 |
< |
return entry_plug->boxVol; |
| 151 |
> |
return info->boxVol; |
| 152 |
|
} |
| 153 |
|
|
| 154 |
|
double Thermo::getPressure() { |
| 166 |
|
return pressure; |
| 167 |
|
} |
| 168 |
|
|
| 169 |
+ |
double Thermo::getPressureX() { |
| 170 |
|
|
| 171 |
+ |
// Relies on the calculation of the full molecular pressure tensor |
| 172 |
+ |
|
| 173 |
+ |
const double p_convert = 1.63882576e8; |
| 174 |
+ |
double press[3][3]; |
| 175 |
+ |
double pressureX; |
| 176 |
+ |
|
| 177 |
+ |
this->getPressureTensor(press); |
| 178 |
+ |
|
| 179 |
+ |
pressureX = p_convert * press[0][0]; |
| 180 |
+ |
|
| 181 |
+ |
return pressureX; |
| 182 |
+ |
} |
| 183 |
+ |
|
| 184 |
+ |
double Thermo::getPressureY() { |
| 185 |
+ |
|
| 186 |
+ |
// Relies on the calculation of the full molecular pressure tensor |
| 187 |
+ |
|
| 188 |
+ |
const double p_convert = 1.63882576e8; |
| 189 |
+ |
double press[3][3]; |
| 190 |
+ |
double pressureY; |
| 191 |
+ |
|
| 192 |
+ |
this->getPressureTensor(press); |
| 193 |
+ |
|
| 194 |
+ |
pressureY = p_convert * press[1][1]; |
| 195 |
+ |
|
| 196 |
+ |
return pressureY; |
| 197 |
+ |
} |
| 198 |
+ |
|
| 199 |
+ |
double Thermo::getPressureZ() { |
| 200 |
+ |
|
| 201 |
+ |
// Relies on the calculation of the full molecular pressure tensor |
| 202 |
+ |
|
| 203 |
+ |
const double p_convert = 1.63882576e8; |
| 204 |
+ |
double press[3][3]; |
| 205 |
+ |
double pressureZ; |
| 206 |
+ |
|
| 207 |
+ |
this->getPressureTensor(press); |
| 208 |
+ |
|
| 209 |
+ |
pressureZ = p_convert * press[2][2]; |
| 210 |
+ |
|
| 211 |
+ |
return pressureZ; |
| 212 |
+ |
} |
| 213 |
+ |
|
| 214 |
+ |
|
| 215 |
|
void Thermo::getPressureTensor(double press[3][3]){ |
| 216 |
|
// returns pressure tensor in units amu*fs^-2*Ang^-1 |
| 217 |
|
// routine derived via viral theorem description in: |
| 222 |
|
double molmass, volume; |
| 223 |
|
double vcom[3]; |
| 224 |
|
double p_local[9], p_global[9]; |
| 225 |
< |
int i, j, k, l, nMols; |
| 225 |
> |
int i, j, k, nMols; |
| 226 |
|
Molecule* molecules; |
| 227 |
|
|
| 228 |
< |
nMols = entry_plug->n_mol; |
| 229 |
< |
molecules = entry_plug->molecules; |
| 230 |
< |
//tau = entry_plug->tau; |
| 228 |
> |
nMols = info->n_mol; |
| 229 |
> |
molecules = info->molecules; |
| 230 |
> |
//tau = info->tau; |
| 231 |
|
|
| 232 |
|
// use velocities of molecular centers of mass and molecular masses: |
| 233 |
|
for (i=0; i < 9; i++) { |
| 264 |
|
for(i = 0; i < 3; i++) { |
| 265 |
|
for (j = 0; j < 3; j++) { |
| 266 |
|
k = 3*i + j; |
| 267 |
< |
press[i][j] = (p_global[k] + entry_plug->tau[k]*e_convert) / volume; |
| 267 |
> |
press[i][j] = (p_global[k] + info->tau[k]*e_convert) / volume; |
| 268 |
> |
|
| 269 |
|
} |
| 270 |
|
} |
| 271 |
|
} |
| 287 |
|
int n_oriented; |
| 288 |
|
int n_constraints; |
| 289 |
|
|
| 290 |
< |
atoms = entry_plug->atoms; |
| 291 |
< |
n_atoms = entry_plug->n_atoms; |
| 292 |
< |
temperature = entry_plug->target_temp; |
| 293 |
< |
n_oriented = entry_plug->n_oriented; |
| 294 |
< |
n_constraints = entry_plug->n_constraints; |
| 290 |
> |
atoms = info->atoms; |
| 291 |
> |
n_atoms = info->n_atoms; |
| 292 |
> |
temperature = info->target_temp; |
| 293 |
> |
n_oriented = info->n_oriented; |
| 294 |
> |
n_constraints = info->n_constraints; |
| 295 |
|
|
| 296 |
< |
kebar = kb * temperature * (double)entry_plug->ndf / |
| 297 |
< |
( 2.0 * (double)entry_plug->ndfRaw ); |
| 296 |
> |
kebar = kb * temperature * (double)info->ndf / |
| 297 |
> |
( 2.0 * (double)info->ndfRaw ); |
| 298 |
|
|
| 299 |
|
for(vr = 0; vr < n_atoms; vr++){ |
| 300 |
|
|
| 365 |
|
// We are very careless here with the distinction between n_atoms and n_local |
| 366 |
|
// We should really fix this before someone pokes an eye out. |
| 367 |
|
|
| 368 |
< |
n_atoms = entry_plug->n_atoms; |
| 369 |
< |
atoms = entry_plug->atoms; |
| 368 |
> |
n_atoms = info->n_atoms; |
| 369 |
> |
atoms = info->atoms; |
| 370 |
|
|
| 371 |
|
mtot_local = 0.0; |
| 372 |
|
vdrift_local[0] = 0.0; |