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

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

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines