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 1761 by gezelter, Fri Jun 22 20:01:37 2012 UTC vs.
Revision 1766 by gezelter, Thu Jul 5 17:08:25 2012 UTC

# Line 51 | Line 51 | namespace OpenMD {
51    FluctuatingChargeNVT::FluctuatingChargeNVT(SimInfo* info) :
52      FluctuatingChargePropagator(info), chiTolerance_ (1e-6),
53      maxIterNum_(4), thermo(info),
54 <    currentSnapshot_(info->getSnapshotManager()->getCurrentSnapshot()) {    
54 >    snap(info->getSnapshotManager()->getCurrentSnapshot()) {    
55    }
56  
57    void FluctuatingChargeNVT::initialize() {
# Line 68 | Line 68 | namespace OpenMD {
68        }
69        
70        if (!info_->getSimParams()->getUseIntialExtendedSystemState()) {
71 <        currentSnapshot_->setChiElectronic(0.0);
72 <        currentSnapshot_->setIntegralOfChiElectronicDt(0.0);
71 >        snap->setElectronicThermostat(make_pair(0.0, 0.0));
72        }
73        
74        if (!fqParams_->haveTargetTemp()) {
# Line 109 | Line 108 | namespace OpenMD {
108      Atom* atom;
109      RealType cvel, cpos, cfrc, cmass;
110  
111 <    RealType chi = currentSnapshot_->getChiElectronic();
112 <    RealType integralOfChidt = currentSnapshot_->getIntegralOfChiElectronicDt();
111 >    pair<RealType, RealType> thermostat = snap->getElectronicThermostat();
112 >    RealType chi = thermostat.first;
113 >    RealType integralOfChidt = thermostat.second;
114      RealType instTemp = thermo.getElectronicTemperature();
115  
116      for (mol = info_->beginMolecule(i); mol != NULL;
# Line 123 | Line 123 | namespace OpenMD {
123          cfrc = atom->getFlucQFrc();
124          cmass = atom->getChargeMass();      
125  
126 +        cerr << cpos << "\t" << cvel << "\t" << cfrc << "\t" << instTemp << "\t" <<chi << "\t" << integralOfChidt << "\n";
127          // velocity half step
128          cvel += dt2_ * cfrc / cmass - dt2_*chi*cvel;                    
129          // position whole step
# Line 137 | Line 138 | namespace OpenMD {
138        (tauThermostat_ * tauThermostat_);
139  
140      integralOfChidt += chi * dt2_;
141 <    currentSnapshot_->setChiElectronic(chi);
141 <    currentSnapshot_->setIntegralOfChiElectronicDt(integralOfChidt);
142 <      
141 >    snap->setElectronicThermostat(make_pair(chi, integralOfChidt));
142    }
143  
144    void FluctuatingChargeNVT::updateSizes() {
# Line 153 | Line 152 | namespace OpenMD {
152      Molecule* mol;
153      Atom* atom;
154      RealType instTemp;
155 <    RealType chi = currentSnapshot_->getChiElectronic();
155 >    pair<RealType, RealType> thermostat = snap->getElectronicThermostat();
156 >    RealType chi = thermostat.first;
157      RealType oldChi = chi;
158      RealType prevChi;
159 <    RealType integralOfChidt = currentSnapshot_->getIntegralOfChiElectronicDt();
159 >    RealType integralOfChidt = thermostat.second;
160      int index;
161      RealType cfrc, cvel, cmass;
162  
# Line 200 | Line 200 | namespace OpenMD {
200          break;
201      }
202      integralOfChidt += dt2_ * chi;
203 <    currentSnapshot_->setChiElectronic(chi);
204 <    currentSnapshot_->setIntegralOfChiElectronicDt(integralOfChidt);
203 >    snap->setElectronicThermostat(make_pair(chi, integralOfChidt));
204    }
205    
206    void FluctuatingChargeNVT::resetPropagator() {
207      if (!hasFlucQ_) return;
208 <    currentSnapshot_->setChiElectronic(0.0);
210 <    currentSnapshot_->setIntegralOfChiElectronicDt(0.0);
208 >    snap->setElectronicThermostat(make_pair(0.0, 0.0));
209    }
210    
211    RealType FluctuatingChargeNVT::calcConservedQuantity() {
212      if (!hasFlucQ_) return 0.0;
213 <    RealType chi = currentSnapshot_->getChiElectronic();
214 <    RealType integralOfChidt = currentSnapshot_->getIntegralOfChiElectronicDt();
213 >    pair<RealType, RealType> thermostat = snap->getElectronicThermostat();
214 >    RealType chi = thermostat.first;
215 >    RealType integralOfChidt = thermostat.second;
216      RealType fkBT = info_->getNFluctuatingCharges() *
217        PhysicalConstants::kB *targetTemp_;
218  

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines