| 19 | 
  | 
//  | 
| 20 | 
  | 
//    Hoover, W. G., 1986, Phys. Rev. A, 34, 2499. | 
| 21 | 
  | 
 | 
| 22 | 
< | 
NPTi::NPTi ( SimInfo *theInfo, ForceFields* the_ff): | 
| 22 | 
> | 
NPTf::NPTf ( SimInfo *theInfo, ForceFields* the_ff): | 
| 23 | 
  | 
  Integrator( theInfo, the_ff ) | 
| 24 | 
  | 
{ | 
| 25 | 
  | 
  int i; | 
| 31 | 
  | 
  have_target_pressure = 0; | 
| 32 | 
  | 
} | 
| 33 | 
  | 
 | 
| 34 | 
< | 
void NPTi::moveA() { | 
| 34 | 
> | 
void NPTf::moveA() { | 
| 35 | 
  | 
   | 
| 36 | 
  | 
  int i,j,k; | 
| 37 | 
  | 
  int atomIndex, aMatIndex; | 
| 42 | 
  | 
  double instaTemp, instaPress, instaVol; | 
| 43 | 
  | 
  double tt2, tb2; | 
| 44 | 
  | 
  double angle; | 
| 45 | 
+ | 
  double press[9]; | 
| 46 | 
+ | 
  const double p_convert = 1.63882576e8; | 
| 47 | 
  | 
 | 
| 48 | 
  | 
  tt2 = tauThermostat * tauThermostat; | 
| 49 | 
  | 
  tb2 = tauBarostat * tauBarostat; | 
| 50 | 
  | 
 | 
| 51 | 
  | 
  instaTemp = tStats->getTemperature(); | 
| 52 | 
< | 
  instaPress = tStats->getPressure(); | 
| 52 | 
> | 
  tStats->getPressureTensor(press); | 
| 53 | 
> | 
 | 
| 54 | 
> | 
  for (i=0; i < 9; i++) press[i] *= p_convert; | 
| 55 | 
> | 
 | 
| 56 | 
  | 
  instaVol = tStats->getVolume(); | 
| 57 | 
  | 
    | 
| 58 | 
  | 
  // first evolve chi a half step | 
| 59 | 
  | 
   | 
| 60 | 
  | 
  chi += dt2 * ( instaTemp / targetTemp - 1.0) / tt2; | 
| 61 | 
  | 
   | 
| 62 | 
< | 
  for (i = 0; i < 9; i++) { | 
| 63 | 
< | 
    eta[i] += dt2 * ( instaVol * (sigma[i] - targetPressure*identMat[i]))  | 
| 64 | 
< | 
      / (NkBT*tb2)); | 
| 65 | 
< | 
} | 
| 66 | 
< | 
 | 
| 62 | 
> | 
  eta[0] += dt2 * instaVol * (press[0] - targetPressure) / (NkBT*tb2); | 
| 63 | 
> | 
  eta[1] += dt2 * instaVol * press[1] / (NkBT*tb2); | 
| 64 | 
> | 
  eta[2] += dt2 * instaVol * press[2] / (NkBT*tb2); | 
| 65 | 
> | 
  eta[3] += dt2 * instaVol * press[3] / (NkBT*tb2); | 
| 66 | 
> | 
  eta[4] += dt2 * instaVol * (press[4] - targetPressure) / (NkBT*tb2); | 
| 67 | 
> | 
  eta[5] += dt2 * instaVol * press[5] / (NkBT*tb2); | 
| 68 | 
> | 
  eta[6] += dt2 * instaVol * press[6] / (NkBT*tb2); | 
| 69 | 
> | 
  eta[7] += dt2 * instaVol * press[7] / (NkBT*tb2); | 
| 70 | 
> | 
  eta[8] += dt2 * instaVol * (press[8] - targetPressure) / (NkBT*tb2); | 
| 71 | 
> | 
   | 
| 72 | 
  | 
  for( i=0; i<nAtoms; i++ ){ | 
| 73 | 
  | 
    atomIndex = i * 3; | 
| 74 | 
  | 
    aMatIndex = i * 9; | 
| 75 | 
  | 
     | 
| 76 | 
  | 
    // velocity half step | 
| 77 | 
< | 
    for( j=atomIndex; j<(atomIndex+3); j++ ) | 
| 78 | 
< | 
      vel[j] += dt2 * ((frc[j]/atoms[i]->getMass())*eConvert  | 
| 79 | 
< | 
                       - vel[j]*(chi+eta)); | 
| 77 | 
> | 
     | 
| 78 | 
> | 
    vx = vel[atomIndex]; | 
| 79 | 
> | 
    vy = vel[atomIndex+1]; | 
| 80 | 
> | 
    vz = vel[atomIndex+2]; | 
| 81 | 
> | 
     | 
| 82 | 
> | 
    scx = (chi + eta[0])*vx + eta[1]*vy + eta[2]*vz; | 
| 83 | 
> | 
    scy = eta[3]*vx + (chi + eta[4])*vy + eta[5]*vz; | 
| 84 | 
> | 
    scz = eta[6]*vx + eta[7]*vy + (chi + eta[8])*vz; | 
| 85 | 
> | 
     | 
| 86 | 
> | 
    vx += dt2 * ((frc[atomIndex]  /atoms[i]->getMass())*eConvert - scx); | 
| 87 | 
> | 
    vy += dt2 * ((frc[atomIndex+1]/atoms[i]->getMass())*eConvert - scy); | 
| 88 | 
> | 
    vz += dt2 * ((frc[atomIndex+2]/atoms[i]->getMass())*eConvert - scz); | 
| 89 | 
> | 
 | 
| 90 | 
> | 
    vel[atomIndex] = vx; | 
| 91 | 
> | 
    vel[atomIndex+1] = vy; | 
| 92 | 
> | 
    vel[atomIndex+2] = vz; | 
| 93 | 
  | 
 | 
| 94 | 
  | 
    // position whole step     | 
| 95 | 
  | 
 | 
| 96 | 
< | 
    for( j=atomIndex; j<(atomIndex+3); j=j+3 ) { | 
| 97 | 
< | 
      rj[0] = pos[j]; | 
| 98 | 
< | 
      rj[1] = pos[j+1]; | 
| 76 | 
< | 
      rj[2] = pos[j+2]; | 
| 96 | 
> | 
    rj[0] = pos[atomIndex]; | 
| 97 | 
> | 
    rj[1] = pos[atomIndex+1]; | 
| 98 | 
> | 
    rj[2] = pos[atomIndex+2]; | 
| 99 | 
  | 
 | 
| 100 | 
< | 
      info->wrapVector(rj); | 
| 100 | 
> | 
    info->wrapVector(rj); | 
| 101 | 
  | 
 | 
| 102 | 
< | 
      pos[j] += dt * (vel[j] + eta*rj[0]); | 
| 103 | 
< | 
      pos[j+1] += dt * (vel[j+1] + eta*rj[1]); | 
| 104 | 
< | 
      pos[j+2] += dt * (vel[j+2] + eta*rj[2]); | 
| 83 | 
< | 
    } | 
| 102 | 
> | 
    scx = eta[0]*rj[0] + eta[1]*rj[1] + eta[2]*rj[2]; | 
| 103 | 
> | 
    scy = eta[3]*rj[0] + eta[4]*rj[1] + eta[5]*rj[2]; | 
| 104 | 
> | 
    scz = eta[6]*rj[0] + eta[7]*rj[1] + eta[8]*rj[2]; | 
| 105 | 
  | 
 | 
| 106 | 
< | 
    // Scale the box after all the positions have been moved: | 
| 107 | 
< | 
 | 
| 108 | 
< | 
    info->scaleBox(exp(dt*eta)); | 
| 106 | 
> | 
    pos[atomIndex] += dt * (vel[atomIndex] + scx); | 
| 107 | 
> | 
    pos[atomIndex+1] += dt * (vel[atomIndex+1] + scy); | 
| 108 | 
> | 
    pos[atomIndex+2] += dt * (vel[atomIndex+2] + scz); | 
| 109 | 
  | 
    | 
| 110 | 
  | 
    if( atoms[i]->isDirectional() ){ | 
| 111 | 
  | 
 | 
| 158 | 
  | 
    } | 
| 159 | 
  | 
     | 
| 160 | 
  | 
  } | 
| 161 | 
+ | 
 | 
| 162 | 
+ | 
  // Scale the box after all the positions have been moved: | 
| 163 | 
+ | 
   | 
| 164 | 
+ | 
 | 
| 165 | 
+ | 
 | 
| 166 | 
+ | 
  // Use a taylor expansion for eta products | 
| 167 | 
+ | 
    | 
| 168 | 
+ | 
  info->getBoxM(hm); | 
| 169 | 
+ | 
   | 
| 170 | 
+ | 
 | 
| 171 | 
+ | 
 | 
| 172 | 
+ | 
 | 
| 173 | 
+ | 
 | 
| 174 | 
+ | 
 | 
| 175 | 
+ | 
   info->scaleBox(exp(dt*eta)); | 
| 176 | 
+ | 
 | 
| 177 | 
+ | 
 | 
| 178 | 
  | 
} | 
| 179 | 
  | 
 | 
| 180 | 
  | 
void NPTi::moveB( void ){ |