| 1 |
< |
/* |
| 1 |
> |
/* |
| 2 |
|
* Copyright (c) 2005 The University of Notre Dame. All Rights Reserved. |
| 3 |
|
* |
| 4 |
|
* The University of Notre Dame grants you ("Licensee") a |
| 6 |
|
* redistribute this software in source and binary code form, provided |
| 7 |
|
* that the following conditions are met: |
| 8 |
|
* |
| 9 |
< |
* 1. Acknowledgement of the program authors must be made in any |
| 10 |
< |
* publication of scientific results based in part on use of the |
| 11 |
< |
* program. An acceptable form of acknowledgement is citation of |
| 12 |
< |
* the article in which the program was described (Matthew |
| 13 |
< |
* A. Meineke, Charles F. Vardeman II, Teng Lin, Christopher |
| 14 |
< |
* J. Fennell and J. Daniel Gezelter, "OOPSE: An Object-Oriented |
| 15 |
< |
* Parallel Simulation Engine for Molecular Dynamics," |
| 16 |
< |
* J. Comput. Chem. 26, pp. 252-271 (2005)) |
| 17 |
< |
* |
| 18 |
< |
* 2. Redistributions of source code must retain the above copyright |
| 9 |
> |
* 1. Redistributions of source code must retain the above copyright |
| 10 |
|
* notice, this list of conditions and the following disclaimer. |
| 11 |
|
* |
| 12 |
< |
* 3. Redistributions in binary form must reproduce the above copyright |
| 12 |
> |
* 2. Redistributions in binary form must reproduce the above copyright |
| 13 |
|
* notice, this list of conditions and the following disclaimer in the |
| 14 |
|
* documentation and/or other materials provided with the |
| 15 |
|
* distribution. |
| 28 |
|
* arising out of the use of or inability to use software, even if the |
| 29 |
|
* University of Notre Dame has been advised of the possibility of |
| 30 |
|
* such damages. |
| 31 |
+ |
* |
| 32 |
+ |
* SUPPORT OPEN SCIENCE! If you use OpenMD or its source code in your |
| 33 |
+ |
* research, please cite the appropriate papers when you publish your |
| 34 |
+ |
* work. Good starting points are: |
| 35 |
+ |
* |
| 36 |
+ |
* [1] Meineke, et al., J. Comp. Chem. 26, 252-271 (2005). |
| 37 |
+ |
* [2] Fennell & Gezelter, J. Chem. Phys. 124, 234104 (2006). |
| 38 |
+ |
* [3] Sun, Lin & Gezelter, J. Chem. Phys. 128, 24107 (2008). |
| 39 |
+ |
* [4] Vardeman & Gezelter, in progress (2009). |
| 40 |
|
*/ |
| 41 |
|
|
| 42 |
|
/** |
| 51 |
|
#include "integrators/DLM.hpp" |
| 52 |
|
#include "utils/StringUtils.hpp" |
| 53 |
|
|
| 54 |
< |
namespace oopse { |
| 55 |
< |
VelocityVerletIntegrator::VelocityVerletIntegrator(SimInfo *info) : Integrator(info), rotAlgo(NULL) { |
| 54 |
> |
namespace OpenMD { |
| 55 |
> |
VelocityVerletIntegrator::VelocityVerletIntegrator(SimInfo *info) : Integrator(info), rotAlgo(NULL) { |
| 56 |
|
dt2 = 0.5 * dt; |
| 57 |
|
rotAlgo = new DLM(); |
| 58 |
|
rattle = new Rattle(info); |
| 59 |
< |
} |
| 60 |
< |
|
| 61 |
< |
VelocityVerletIntegrator::~VelocityVerletIntegrator() { |
| 59 |
> |
} |
| 60 |
> |
|
| 61 |
> |
VelocityVerletIntegrator::~VelocityVerletIntegrator() { |
| 62 |
|
delete rotAlgo; |
| 63 |
|
delete rattle; |
| 64 |
< |
} |
| 65 |
< |
|
| 66 |
< |
void VelocityVerletIntegrator::initialize(){ |
| 67 |
< |
|
| 64 |
> |
} |
| 65 |
> |
|
| 66 |
> |
void VelocityVerletIntegrator::initialize(){ |
| 67 |
> |
|
| 68 |
|
forceMan_->init(); |
| 69 |
< |
|
| 70 |
< |
// remove center of mass drift velocity (in case we passed in a configuration |
| 71 |
< |
// that was drifting |
| 69 |
> |
|
| 70 |
> |
// remove center of mass drift velocity (in case we passed in a |
| 71 |
> |
// configuration that was drifting) |
| 72 |
|
velocitizer_->removeComDrift(); |
| 73 |
< |
|
| 73 |
> |
|
| 74 |
|
// initialize the forces before the first step |
| 75 |
|
calcForce(true, true); |
| 76 |
< |
|
| 77 |
< |
//execute constraint algorithm to make sure at the very beginning the system is constrained |
| 76 |
> |
|
| 77 |
> |
// execute the constraint algorithm to make sure that the system is |
| 78 |
> |
// constrained at the very beginning |
| 79 |
|
if (info_->getNGlobalConstraints() > 0) { |
| 80 |
< |
rattle->constraintA(); |
| 81 |
< |
calcForce(true, true); |
| 82 |
< |
rattle->constraintB(); |
| 83 |
< |
info_->getSnapshotManager()->advance();//copy the current snapshot to previous snapshot |
| 80 |
> |
rattle->constraintA(); |
| 81 |
> |
calcForce(true, true); |
| 82 |
> |
rattle->constraintB(); |
| 83 |
> |
//copy the current snapshot to previous snapshot |
| 84 |
> |
info_->getSnapshotManager()->advance(); |
| 85 |
|
} |
| 86 |
< |
|
| 86 |
> |
|
| 87 |
|
if (needVelocityScaling) { |
| 88 |
< |
velocitizer_->velocitize(targetScalingTemp); |
| 88 |
> |
velocitizer_->velocitize(targetScalingTemp); |
| 89 |
|
} |
| 90 |
|
|
| 91 |
|
dumpWriter = createDumpWriter(); |
| 92 |
< |
|
| 92 |
> |
|
| 93 |
|
statWriter = createStatWriter(); |
| 94 |
< |
|
| 94 |
> |
|
| 95 |
|
dumpWriter->writeDumpAndEor(); |
| 96 |
< |
|
| 96 |
> |
|
| 97 |
|
//save statistics, before writeStat, we must save statistics |
| 98 |
|
thermo.saveStat(); |
| 99 |
|
saveConservedQuantity(); |
| 100 |
< |
statWriter->writeStat(currentSnapshot_->statData); |
| 100 |
> |
if (simParams->getUseRNEMD()) |
| 101 |
> |
rnemd_->getStarted(); |
| 102 |
|
|
| 103 |
+ |
statWriter->writeStat(currentSnapshot_->statData); |
| 104 |
+ |
|
| 105 |
|
currSample = sampleTime + currentSnapshot_->getTime(); |
| 106 |
< |
currStatus = statusTime + currentSnapshot_->getTime();; |
| 107 |
< |
currThermal = thermalTime + + currentSnapshot_->getTime(); |
| 106 |
> |
currStatus = statusTime + currentSnapshot_->getTime(); |
| 107 |
> |
currThermal = thermalTime + currentSnapshot_->getTime(); |
| 108 |
> |
if (needReset) { |
| 109 |
> |
currReset = resetTime + currentSnapshot_->getTime(); |
| 110 |
> |
} |
| 111 |
> |
if (simParams->getUseRNEMD()){ |
| 112 |
> |
currRNEMD = RNEMD_exchangeTime + currentSnapshot_->getTime(); |
| 113 |
> |
} |
| 114 |
|
needPotential = false; |
| 115 |
|
needStress = false; |
| 116 |
< |
|
| 117 |
< |
} |
| 107 |
< |
|
| 108 |
< |
void VelocityVerletIntegrator::doIntegrate() { |
| 116 |
> |
|
| 117 |
> |
} |
| 118 |
|
|
| 119 |
< |
|
| 119 |
> |
void VelocityVerletIntegrator::doIntegrate() { |
| 120 |
> |
|
| 121 |
> |
|
| 122 |
|
initialize(); |
| 123 |
< |
|
| 123 |
> |
|
| 124 |
|
while (currentSnapshot_->getTime() < runTime) { |
| 125 |
< |
|
| 126 |
< |
preStep(); |
| 127 |
< |
|
| 128 |
< |
integrateStep(); |
| 129 |
< |
|
| 130 |
< |
postStep(); |
| 131 |
< |
|
| 125 |
> |
|
| 126 |
> |
preStep(); |
| 127 |
> |
|
| 128 |
> |
integrateStep(); |
| 129 |
> |
|
| 130 |
> |
postStep(); |
| 131 |
> |
|
| 132 |
|
} |
| 133 |
< |
|
| 133 |
> |
|
| 134 |
|
finalize(); |
| 135 |
< |
|
| 136 |
< |
} |
| 135 |
> |
|
| 136 |
> |
} |
| 137 |
|
|
| 138 |
|
|
| 139 |
< |
void VelocityVerletIntegrator::preStep() { |
| 140 |
< |
double difference = currentSnapshot_->getTime() + dt - currStatus; |
| 139 |
> |
void VelocityVerletIntegrator::preStep() { |
| 140 |
> |
RealType difference = currentSnapshot_->getTime() + dt - currStatus; |
| 141 |
> |
|
| 142 |
> |
if (difference > 0 || fabs(difference) < OpenMD::epsilon) { |
| 143 |
> |
needPotential = true; |
| 144 |
> |
needStress = true; |
| 145 |
> |
} |
| 146 |
> |
} |
| 147 |
|
|
| 148 |
< |
if (difference > 0 || fabs(difference) < oopse::epsilon) { |
| 132 |
< |
needPotential = true; |
| 133 |
< |
needStress = true; |
| 134 |
< |
} |
| 148 |
> |
void VelocityVerletIntegrator::postStep() { |
| 149 |
|
|
| 150 |
< |
} |
| 150 |
> |
//save snapshot |
| 151 |
> |
info_->getSnapshotManager()->advance(); |
| 152 |
> |
|
| 153 |
> |
//increase time |
| 154 |
> |
currentSnapshot_->increaseTime(dt); |
| 155 |
> |
|
| 156 |
> |
if (needVelocityScaling) { |
| 157 |
> |
if (currentSnapshot_->getTime() >= currThermal) { |
| 158 |
> |
velocitizer_->velocitize(targetScalingTemp); |
| 159 |
> |
currThermal += thermalTime; |
| 160 |
> |
} |
| 161 |
> |
} |
| 162 |
> |
if (useRNEMD) { |
| 163 |
> |
rnemd_->collectData(); |
| 164 |
> |
if (currentSnapshot_->getTime() >= currRNEMD) { |
| 165 |
> |
rnemd_->doRNEMD(); |
| 166 |
> |
currRNEMD += RNEMD_exchangeTime; |
| 167 |
> |
} |
| 168 |
> |
} |
| 169 |
> |
|
| 170 |
> |
if (currentSnapshot_->getTime() >= currSample) { |
| 171 |
> |
dumpWriter->writeDumpAndEor(); |
| 172 |
> |
|
| 173 |
> |
currSample += sampleTime; |
| 174 |
> |
} |
| 175 |
> |
|
| 176 |
> |
if (currentSnapshot_->getTime() >= currStatus) { |
| 177 |
> |
//save statistics, before writeStat, we must save statistics |
| 178 |
> |
thermo.saveStat(); |
| 179 |
> |
saveConservedQuantity(); |
| 180 |
|
|
| 181 |
< |
void VelocityVerletIntegrator::postStep() { |
| 181 |
> |
if (simParams->getUseRNEMD()) { |
| 182 |
> |
rnemd_->getStatus(); |
| 183 |
> |
} |
| 184 |
|
|
| 185 |
< |
//save snapshot |
| 186 |
< |
info_->getSnapshotManager()->advance(); |
| 185 |
> |
statWriter->writeStat(currentSnapshot_->statData); |
| 186 |
> |
|
| 187 |
> |
needPotential = false; |
| 188 |
> |
needStress = false; |
| 189 |
> |
currStatus += statusTime; |
| 190 |
> |
} |
| 191 |
> |
|
| 192 |
> |
if (needReset && currentSnapshot_->getTime() >= currReset) { |
| 193 |
> |
resetIntegrator(); |
| 194 |
> |
currReset += resetTime; |
| 195 |
> |
} |
| 196 |
> |
} |
| 197 |
|
|
| 143 |
– |
//increase time |
| 144 |
– |
currentSnapshot_->increaseTime(dt); |
| 145 |
– |
|
| 146 |
– |
if (needVelocityScaling) { |
| 147 |
– |
if (currentSnapshot_->getTime() >= currThermal) { |
| 148 |
– |
velocitizer_->velocitize(targetScalingTemp); |
| 149 |
– |
currThermal += thermalTime; |
| 150 |
– |
} |
| 151 |
– |
} |
| 198 |
|
|
| 199 |
< |
if (currentSnapshot_->getTime() >= currSample) { |
| 200 |
< |
dumpWriter->writeDumpAndEor(); |
| 201 |
< |
currSample += sampleTime; |
| 156 |
< |
} |
| 157 |
< |
|
| 158 |
< |
if (currentSnapshot_->getTime() >= currStatus) { |
| 159 |
< |
//save statistics, before writeStat, we must save statistics |
| 160 |
< |
thermo.saveStat(); |
| 161 |
< |
saveConservedQuantity(); |
| 162 |
< |
statWriter->writeStat(currentSnapshot_->statData); |
| 163 |
< |
|
| 164 |
< |
needPotential = false; |
| 165 |
< |
needStress = false; |
| 166 |
< |
currStatus += statusTime; |
| 167 |
< |
} |
| 168 |
< |
|
| 169 |
< |
|
| 170 |
< |
} |
| 171 |
< |
|
| 172 |
< |
|
| 173 |
< |
void VelocityVerletIntegrator::finalize() { |
| 174 |
< |
dumpWriter->writeEor(); |
| 175 |
< |
|
| 199 |
> |
void VelocityVerletIntegrator::finalize() { |
| 200 |
> |
dumpWriter->writeEor(); |
| 201 |
> |
|
| 202 |
|
delete dumpWriter; |
| 203 |
|
delete statWriter; |
| 204 |
< |
|
| 204 |
> |
|
| 205 |
|
dumpWriter = NULL; |
| 206 |
|
statWriter = NULL; |
| 207 |
< |
|
| 208 |
< |
} |
| 207 |
> |
|
| 208 |
> |
} |
| 209 |
|
|
| 210 |
< |
void VelocityVerletIntegrator::integrateStep() { |
| 211 |
< |
|
| 210 |
> |
void VelocityVerletIntegrator::integrateStep() { |
| 211 |
> |
|
| 212 |
|
moveA(); |
| 213 |
|
calcForce(needPotential, needStress); |
| 214 |
|
moveB(); |
| 215 |
< |
} |
| 215 |
> |
} |
| 216 |
|
|
| 217 |
|
|
| 218 |
< |
void VelocityVerletIntegrator::calcForce(bool needPotential, |
| 219 |
< |
bool needStress) { |
| 218 |
> |
void VelocityVerletIntegrator::calcForce(bool needPotential, |
| 219 |
> |
bool needStress) { |
| 220 |
|
forceMan_->calcForces(needPotential, needStress); |
| 221 |
< |
} |
| 221 |
> |
} |
| 222 |
|
|
| 223 |
< |
DumpWriter* VelocityVerletIntegrator::createDumpWriter() { |
| 223 |
> |
DumpWriter* VelocityVerletIntegrator::createDumpWriter() { |
| 224 |
|
return new DumpWriter(info_); |
| 225 |
< |
} |
| 225 |
> |
} |
| 226 |
|
|
| 227 |
< |
StatWriter* VelocityVerletIntegrator::createStatWriter() { |
| 202 |
< |
return new StatWriter(info_->getStatFileName()); |
| 203 |
< |
} |
| 227 |
> |
StatWriter* VelocityVerletIntegrator::createStatWriter() { |
| 228 |
|
|
| 229 |
+ |
std::string statFileFormatString = simParams->getStatFileFormat(); |
| 230 |
+ |
StatsBitSet mask = parseStatFileFormat(statFileFormatString); |
| 231 |
+ |
|
| 232 |
+ |
// if we're doing a thermodynamic integration, we'll want the raw |
| 233 |
+ |
// potential as well as the full potential: |
| 234 |
|
|
| 235 |
< |
} //end namespace oopse |
| 235 |
> |
|
| 236 |
> |
if (simParams->getUseThermodynamicIntegration()) |
| 237 |
> |
mask.set(Stats::VRAW); |
| 238 |
> |
|
| 239 |
> |
// if we've got restraints turned on, we'll also want a report of the |
| 240 |
> |
// total harmonic restraints |
| 241 |
> |
if (simParams->getUseRestraints()){ |
| 242 |
> |
mask.set(Stats::VHARM); |
| 243 |
> |
} |
| 244 |
> |
|
| 245 |
> |
if (simParams->havePrintPressureTensor() && |
| 246 |
> |
simParams->getPrintPressureTensor()){ |
| 247 |
> |
mask.set(Stats::PRESSURE_TENSOR_XX); |
| 248 |
> |
mask.set(Stats::PRESSURE_TENSOR_XY); |
| 249 |
> |
mask.set(Stats::PRESSURE_TENSOR_XZ); |
| 250 |
> |
mask.set(Stats::PRESSURE_TENSOR_YX); |
| 251 |
> |
mask.set(Stats::PRESSURE_TENSOR_YY); |
| 252 |
> |
mask.set(Stats::PRESSURE_TENSOR_YZ); |
| 253 |
> |
mask.set(Stats::PRESSURE_TENSOR_ZX); |
| 254 |
> |
mask.set(Stats::PRESSURE_TENSOR_ZY); |
| 255 |
> |
mask.set(Stats::PRESSURE_TENSOR_ZZ); |
| 256 |
> |
} |
| 257 |
> |
|
| 258 |
> |
if (simParams->getAccumulateBoxDipole()) { |
| 259 |
> |
mask.set(Stats::BOX_DIPOLE_X); |
| 260 |
> |
mask.set(Stats::BOX_DIPOLE_Y); |
| 261 |
> |
mask.set(Stats::BOX_DIPOLE_Z); |
| 262 |
> |
} |
| 263 |
> |
|
| 264 |
> |
if (simParams->haveTaggedAtomPair() && simParams->havePrintTaggedPairDistance()) { |
| 265 |
> |
if (simParams->getPrintTaggedPairDistance()) { |
| 266 |
> |
mask.set(Stats::TAGGED_PAIR_DISTANCE); |
| 267 |
> |
} |
| 268 |
> |
} |
| 269 |
> |
|
| 270 |
> |
if (simParams->getUseRNEMD()) { |
| 271 |
> |
mask.set(Stats::RNEMD_EXCHANGE_TOTAL); |
| 272 |
> |
} |
| 273 |
> |
|
| 274 |
> |
|
| 275 |
> |
return new StatWriter(info_->getStatFileName(), mask); |
| 276 |
> |
} |
| 277 |
> |
|
| 278 |
> |
|
| 279 |
> |
} //end namespace OpenMD |