| 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 | 
  | 
#include "integrators/NVT.hpp" | 
| 43 | 
  | 
#include "primitives/Molecule.hpp" | 
| 44 | 
  | 
#include "utils/simError.h" | 
| 45 | 
< | 
#include "utils/OOPSEConstant.hpp" | 
| 45 | 
> | 
#include "utils/PhysicalConstants.hpp" | 
| 46 | 
  | 
 | 
| 47 | 
< | 
namespace oopse { | 
| 47 | 
> | 
namespace OpenMD { | 
| 48 | 
  | 
 | 
| 49 | 
  | 
  NVT::NVT(SimInfo* info) : VelocityVerletIntegrator(info), chiTolerance_ (1e-6), maxIterNum_(4) { | 
| 50 | 
  | 
 | 
| 51 | 
  | 
    Globals* simParams = info_->getSimParams(); | 
| 52 | 
  | 
 | 
| 53 | 
< | 
    if (!simParams->getUseInitXSstate()) { | 
| 53 | 
> | 
    if (!simParams->getUseIntialExtendedSystemState()) { | 
| 54 | 
  | 
      Snapshot* currSnapshot = info_->getSnapshotManager()->getCurrentSnapshot(); | 
| 55 | 
  | 
      currSnapshot->setChi(0.0); | 
| 56 | 
  | 
      currSnapshot->setIntegralOfChiDt(0.0); | 
| 59 | 
  | 
    if (!simParams->haveTargetTemp()) { | 
| 60 | 
  | 
      sprintf(painCave.errMsg, "You can't use the NVT integrator without a targetTemp_!\n"); | 
| 61 | 
  | 
      painCave.isFatal = 1; | 
| 62 | 
< | 
      painCave.severity = OOPSE_ERROR; | 
| 62 | 
> | 
      painCave.severity = OPENMD_ERROR; | 
| 63 | 
  | 
      simError(); | 
| 64 | 
  | 
    } else { | 
| 65 | 
  | 
      targetTemp_ = simParams->getTargetTemp(); | 
| 66 | 
  | 
    } | 
| 67 | 
  | 
 | 
| 68 | 
< | 
    // We must set tauThermostat_. | 
| 68 | 
> | 
    // We must set tauThermostat. | 
| 69 | 
  | 
 | 
| 70 | 
  | 
    if (!simParams->haveTauThermostat()) { | 
| 71 | 
  | 
      sprintf(painCave.errMsg, "If you use the constant temperature\n" | 
| 72 | 
< | 
              "\tintegrator, you must set tauThermostat_.\n"); | 
| 72 | 
> | 
              "\tintegrator, you must set tauThermostat.\n"); | 
| 73 | 
  | 
 | 
| 74 | 
< | 
      painCave.severity = OOPSE_ERROR; | 
| 74 | 
> | 
      painCave.severity = OPENMD_ERROR; | 
| 75 | 
  | 
      painCave.isFatal = 1; | 
| 76 | 
  | 
      simError(); | 
| 77 | 
  | 
    } else { | 
| 92 | 
  | 
    StuntDouble* integrableObject; | 
| 93 | 
  | 
    Vector3d Tb; | 
| 94 | 
  | 
    Vector3d ji; | 
| 95 | 
< | 
    double mass; | 
| 95 | 
> | 
    RealType mass; | 
| 96 | 
  | 
    Vector3d vel; | 
| 97 | 
  | 
    Vector3d pos; | 
| 98 | 
  | 
    Vector3d frc; | 
| 99 | 
  | 
 | 
| 100 | 
< | 
    double chi = currentSnapshot_->getChi(); | 
| 101 | 
< | 
    double integralOfChidt = currentSnapshot_->getIntegralOfChiDt(); | 
| 100 | 
> | 
    RealType chi = currentSnapshot_->getChi(); | 
| 101 | 
> | 
    RealType integralOfChidt = currentSnapshot_->getIntegralOfChiDt(); | 
| 102 | 
  | 
     | 
| 103 | 
  | 
    // We need the temperature at time = t for the chi update below: | 
| 104 | 
  | 
 | 
| 105 | 
< | 
    double instTemp = thermo.getTemperature(); | 
| 105 | 
> | 
    RealType instTemp = thermo.getTemperature(); | 
| 106 | 
  | 
 | 
| 107 | 
  | 
    for (mol = info_->beginMolecule(i); mol != NULL; mol = info_->nextMolecule(i)) { | 
| 108 | 
  | 
      for (integrableObject = mol->beginIntegrableObject(j); integrableObject != NULL; | 
| 115 | 
  | 
        mass = integrableObject->getMass(); | 
| 116 | 
  | 
 | 
| 117 | 
  | 
        // velocity half step  (use chi from previous step here): | 
| 118 | 
< | 
        //vel[j] += dt2 * ((frc[j] / mass ) * OOPSEConstant::energyConvert - vel[j]*chi); | 
| 119 | 
< | 
        vel += dt2 *OOPSEConstant::energyConvert/mass*frc - dt2*chi*vel; | 
| 118 | 
> | 
        //vel[j] += dt2 * ((frc[j] / mass ) * PhysicalConstants::energyConvert - vel[j]*chi); | 
| 119 | 
> | 
        vel += dt2 *PhysicalConstants::energyConvert/mass*frc - dt2*chi*vel; | 
| 120 | 
  | 
         | 
| 121 | 
  | 
        // position whole step | 
| 122 | 
  | 
        //pos[j] += dt * vel[j]; | 
| 134 | 
  | 
 | 
| 135 | 
  | 
          ji = integrableObject->getJ(); | 
| 136 | 
  | 
 | 
| 137 | 
< | 
          //ji[j] += dt2 * (Tb[j] * OOPSEConstant::energyConvert - ji[j]*chi); | 
| 138 | 
< | 
          ji += dt2*OOPSEConstant::energyConvert*Tb - dt2*chi *ji; | 
| 137 | 
> | 
          //ji[j] += dt2 * (Tb[j] * PhysicalConstants::energyConvert - ji[j]*chi); | 
| 138 | 
> | 
          ji += dt2*PhysicalConstants::energyConvert*Tb - dt2*chi *ji; | 
| 139 | 
  | 
          rotAlgo->rotate(integrableObject, ji, dt); | 
| 140 | 
  | 
 | 
| 141 | 
  | 
          integrableObject->setJ(ji); | 
| 167 | 
  | 
    Vector3d ji;     | 
| 168 | 
  | 
    Vector3d vel; | 
| 169 | 
  | 
    Vector3d frc; | 
| 170 | 
< | 
    double mass; | 
| 171 | 
< | 
    double instTemp; | 
| 170 | 
> | 
    RealType mass; | 
| 171 | 
> | 
    RealType instTemp; | 
| 172 | 
  | 
    int index; | 
| 173 | 
  | 
    // Set things up for the iteration: | 
| 174 | 
  | 
 | 
| 175 | 
< | 
    double chi = currentSnapshot_->getChi(); | 
| 176 | 
< | 
    double oldChi = chi; | 
| 177 | 
< | 
    double  prevChi; | 
| 178 | 
< | 
    double integralOfChidt = currentSnapshot_->getIntegralOfChiDt(); | 
| 175 | 
> | 
    RealType chi = currentSnapshot_->getChi(); | 
| 176 | 
> | 
    RealType oldChi = chi; | 
| 177 | 
> | 
    RealType  prevChi; | 
| 178 | 
> | 
    RealType integralOfChidt = currentSnapshot_->getIntegralOfChiDt(); | 
| 179 | 
  | 
 | 
| 180 | 
  | 
    index = 0; | 
| 181 | 
  | 
    for (mol = info_->beginMolecule(i); mol != NULL; mol = info_->nextMolecule(i)) { | 
| 211 | 
  | 
 | 
| 212 | 
  | 
          // velocity half step | 
| 213 | 
  | 
          //for(j = 0; j < 3; j++) | 
| 214 | 
< | 
          //    vel[j] = oldVel_[3*i+j] + dt2 * ((frc[j] / mass ) * OOPSEConstant::energyConvert - oldVel_[3*i + j]*chi); | 
| 215 | 
< | 
          vel = oldVel_[index] + dt2/mass*OOPSEConstant::energyConvert * frc - dt2*chi*oldVel_[index]; | 
| 214 | 
> | 
          //    vel[j] = oldVel_[3*i+j] + dt2 * ((frc[j] / mass ) * PhysicalConstants::energyConvert - oldVel_[3*i + j]*chi); | 
| 215 | 
> | 
          vel = oldVel_[index] + dt2/mass*PhysicalConstants::energyConvert * frc - dt2*chi*oldVel_[index]; | 
| 216 | 
  | 
             | 
| 217 | 
  | 
          integrableObject->setVel(vel); | 
| 218 | 
  | 
 | 
| 223 | 
  | 
            Tb =  integrableObject->lab2Body(integrableObject->getTrq()); | 
| 224 | 
  | 
 | 
| 225 | 
  | 
            //for(j = 0; j < 3; j++) | 
| 226 | 
< | 
            //    ji[j] = oldJi_[3*i + j] + dt2 * (Tb[j] * OOPSEConstant::energyConvert - oldJi_[3*i+j]*chi); | 
| 227 | 
< | 
            ji = oldJi_[index] + dt2*OOPSEConstant::energyConvert*Tb - dt2*chi *oldJi_[index]; | 
| 226 | 
> | 
            //    ji[j] = oldJi_[3*i + j] + dt2 * (Tb[j] * PhysicalConstants::energyConvert - oldJi_[3*i+j]*chi); | 
| 227 | 
> | 
            ji = oldJi_[index] + dt2*PhysicalConstants::energyConvert*Tb - dt2*chi *oldJi_[index]; | 
| 228 | 
  | 
 | 
| 229 | 
  | 
            integrableObject->setJ(ji); | 
| 230 | 
  | 
          } | 
| 253 | 
  | 
      currentSnapshot_->setIntegralOfChiDt(0.0); | 
| 254 | 
  | 
  } | 
| 255 | 
  | 
   | 
| 256 | 
< | 
  double NVT::calcConservedQuantity() { | 
| 256 | 
> | 
  RealType NVT::calcConservedQuantity() { | 
| 257 | 
  | 
 | 
| 258 | 
< | 
    double chi = currentSnapshot_->getChi(); | 
| 259 | 
< | 
    double integralOfChidt = currentSnapshot_->getIntegralOfChiDt(); | 
| 260 | 
< | 
    double conservedQuantity; | 
| 261 | 
< | 
    double fkBT; | 
| 262 | 
< | 
    double Energy; | 
| 263 | 
< | 
    double thermostat_kinetic; | 
| 264 | 
< | 
    double thermostat_potential; | 
| 258 | 
> | 
    RealType chi = currentSnapshot_->getChi(); | 
| 259 | 
> | 
    RealType integralOfChidt = currentSnapshot_->getIntegralOfChiDt(); | 
| 260 | 
> | 
    RealType conservedQuantity; | 
| 261 | 
> | 
    RealType fkBT; | 
| 262 | 
> | 
    RealType Energy; | 
| 263 | 
> | 
    RealType thermostat_kinetic; | 
| 264 | 
> | 
    RealType thermostat_potential; | 
| 265 | 
  | 
     | 
| 266 | 
< | 
    fkBT = info_->getNdf() *OOPSEConstant::kB *targetTemp_; | 
| 266 | 
> | 
    fkBT = info_->getNdf() *PhysicalConstants::kB *targetTemp_; | 
| 267 | 
  | 
 | 
| 268 | 
  | 
    Energy = thermo.getTotalE(); | 
| 269 | 
  | 
 | 
| 270 | 
< | 
    thermostat_kinetic = fkBT * tauThermostat_ * tauThermostat_ * chi * chi / (2.0 * OOPSEConstant::energyConvert); | 
| 270 | 
> | 
    thermostat_kinetic = fkBT * tauThermostat_ * tauThermostat_ * chi * chi / (2.0 * PhysicalConstants::energyConvert); | 
| 271 | 
  | 
 | 
| 272 | 
< | 
    thermostat_potential = fkBT * integralOfChidt / OOPSEConstant::energyConvert; | 
| 272 | 
> | 
    thermostat_potential = fkBT * integralOfChidt / PhysicalConstants::energyConvert; | 
| 273 | 
  | 
 | 
| 274 | 
  | 
    conservedQuantity = Energy + thermostat_kinetic + thermostat_potential; | 
| 275 | 
  | 
 | 
| 277 | 
  | 
  } | 
| 278 | 
  | 
 | 
| 279 | 
  | 
 | 
| 280 | 
< | 
}//end namespace oopse | 
| 280 | 
> | 
}//end namespace OpenMD |