ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/OpenMD/trunk/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.
trunk/src/flucq/FluctuatingChargeNVT.cpp (file contents), Revision 2071 by gezelter, Sat Mar 7 21:41:51 2015 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 49 | Line 49 | namespace OpenMD {
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()) {    
52 >    FluctuatingChargePropagator(info), maxIterNum_(4), chiTolerance_ (1e-6),
53 >    snap(info->getSnapshotManager()->getCurrentSnapshot()), thermo(info) {  
54    }
55  
56    void FluctuatingChargeNVT::initialize() {
# Line 68 | Line 67 | namespace OpenMD {
67        }
68        
69        if (!info_->getSimParams()->getUseIntialExtendedSystemState()) {
70 <        currentSnapshot_->setChiElectronic(0.0);
72 <        currentSnapshot_->setIntegralOfChiElectronicDt(0.0);
70 >        snap->setElectronicThermostat(make_pair(0.0, 0.0));
71        }
72        
73        if (!fqParams_->haveTargetTemp()) {
# Line 109 | Line 107 | namespace OpenMD {
107      Atom* atom;
108      RealType cvel, cpos, cfrc, cmass;
109  
110 <    RealType chi = currentSnapshot_->getChiElectronic();
111 <    RealType integralOfChidt = currentSnapshot_->getIntegralOfChiElectronicDt();
110 >    pair<RealType, RealType> thermostat = snap->getElectronicThermostat();
111 >    RealType chi = thermostat.first;
112 >    RealType integralOfChidt = thermostat.second;
113      RealType instTemp = thermo.getElectronicTemperature();
114  
115      for (mol = info_->beginMolecule(i); mol != NULL;
# Line 137 | Line 136 | namespace OpenMD {
136        (tauThermostat_ * tauThermostat_);
137  
138      integralOfChidt += chi * dt2_;
139 <    currentSnapshot_->setChiElectronic(chi);
141 <    currentSnapshot_->setIntegralOfChiElectronicDt(integralOfChidt);
142 <      
139 >    snap->setElectronicThermostat(make_pair(chi, integralOfChidt));
140    }
141  
142    void FluctuatingChargeNVT::updateSizes() {
# Line 153 | Line 150 | namespace OpenMD {
150      Molecule* mol;
151      Atom* atom;
152      RealType instTemp;
153 <    RealType chi = currentSnapshot_->getChiElectronic();
153 >    pair<RealType, RealType> thermostat = snap->getElectronicThermostat();
154 >    RealType chi = thermostat.first;
155      RealType oldChi = chi;
156      RealType prevChi;
157 <    RealType integralOfChidt = currentSnapshot_->getIntegralOfChiElectronicDt();
157 >    RealType integralOfChidt = thermostat.second;
158      int index;
159      RealType cfrc, cvel, cmass;
160  
# Line 187 | Line 185 | namespace OpenMD {
185               atom = mol->nextFluctuatingCharge(j)) {
186  
187            cfrc = atom->getFlucQFrc();
190          cvel =atom->getFlucQVel();
188            cmass = atom->getChargeMass();
189            
190            // velocity half step
# Line 200 | Line 197 | namespace OpenMD {
197          break;
198      }
199      integralOfChidt += dt2_ * chi;
200 <    currentSnapshot_->setChiElectronic(chi);
204 <    currentSnapshot_->setIntegralOfChiElectronicDt(integralOfChidt);
200 >    snap->setElectronicThermostat(make_pair(chi, integralOfChidt));
201    }
202    
203    void FluctuatingChargeNVT::resetPropagator() {
204      if (!hasFlucQ_) return;
205 <    currentSnapshot_->setChiElectronic(0.0);
210 <    currentSnapshot_->setIntegralOfChiElectronicDt(0.0);
205 >    snap->setElectronicThermostat(make_pair(0.0, 0.0));
206    }
207    
208    RealType FluctuatingChargeNVT::calcConservedQuantity() {
209      if (!hasFlucQ_) return 0.0;
210 <    RealType chi = currentSnapshot_->getChiElectronic();
211 <    RealType integralOfChidt = currentSnapshot_->getIntegralOfChiElectronicDt();
210 >    pair<RealType, RealType> thermostat = snap->getElectronicThermostat();
211 >    RealType chi = thermostat.first;
212 >    RealType integralOfChidt = thermostat.second;
213      RealType fkBT = info_->getNFluctuatingCharges() *
214        PhysicalConstants::kB *targetTemp_;
215  

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines