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

Comparing branches/development/src/perturbations/ElectricField.cpp (file contents):
Revision 1780 by jmarr, Mon Aug 20 18:28:22 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 78 | Line 78 | namespace OpenMD {
78      Vector3d EFfrc;                            
79      Vector3d pos;
80      RealType chrg;
81 <    RealType pot, fieldPot, moment;
81 >    RealType pot, fieldPot;
82      RealType chrgToKcal = 23.0609;
83      RealType debyeToKcal = 4.8018969509;
84    bool isCharge;
84  
85 +
86      if (doElectricField) {
87        fieldPot = 0.0;
88  
89 <      for (mol = info_->beginMolecule(i); mol != NULL; mol = info_->nextMolecule(i)) {      
89 >      for (mol = info_->beginMolecule(i); mol != NULL;
90 >           mol = info_->nextMolecule(i)) {      
91 >
92          for (atom = mol->beginAtom(j); atom != NULL;
93               atom = mol->nextAtom(j)) {
92          isCharge = false;
93          chrg = 0.0;
94  
95 <          FixedChargeAdapter fca = FixedChargeAdapter(atom->getAtomType());
95 >          bool isCharge = false;
96 >          chrg = 0.0;
97 >          
98 >          AtomType* atype = atom->getAtomType();
99 >          
100 >          if (atype->isElectrostatic()) {
101 >            atom->addElectricField(EF * chrgToKcal);
102 >          }
103 >          
104 >          FixedChargeAdapter fca = FixedChargeAdapter(atype);
105            if ( fca.isFixedCharge() ) {
106              isCharge = true;
107              chrg = fca.getCharge();
108            }
109            
110 <          FluctuatingChargeAdapter fqa = FluctuatingChargeAdapter(atom->getAtomType());
110 >          FluctuatingChargeAdapter fqa = FluctuatingChargeAdapter(atype);
111            if ( fqa.isFluctuatingCharge() ) {
112              isCharge = true;
113              chrg += atom->getFlucQPos();
# Line 108 | Line 117 | namespace OpenMD {
117              EFfrc = EF*chrg;
118              EFfrc *= chrgToKcal;
119              atom->addFrc(EFfrc);
120 <            // totally ad-hoc choice of the origin for potential calculation
120 >            // ad-hoc choice of the origin for potential calculation
121              pos = atom->getPos();
122              pot = -dot(pos, EFfrc);
123              if (doParticlePot) {      
# Line 117 | Line 126 | namespace OpenMD {
126              fieldPot += pot;
127            }
128              
129 <          MultipoleAdapter ma = MultipoleAdapter(atom->getAtomType());
129 >          MultipoleAdapter ma = MultipoleAdapter(atype);
130            if (ma.isDipole() ) {
131 <            Vector3d u_i = atom->getElectroFrame().getColumn(2);
132 <            moment = ma.getDipoleMoment();
133 <            moment *= debyeToKcal;
134 <            dip = u_i * moment;
126 <            trq = cross(dip, EF);
127 <            //cerr << "dip = " << dip << "\n";
128 <            // cerr << "trq = " << trq << "\n";
131 >            Vector3d dipole = atom->getDipole();
132 >            dipole *= debyeToKcal;
133 >
134 >            trq = cross(dipole, EF);
135              atom->addTrq(trq);
136 <            pot = -dot(dip, EF);
137 <            //cerr << "pot = " << pot << "\n";
136 >
137 >            pot = -dot(dipole, EF);
138              if (doParticlePot) {      
139                atom->addParticlePot(pot);
140              }
# Line 142 | Line 148 | namespace OpenMD {
148   #endif
149        Snapshot* snap = info_->getSnapshotManager()->getCurrentSnapshot();
150        longRangePotential = snap->getLongRangePotentials();
145      // << "longRangePotential = " << longRangePotential << "\n";
151        longRangePotential[ELECTROSTATIC_FAMILY] += fieldPot;
147      //cerr << "longRangePotential[ELECTROSTATIC_FAMILY] = " << longRangePotential[ELECTROSTATIC_FAMILY] << "\n";
152        snap->setLongRangePotential(longRangePotential);
153      }
154    }
151
155   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines