| 71 | 
  | 
  RNEMD::RNEMD(SimInfo* info) : info_(info), evaluator_(info), seleMan_(info),  | 
| 72 | 
  | 
                                evaluatorA_(info), seleManA_(info),  | 
| 73 | 
  | 
                                commonA_(info), evaluatorB_(info),  | 
| 74 | 
< | 
                                seleManB_(info), commonB_(info), | 
| 74 | 
> | 
                                seleManB_(info), commonB_(info),  | 
| 75 | 
> | 
                                hasData_(false), hasDividingArea_(false), | 
| 76 | 
  | 
                                usePeriodicBoundaryConditions_(info->getSimParams()->getUsePeriodicBoundaryConditions()) { | 
| 77 | 
  | 
 | 
| 78 | 
  | 
    trialCount_ = 0; | 
| 604 | 
  | 
#ifdef IS_MPI | 
| 605 | 
  | 
    } | 
| 606 | 
  | 
#endif | 
| 607 | 
+ | 
 | 
| 608 | 
+ | 
    // delete all of the objects we created: | 
| 609 | 
+ | 
    delete areaAccumulator_;     | 
| 610 | 
+ | 
    data_.clear(); | 
| 611 | 
  | 
  } | 
| 612 | 
  | 
   | 
| 613 | 
  | 
  void RNEMD::doSwap(SelectionManager& smanA, SelectionManager& smanB) { | 
| 1151 | 
  | 
          //if w is in the right range, so should be x, y, z. | 
| 1152 | 
  | 
          vector<StuntDouble*>::iterator sdi; | 
| 1153 | 
  | 
          Vector3d vel; | 
| 1154 | 
< | 
          for (sdi = coldBin.begin(); sdi != coldBin.end(); sdi++) { | 
| 1154 | 
> | 
          for (sdi = coldBin.begin(); sdi != coldBin.end(); ++sdi) { | 
| 1155 | 
  | 
            if (rnemdFluxType_ == rnemdFullKE) { | 
| 1156 | 
  | 
              vel = (*sdi)->getVel() * c; | 
| 1157 | 
  | 
              (*sdi)->setVel(vel); | 
| 1162 | 
  | 
            } | 
| 1163 | 
  | 
          } | 
| 1164 | 
  | 
          w = sqrt(w); | 
| 1165 | 
< | 
          for (sdi = hotBin.begin(); sdi != hotBin.end(); sdi++) { | 
| 1165 | 
> | 
          for (sdi = hotBin.begin(); sdi != hotBin.end(); ++sdi) { | 
| 1166 | 
  | 
            if (rnemdFluxType_ == rnemdFullKE) { | 
| 1167 | 
  | 
              vel = (*sdi)->getVel(); | 
| 1168 | 
  | 
              vel.x() *= x; | 
| 1281 | 
  | 
      vector<RealType>::iterator ri; | 
| 1282 | 
  | 
      RealType r1, r2, alpha0; | 
| 1283 | 
  | 
      vector<pair<RealType,RealType> > rps; | 
| 1284 | 
< | 
      for (ri = realRoots.begin(); ri !=realRoots.end(); ri++) { | 
| 1284 | 
> | 
      for (ri = realRoots.begin(); ri !=realRoots.end(); ++ri) { | 
| 1285 | 
  | 
        r2 = *ri; | 
| 1286 | 
  | 
        //check if FindRealRoots() give the right answer | 
| 1287 | 
  | 
        if ( fabs(u0 + r2 * (u1 + r2 * (u2 + r2 * (u3 + r2 * u4)))) > 1e-6 ) { | 
| 1313 | 
  | 
        RealType diff; | 
| 1314 | 
  | 
        pair<RealType,RealType> bestPair = make_pair(1.0, 1.0); | 
| 1315 | 
  | 
        vector<pair<RealType,RealType> >::iterator rpi; | 
| 1316 | 
< | 
        for (rpi = rps.begin(); rpi != rps.end(); rpi++) { | 
| 1316 | 
> | 
        for (rpi = rps.begin(); rpi != rps.end(); ++rpi) { | 
| 1317 | 
  | 
          r1 = (*rpi).first; | 
| 1318 | 
  | 
          r2 = (*rpi).second; | 
| 1319 | 
  | 
          switch(rnemdFluxType_) { | 
| 1380 | 
  | 
        } | 
| 1381 | 
  | 
        vector<StuntDouble*>::iterator sdi; | 
| 1382 | 
  | 
        Vector3d vel; | 
| 1383 | 
< | 
        for (sdi = coldBin.begin(); sdi != coldBin.end(); sdi++) { | 
| 1383 | 
> | 
        for (sdi = coldBin.begin(); sdi != coldBin.end(); ++sdi) { | 
| 1384 | 
  | 
          vel = (*sdi)->getVel(); | 
| 1385 | 
  | 
          vel.x() *= x; | 
| 1386 | 
  | 
          vel.y() *= y; | 
| 1391 | 
  | 
        x = 1.0 + px * (1.0 - x); | 
| 1392 | 
  | 
        y = 1.0 + py * (1.0 - y); | 
| 1393 | 
  | 
        z = 1.0 + pz * (1.0 - z); | 
| 1394 | 
< | 
        for (sdi = hotBin.begin(); sdi != hotBin.end(); sdi++) { | 
| 1394 | 
> | 
        for (sdi = hotBin.begin(); sdi != hotBin.end(); ++sdi) { | 
| 1395 | 
  | 
          vel = (*sdi)->getVel(); | 
| 1396 | 
  | 
          vel.x() *= x; | 
| 1397 | 
  | 
          vel.y() *= y; | 
| 1597 | 
  | 
 | 
| 1598 | 
  | 
    Vector3d ac, acrec, bc, bcrec; | 
| 1599 | 
  | 
    Vector3d ah, ahrec, bh, bhrec; | 
| 1595 | 
– | 
    RealType cNumerator, cDenominator; | 
| 1596 | 
– | 
    RealType hNumerator, hDenominator; | 
| 1597 | 
– | 
 | 
| 1600 | 
  | 
 | 
| 1601 | 
  | 
    bool successfulExchange = false; | 
| 1602 | 
  | 
    if ((Mh > 0.0) && (Mc > 0.0)) {//both slabs are not empty | 
| 1611 | 
  | 
      bc  = -(Ici * angularMomentumTarget_) + omegac; | 
| 1612 | 
  | 
      bcrec = bc - omegac; | 
| 1613 | 
  | 
       | 
| 1614 | 
< | 
      cNumerator = Kc - kineticTarget_; | 
| 1614 | 
> | 
      RealType cNumerator = Kc - kineticTarget_; | 
| 1615 | 
  | 
      if (doLinearPart)  | 
| 1616 | 
  | 
        cNumerator -= 0.5 * Mc * ac.lengthSquare(); | 
| 1617 | 
  | 
       | 
| 1620 | 
  | 
 | 
| 1621 | 
  | 
      if (cNumerator > 0.0) { | 
| 1622 | 
  | 
         | 
| 1623 | 
< | 
        cDenominator = Kc; | 
| 1623 | 
> | 
        RealType cDenominator = Kc; | 
| 1624 | 
  | 
 | 
| 1625 | 
  | 
        if (doLinearPart) | 
| 1626 | 
  | 
          cDenominator -= 0.5 * Mc * vc.lengthSquare(); | 
| 1643 | 
  | 
            bh  = (Ihi * angularMomentumTarget_) + omegah; | 
| 1644 | 
  | 
            bhrec = bh - omegah; | 
| 1645 | 
  | 
             | 
| 1646 | 
< | 
            hNumerator = Kh + kineticTarget_; | 
| 1646 | 
> | 
            RealType hNumerator = Kh + kineticTarget_; | 
| 1647 | 
  | 
            if (doLinearPart)  | 
| 1648 | 
  | 
              hNumerator -= 0.5 * Mh * ah.lengthSquare(); | 
| 1649 | 
  | 
             | 
| 1652 | 
  | 
               | 
| 1653 | 
  | 
            if (hNumerator > 0.0) { | 
| 1654 | 
  | 
               | 
| 1655 | 
< | 
              hDenominator = Kh; | 
| 1655 | 
> | 
              RealType hDenominator = Kh; | 
| 1656 | 
  | 
              if (doLinearPart)  | 
| 1657 | 
  | 
                hDenominator -= 0.5 * Mh * vh.lengthSquare(); | 
| 1658 | 
  | 
              if (doAngularPart) | 
| 1666 | 
  | 
                  Vector3d vel; | 
| 1667 | 
  | 
                  Vector3d rPos; | 
| 1668 | 
  | 
                   | 
| 1669 | 
< | 
                  for (sdi = coldBin.begin(); sdi != coldBin.end(); sdi++) { | 
| 1669 | 
> | 
                  for (sdi = coldBin.begin(); sdi != coldBin.end(); ++sdi) { | 
| 1670 | 
  | 
                    //vel = (*sdi)->getVel(); | 
| 1671 | 
  | 
                    rPos = (*sdi)->getPos() - coordinateOrigin_; | 
| 1672 | 
  | 
                    if (doLinearPart) | 
| 1682 | 
  | 
                      } | 
| 1683 | 
  | 
                    } | 
| 1684 | 
  | 
                  } | 
| 1685 | 
< | 
                  for (sdi = hotBin.begin(); sdi != hotBin.end(); sdi++) { | 
| 1685 | 
> | 
                  for (sdi = hotBin.begin(); sdi != hotBin.end(); ++sdi) { | 
| 1686 | 
  | 
                    //vel = (*sdi)->getVel(); | 
| 1687 | 
  | 
                    rPos = (*sdi)->getPos() - coordinateOrigin_; | 
| 1688 | 
  | 
                    if (doLinearPart) | 
| 2010 | 
  | 
        } | 
| 2011 | 
  | 
      } | 
| 2012 | 
  | 
    } | 
| 2013 | 
+ | 
    hasData_ = true; | 
| 2014 | 
  | 
  } | 
| 2015 | 
  | 
 | 
| 2016 | 
  | 
  void RNEMD::getStarted() { | 
| 2043 | 
  | 
   | 
| 2044 | 
  | 
  void RNEMD::writeOutputFile() { | 
| 2045 | 
  | 
    if (!doRNEMD_) return; | 
| 2046 | 
+ | 
    if (!hasData_) return; | 
| 2047 | 
  | 
     | 
| 2048 | 
  | 
#ifdef IS_MPI | 
| 2049 | 
  | 
    // If we're the root node, should we print out the results | 
| 2065 | 
  | 
      RealType time = currentSnap_->getTime(); | 
| 2066 | 
  | 
      RealType avgArea; | 
| 2067 | 
  | 
      areaAccumulator_->getAverage(avgArea); | 
| 2068 | 
< | 
      RealType Jz = kineticExchange_ / (time * avgArea)  | 
| 2069 | 
< | 
        / PhysicalConstants::energyConvert; | 
| 2070 | 
< | 
      Vector3d JzP = momentumExchange_ / (time * avgArea);       | 
| 2071 | 
< | 
      Vector3d JzL = angularMomentumExchange_ / (time * avgArea);       | 
| 2068 | 
> | 
 | 
| 2069 | 
> | 
      RealType Jz(0.0); | 
| 2070 | 
> | 
      Vector3d JzP(V3Zero); | 
| 2071 | 
> | 
      Vector3d JzL(V3Zero); | 
| 2072 | 
> | 
      if (time >= info_->getSimParams()->getDt()) { | 
| 2073 | 
> | 
        Jz = kineticExchange_ / (time * avgArea) | 
| 2074 | 
> | 
          / PhysicalConstants::energyConvert; | 
| 2075 | 
> | 
        JzP = momentumExchange_ / (time * avgArea); | 
| 2076 | 
> | 
        JzL = angularMomentumExchange_ / (time * avgArea); | 
| 2077 | 
> | 
      } | 
| 2078 | 
  | 
 | 
| 2079 | 
  | 
      rnemdFile_ << "#######################################################\n"; | 
| 2080 | 
  | 
      rnemdFile_ << "# RNEMD {\n"; | 
| 2228 | 
  | 
      rnemdFile_ << "\t" << s; | 
| 2229 | 
  | 
    } else{ | 
| 2230 | 
  | 
      sprintf( painCave.errMsg, | 
| 2231 | 
< | 
               "RNEMD detected a numerical error writing: %s for bin %d", | 
| 2231 | 
> | 
               "RNEMD detected a numerical error writing: %s for bin %u", | 
| 2232 | 
  | 
               data_[index].title.c_str(), bin); | 
| 2233 | 
  | 
      painCave.isFatal = 1; | 
| 2234 | 
  | 
      simError(); | 
| 2251 | 
  | 
        isinf(s[1]) || isnan(s[1]) ||  | 
| 2252 | 
  | 
        isinf(s[2]) || isnan(s[2]) ) {       | 
| 2253 | 
  | 
      sprintf( painCave.errMsg, | 
| 2254 | 
< | 
               "RNEMD detected a numerical error writing: %s for bin %d", | 
| 2254 | 
> | 
               "RNEMD detected a numerical error writing: %s for bin %u", | 
| 2255 | 
  | 
               data_[index].title.c_str(), bin); | 
| 2256 | 
  | 
      painCave.isFatal = 1; | 
| 2257 | 
  | 
      simError(); | 
| 2276 | 
  | 
      rnemdFile_ << "\t" << s; | 
| 2277 | 
  | 
    } else{ | 
| 2278 | 
  | 
      sprintf( painCave.errMsg, | 
| 2279 | 
< | 
               "RNEMD detected a numerical error writing: %s std. dev. for bin %d", | 
| 2279 | 
> | 
               "RNEMD detected a numerical error writing: %s std. dev. for bin %u", | 
| 2280 | 
  | 
               data_[index].title.c_str(), bin); | 
| 2281 | 
  | 
      painCave.isFatal = 1; | 
| 2282 | 
  | 
      simError(); | 
| 2298 | 
  | 
        isinf(s[1]) || isnan(s[1]) ||  | 
| 2299 | 
  | 
        isinf(s[2]) || isnan(s[2]) ) {       | 
| 2300 | 
  | 
      sprintf( painCave.errMsg, | 
| 2301 | 
< | 
               "RNEMD detected a numerical error writing: %s std. dev. for bin %d", | 
| 2301 | 
> | 
               "RNEMD detected a numerical error writing: %s std. dev. for bin %u", | 
| 2302 | 
  | 
               data_[index].title.c_str(), bin); | 
| 2303 | 
  | 
      painCave.isFatal = 1; | 
| 2304 | 
  | 
      simError(); |