ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/OpenMD/trunk/src/rnemd/RNEMD.cpp
(Generate patch)

Comparing:
branches/development/src/rnemd/RNEMD.cpp (file contents), Revision 1776 by gezelter, Thu Aug 9 15:52:59 2012 UTC vs.
trunk/src/rnemd/RNEMD.cpp (file contents), Revision 1789 by gezelter, Wed Aug 29 20:52:19 2012 UTC

# Line 53 | Line 53
53   #include <mpi.h>
54   #endif
55  
56 + #ifdef _MSC_VER
57 + #define isnan(x) _isnan((x))
58 + #define isinf(x) (!_finite(x) && !_isnan(x))
59 + #endif
60 +
61   #define HONKING_LARGE_VALUE 1.0e10
62  
63   using namespace std;
# Line 65 | Line 70 | namespace OpenMD {
70      failTrialCount_ = 0;
71      failRootCount_ = 0;
72  
68    int seedValue;
73      Globals * simParams = info->getSimParams();
74      RNEMDParameters* rnemdParams = simParams->getRNEMDParameters();
75  
# Line 80 | Line 84 | namespace OpenMD {
84      stringToFluxType_["Px"]  = rnemdPx;
85      stringToFluxType_["Py"]  = rnemdPy;
86      stringToFluxType_["Pz"]  = rnemdPz;
87 +    stringToFluxType_["Pvector"]  = rnemdPvector;
88      stringToFluxType_["KE+Px"]  = rnemdKePx;
89      stringToFluxType_["KE+Py"]  = rnemdKePy;
90      stringToFluxType_["KE+Pvector"]  = rnemdKePvector;
# Line 101 | Line 106 | namespace OpenMD {
106        sprintf(painCave.errMsg,
107                "RNEMD: No fluxType was set in the md file.  This parameter,\n"
108                "\twhich must be one of the following values:\n"
109 <              "\tKE, Px, Py, Pz, KE+Px, KE+Py, KE+Pvector, must be set to\n"
110 <              "\tuse RNEMD\n");
109 >              "\tKE, Px, Py, Pz, Pvector, KE+Px, KE+Py, KE+Pvector\n"
110 >              "\tmust be set to use RNEMD\n");
111        painCave.isFatal = 1;
112        painCave.severity = OPENMD_ERROR;
113        simError();
# Line 200 | Line 205 | namespace OpenMD {
205          break;
206        case rnemdPvector:
207          hasCorrectFlux = hasMomentumFluxVector;
208 +        break;
209        case rnemdKePx:
210        case rnemdKePy:
211          hasCorrectFlux = hasMomentumFlux && hasKineticFlux;
# Line 227 | Line 233 | namespace OpenMD {
233      }
234      if (!hasCorrectFlux) {
235        sprintf(painCave.errMsg,
236 <              "RNEMD: The current method,\n"
231 <              "\t%s, and flux type %s\n"
236 >              "RNEMD: The current method, %s, and flux type, %s,\n"
237                "\tdid not have the correct flux value specified. Options\n"
238                "\tinclude: kineticFlux, momentumFlux, and momentumFluxVector\n",
239                methStr.c_str(), fluxStr.c_str());
# Line 238 | Line 243 | namespace OpenMD {
243      }
244  
245      if (hasKineticFlux) {
246 <      kineticFlux_ = rnemdParams->getKineticFlux();
246 >      // convert the kcal / mol / Angstroms^2 / fs values in the md file
247 >      // into  amu / fs^3:
248 >      kineticFlux_ = rnemdParams->getKineticFlux()
249 >        * PhysicalConstants::energyConvert;
250      } else {
251        kineticFlux_ = 0.0;
252      }
# Line 301 | Line 309 | namespace OpenMD {
309      z.title =  "Z";
310      z.dataType = "RealType";
311      z.accumulator.reserve(nBins_);
312 <    for (unsigned int i = 0; i < nBins_; i++)
312 >    for (int i = 0; i < nBins_; i++)
313        z.accumulator.push_back( new Accumulator() );
314      data_[Z] = z;
315      outputMap_["Z"] =  Z;
# Line 311 | Line 319 | namespace OpenMD {
319      temperature.title =  "Temperature";
320      temperature.dataType = "RealType";
321      temperature.accumulator.reserve(nBins_);
322 <    for (unsigned int i = 0; i < nBins_; i++)
322 >    for (int i = 0; i < nBins_; i++)
323        temperature.accumulator.push_back( new Accumulator() );
324      data_[TEMPERATURE] = temperature;
325      outputMap_["TEMPERATURE"] =  TEMPERATURE;
326  
327      OutputData velocity;
328 <    velocity.units = "amu/fs";
328 >    velocity.units = "angstroms/fs";
329      velocity.title =  "Velocity";  
330      velocity.dataType = "Vector3d";
331      velocity.accumulator.reserve(nBins_);
332 <    for (unsigned int i = 0; i < nBins_; i++)
332 >    for (int i = 0; i < nBins_; i++)
333        velocity.accumulator.push_back( new VectorAccumulator() );
334      data_[VELOCITY] = velocity;
335      outputMap_["VELOCITY"] = VELOCITY;
# Line 331 | Line 339 | namespace OpenMD {
339      density.title =  "Density";
340      density.dataType = "RealType";
341      density.accumulator.reserve(nBins_);
342 <    for (unsigned int i = 0; i < nBins_; i++)
342 >    for (int i = 0; i < nBins_; i++)
343        density.accumulator.push_back( new Accumulator() );
344      data_[DENSITY] = density;
345      outputMap_["DENSITY"] =  DENSITY;
# Line 494 | Line 502 | namespace OpenMD {
502                  + angMom[2]*angMom[2]/I(2, 2);
503              }
504            } //angular momenta exchange enabled
497          //energyConvert temporarily disabled
498          //make kineticExchange_ comparable between swap & scale
499          //value = value * 0.5 / PhysicalConstants::energyConvert;
505            value *= 0.5;
506            break;
507          case rnemdPx :
# Line 734 | Line 739 | namespace OpenMD {
739          
740          switch(rnemdFluxType_) {
741          case rnemdKE:
737          cerr << "KE\n";
742            kineticExchange_ += max_val - min_val;
743            break;
744          case rnemdPx:
# Line 747 | Line 751 | namespace OpenMD {
751            momentumExchange_.z() += max_val - min_val;
752            break;
753          default:
750          cerr << "default\n";
754            break;
755          }
756        } else {        
# Line 1527 | Line 1530 | namespace OpenMD {
1530        vel.x() = binPx[i] / binMass[i];
1531        vel.y() = binPy[i] / binMass[i];
1532        vel.z() = binPz[i] / binMass[i];
1533 <      den = binCount[i] * nBins_ / currentSnap_->getVolume();
1533 >
1534 >      den = binMass[i] * nBins_ * PhysicalConstants::densityConvert
1535 >        / currentSnap_->getVolume() ;
1536 >
1537        temp = 2.0 * binKE[i] / (binDOF[i] * PhysicalConstants::kb *
1538                                 PhysicalConstants::energyConvert);
1539  
# Line 1602 | Line 1608 | namespace OpenMD {
1608        RealType time = currentSnap_->getTime();
1609        RealType avgArea;
1610        areaAccumulator_->getAverage(avgArea);
1611 <      RealType Jz = kineticExchange_ / (2.0 * time * avgArea);
1611 >      RealType Jz = kineticExchange_ / (2.0 * time * avgArea)
1612 >        / PhysicalConstants::energyConvert;
1613        Vector3d JzP = momentumExchange_ / (2.0 * time * avgArea);      
1614  
1615        rnemdFile_ << "#######################################################\n";
# Line 1631 | Line 1638 | namespace OpenMD {
1638        rnemdFile_ << "# RNEMD report:\n";      
1639        rnemdFile_ << "#     running time = " << time << " fs\n";
1640        rnemdFile_ << "#     target flux:\n";
1641 <      rnemdFile_ << "#         kinetic = " << kineticFlux_ << "\n";
1642 <      rnemdFile_ << "#         momentum = " << momentumFluxVector_ << "\n";
1641 >      rnemdFile_ << "#         kinetic = "
1642 >                 << kineticFlux_ / PhysicalConstants::energyConvert
1643 >                 << " (kcal/mol/A^2/fs)\n";
1644 >      rnemdFile_ << "#         momentum = " << momentumFluxVector_
1645 >                 << " (amu/A/fs^2)\n";
1646        rnemdFile_ << "#     target one-time exchanges:\n";
1647 <      rnemdFile_ << "#         kinetic = " << kineticTarget_ << "\n";
1648 <      rnemdFile_ << "#         momentum = " << momentumTarget_ << "\n";
1647 >      rnemdFile_ << "#         kinetic = "
1648 >                 << kineticTarget_ / PhysicalConstants::energyConvert
1649 >                 << " (kcal/mol)\n";
1650 >      rnemdFile_ << "#         momentum = " << momentumTarget_
1651 >                 << " (amu*A/fs)\n";
1652        rnemdFile_ << "#     actual exchange totals:\n";
1653 <      rnemdFile_ << "#         kinetic = " << kineticExchange_ << "\n";
1654 <      rnemdFile_ << "#         momentum = " << momentumExchange_  << "\n";
1653 >      rnemdFile_ << "#         kinetic = "
1654 >                 << kineticExchange_ / PhysicalConstants::energyConvert
1655 >                 << " (kcal/mol)\n";
1656 >      rnemdFile_ << "#         momentum = " << momentumExchange_
1657 >                 << " (amu*A/fs)\n";      
1658        rnemdFile_ << "#     actual flux:\n";
1659 <      rnemdFile_ << "#         kinetic = " << Jz << "\n";
1660 <      rnemdFile_ << "#         momentum = " << JzP  << "\n";
1659 >      rnemdFile_ << "#         kinetic = " << Jz
1660 >                 << " (kcal/mol/A^2/fs)\n";
1661 >      rnemdFile_ << "#         momentum = " << JzP
1662 >                 << " (amu/A/fs^2)\n";
1663        rnemdFile_ << "#     exchange statistics:\n";
1664        rnemdFile_ << "#         attempted = " << trialCount_ << "\n";
1665        rnemdFile_ << "#         failed = " << failTrialCount_ << "\n";    
# Line 1659 | Line 1677 | namespace OpenMD {
1677          if (outputMask_[i]) {
1678            rnemdFile_ << "\t" << data_[i].title <<
1679              "(" << data_[i].units << ")";
1680 +          // add some extra tabs for column alignment
1681 +          if (data_[i].dataType == "Vector3d") rnemdFile_ << "\t\t";
1682          }
1683        }
1684        rnemdFile_ << std::endl;
1685        
1686        rnemdFile_.precision(8);
1687        
1688 <      for (unsigned int j = 0; j < nBins_; j++) {        
1688 >      for (int j = 0; j < nBins_; j++) {        
1689          
1690          for (unsigned int i = 0; i < outputMask_.size(); ++i) {
1691            if (outputMask_[i]) {
# Line 1691 | Line 1711 | namespace OpenMD {
1711        rnemdFile_ << "#######################################################\n";
1712  
1713  
1714 <      for (unsigned int j = 0; j < nBins_; j++) {        
1714 >      for (int j = 0; j < nBins_; j++) {        
1715          rnemdFile_ << "#";
1716          for (unsigned int i = 0; i < outputMask_.size(); ++i) {
1717            if (outputMask_[i]) {

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines