72 |
|
Molecule::AtomIterator j; |
73 |
|
Molecule* mol; |
74 |
|
Atom* atom; |
75 |
+ |
AtomType* atype; |
76 |
|
potVec longRangePotential(0.0); |
77 |
|
Vector3d dip; |
78 |
|
Vector3d trq; |
79 |
|
Vector3d EFfrc; |
80 |
|
Vector3d pos; |
81 |
|
RealType chrg; |
82 |
< |
RealType pot, fieldPot, moment; |
82 |
> |
RealType pot, fieldPot; |
83 |
|
RealType chrgToKcal = 23.0609; |
84 |
|
RealType debyeToKcal = 4.8018969509; |
85 |
|
bool isCharge; |
87 |
|
if (doElectricField) { |
88 |
|
fieldPot = 0.0; |
89 |
|
|
90 |
< |
for (mol = info_->beginMolecule(i); mol != NULL; mol = info_->nextMolecule(i)) { |
90 |
> |
for (mol = info_->beginMolecule(i); mol != NULL; |
91 |
> |
mol = info_->nextMolecule(i)) { |
92 |
> |
|
93 |
|
for (atom = mol->beginAtom(j); atom != NULL; |
94 |
|
atom = mol->nextAtom(j)) { |
95 |
+ |
|
96 |
|
isCharge = false; |
97 |
|
chrg = 0.0; |
98 |
< |
|
99 |
< |
FixedChargeAdapter fca = FixedChargeAdapter(atom->getAtomType()); |
98 |
> |
|
99 |
> |
atype = atom->getAtomType(); |
100 |
> |
|
101 |
> |
if (atype->isElectrostatic()) { |
102 |
> |
atom->addElectricField(EF * chrgToKcal); |
103 |
> |
} |
104 |
> |
|
105 |
> |
FixedChargeAdapter fca = FixedChargeAdapter(atype); |
106 |
|
if ( fca.isFixedCharge() ) { |
107 |
|
isCharge = true; |
108 |
|
chrg = fca.getCharge(); |
109 |
|
} |
110 |
|
|
111 |
< |
FluctuatingChargeAdapter fqa = FluctuatingChargeAdapter(atom->getAtomType()); |
111 |
> |
FluctuatingChargeAdapter fqa = FluctuatingChargeAdapter(atype); |
112 |
|
if ( fqa.isFluctuatingCharge() ) { |
113 |
|
isCharge = true; |
114 |
|
chrg += atom->getFlucQPos(); |
118 |
|
EFfrc = EF*chrg; |
119 |
|
EFfrc *= chrgToKcal; |
120 |
|
atom->addFrc(EFfrc); |
121 |
< |
// totally ad-hoc choice of the origin for potential calculation |
121 |
> |
// ad-hoc choice of the origin for potential calculation |
122 |
|
pos = atom->getPos(); |
123 |
|
pot = -dot(pos, EFfrc); |
124 |
|
if (doParticlePot) { |
127 |
|
fieldPot += pot; |
128 |
|
} |
129 |
|
|
130 |
< |
MultipoleAdapter ma = MultipoleAdapter(atom->getAtomType()); |
130 |
> |
MultipoleAdapter ma = MultipoleAdapter(atype); |
131 |
|
if (ma.isDipole() ) { |
132 |
< |
Vector3d u_i = atom->getElectroFrame().getColumn(2); |
133 |
< |
moment = ma.getDipoleMoment(); |
134 |
< |
moment *= debyeToKcal; |
135 |
< |
dip = u_i * moment; |
126 |
< |
trq = cross(dip, EF); |
127 |
< |
//cerr << "dip = " << dip << "\n"; |
128 |
< |
// cerr << "trq = " << trq << "\n"; |
132 |
> |
Vector3d dipole = atom->getDipole(); |
133 |
> |
dipole *= debyeToKcal; |
134 |
> |
|
135 |
> |
trq = cross(dipole, EF); |
136 |
|
atom->addTrq(trq); |
137 |
< |
pot = -dot(dip, EF); |
138 |
< |
//cerr << "pot = " << pot << "\n"; |
137 |
> |
|
138 |
> |
pot = -dot(dipole, EF); |
139 |
|
if (doParticlePot) { |
140 |
|
atom->addParticlePot(pot); |
141 |
|
} |
149 |
|
#endif |
150 |
|
Snapshot* snap = info_->getSnapshotManager()->getCurrentSnapshot(); |
151 |
|
longRangePotential = snap->getLongRangePotentials(); |
145 |
– |
// << "longRangePotential = " << longRangePotential << "\n"; |
152 |
|
longRangePotential[ELECTROSTATIC_FAMILY] += fieldPot; |
147 |
– |
//cerr << "longRangePotential[ELECTROSTATIC_FAMILY] = " << longRangePotential[ELECTROSTATIC_FAMILY] << "\n"; |
153 |
|
snap->setLongRangePotential(longRangePotential); |
154 |
|
} |
155 |
|
} |
151 |
– |
|
156 |
|
} |