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 1874 by gezelter, Wed May 15 15:09:35 2013 UTC

# Line 35 | Line 35
35   *                                                                      
36   * [1]  Meineke, et al., J. Comp. Chem. 26, 252-271 (2005).            
37   * [2]  Fennell & Gezelter, J. Chem. Phys. 124, 234104 (2006).          
38 < * [3]  Sun, Lin & Gezelter, J. Chem. Phys. 128, 24107 (2008).          
38 > * [3]  Sun, Lin & Gezelter, J. Chem. Phys. 128, 234107 (2008).          
39   * [4]  Kuang & Gezelter,  J. Chem. Phys. 133, 164101 (2010).
40   * [5]  Vardeman, Stocker & Gezelter, J. Chem. Theory Comput. 7, 834 (2011).
41   */
# 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 137 | Line 137 | namespace OpenMD {
137        (tauThermostat_ * tauThermostat_);
138  
139      integralOfChidt += chi * dt2_;
140 <    currentSnapshot_->setChiElectronic(chi);
141 <    currentSnapshot_->setIntegralOfChiElectronicDt(integralOfChidt);
142 <      
140 >    snap->setElectronicThermostat(make_pair(chi, integralOfChidt));
141    }
142  
143    void FluctuatingChargeNVT::updateSizes() {
# Line 153 | Line 151 | namespace OpenMD {
151      Molecule* mol;
152      Atom* atom;
153      RealType instTemp;
154 <    RealType chi = currentSnapshot_->getChiElectronic();
154 >    pair<RealType, RealType> thermostat = snap->getElectronicThermostat();
155 >    RealType chi = thermostat.first;
156      RealType oldChi = chi;
157      RealType prevChi;
158 <    RealType integralOfChidt = currentSnapshot_->getIntegralOfChiElectronicDt();
158 >    RealType integralOfChidt = thermostat.second;
159      int index;
160      RealType cfrc, cvel, cmass;
161  
# Line 187 | Line 186 | namespace OpenMD {
186               atom = mol->nextFluctuatingCharge(j)) {
187  
188            cfrc = atom->getFlucQFrc();
190          cvel =atom->getFlucQVel();
189            cmass = atom->getChargeMass();
190            
191            // velocity half step
# Line 200 | Line 198 | namespace OpenMD {
198          break;
199      }
200      integralOfChidt += dt2_ * chi;
201 <    currentSnapshot_->setChiElectronic(chi);
204 <    currentSnapshot_->setIntegralOfChiElectronicDt(integralOfChidt);
201 >    snap->setElectronicThermostat(make_pair(chi, integralOfChidt));
202    }
203    
204    void FluctuatingChargeNVT::resetPropagator() {
205      if (!hasFlucQ_) return;
206 <    currentSnapshot_->setChiElectronic(0.0);
210 <    currentSnapshot_->setIntegralOfChiElectronicDt(0.0);
206 >    snap->setElectronicThermostat(make_pair(0.0, 0.0));
207    }
208    
209    RealType FluctuatingChargeNVT::calcConservedQuantity() {
210      if (!hasFlucQ_) return 0.0;
211 <    RealType chi = currentSnapshot_->getChiElectronic();
212 <    RealType integralOfChidt = currentSnapshot_->getIntegralOfChiElectronicDt();
211 >    pair<RealType, RealType> thermostat = snap->getElectronicThermostat();
212 >    RealType chi = thermostat.first;
213 >    RealType integralOfChidt = thermostat.second;
214      RealType fkBT = info_->getNFluctuatingCharges() *
215        PhysicalConstants::kB *targetTemp_;
216  

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines