ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/OpenMD/branches/development/src/flucq/FluctuatingChargeNVT.cpp
(Generate patch)

Comparing branches/development/src/flucq/FluctuatingChargeNVT.cpp (file contents):
Revision 1760 by gezelter, Thu Jun 21 19:26:46 2012 UTC vs.
Revision 1761 by gezelter, Fri Jun 22 20:01:37 2012 UTC

# Line 45 | Line 45
45   #include "utils/simError.h"
46   #include "utils/PhysicalConstants.hpp"
47  
48 +
49   namespace OpenMD {
50  
51    FluctuatingChargeNVT::FluctuatingChargeNVT(SimInfo* info) :
52      FluctuatingChargePropagator(info), chiTolerance_ (1e-6),
53 <    maxIterNum_(4), thermo(info),
54 <    currentSnapshot_(info->getSnapshotManager()->getCurrentSnapshot()) {
55 <    
56 <    if (hasFlucQ_) {    
53 >    maxIterNum_(4), thermo(info),
54 >    currentSnapshot_(info->getSnapshotManager()->getCurrentSnapshot()) {    
55 >  }
56 >
57 >  void FluctuatingChargeNVT::initialize() {
58 >    FluctuatingChargePropagator::initialize();  
59 >    if (hasFlucQ_) {
60        if (info_->getSimParams()->haveDt()) {
61          dt_ = info_->getSimParams()->getDt();
62          dt2_ = dt_ * 0.5;
# Line 90 | Line 94 | namespace OpenMD {
94        } else {
95          tauThermostat_ = fqParams_->getTauThermostat();
96        }
97 <      updateSizes();
97 >      updateSizes();
98      }
99    }
100  
97  void FluctuatingChargeNVT::initialize() {
98    FluctuatingChargePropagator::initialize();
99  }
101  
101
102    void FluctuatingChargeNVT::moveA() {
103  
104      if (!hasFlucQ_) return;
# Line 113 | Line 113 | namespace OpenMD {
113      RealType integralOfChidt = currentSnapshot_->getIntegralOfChiElectronicDt();
114      RealType instTemp = thermo.getElectronicTemperature();
115  
116
116      for (mol = info_->beginMolecule(i); mol != NULL;
117           mol = info_->nextMolecule(i)) {
118        for (atom = mol->beginFluctuatingCharge(j); atom != NULL;
# Line 122 | Line 121 | namespace OpenMD {
121          cvel = atom->getFlucQVel();
122          cpos = atom->getFlucQPos();
123          cfrc = atom->getFlucQFrc();
124 <        cmass = atom->getChargeMass();
125 <        
127 <        cerr << atom->getType() << "\n";
128 <        cerr << "Before\n";
129 <        cerr << "cvel: " << cvel << "\tcpos: " << cpos << "\tcfrc: " << cfrc << "\tcmass: " << cmass << "\n";
130 <        
124 >        cmass = atom->getChargeMass();      
125 >
126          // velocity half step
127          cvel += dt2_ * cfrc / cmass - dt2_*chi*cvel;                    
128          // position whole step
129          cpos += dt_ * cvel;
130          
136        cerr << "After\n";
137        cerr << "cvel: " << cvel << "\tcpos: " << cpos << "\n\n";        
138
131          atom->setFlucQVel(cvel);
132          atom->setFlucQPos(cpos);
133        }
# Line 145 | Line 137 | namespace OpenMD {
137        (tauThermostat_ * tauThermostat_);
138  
139      integralOfChidt += chi * dt2_;
148    cerr << "Move A instTemp: " << instTemp << "\n";
140      currentSnapshot_->setChiElectronic(chi);
141      currentSnapshot_->setIntegralOfChiElectronicDt(integralOfChidt);
142        
143    }
144  
145    void FluctuatingChargeNVT::updateSizes() {
155    if (!hasFlucQ_) return;
146      oldVel_.resize(info_->getNFluctuatingCharges());
147    }
148  
# Line 186 | Line 176 | namespace OpenMD {
176      for(int k = 0; k < maxIterNum_; k++) {
177        index = 0;
178        instTemp = thermo.getElectronicTemperature();
189      cerr << "MoveB instTemp: " << instTemp << "\n";
179        // evolve chi another half step using the temperature at t + dt/2
180        prevChi = chi;
181        chi = oldChi + dt2_ * (instTemp / targetTemp_ - 1.0) /
# Line 203 | Line 192 | namespace OpenMD {
192            
193            // velocity half step
194            cvel = oldVel_[index] + dt2_ * cfrc / cmass - dt2_*chi*oldVel_[index];
206          
195            atom->setFlucQVel(cvel);      
196            ++index;          
197          }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines