| 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 |
|
*/ |
| 44 |
|
#include "visitors/AtomVisitor.hpp" |
| 45 |
|
#include "primitives/DirectionalAtom.hpp" |
| 46 |
|
#include "primitives/RigidBody.hpp" |
| 47 |
+ |
#include "types/FixedChargeAdapter.hpp" |
| 48 |
+ |
#include "types/FluctuatingChargeAdapter.hpp" |
| 49 |
|
#include "types/MultipoleAdapter.hpp" |
| 50 |
|
#include "types/GayBerneAdapter.hpp" |
| 51 |
|
|
| 52 |
|
namespace OpenMD { |
| 53 |
+ |
|
| 54 |
+ |
BaseAtomVisitor::BaseAtomVisitor(SimInfo* info) : BaseVisitor() { |
| 55 |
+ |
storageLayout_ = info->getStorageLayout(); |
| 56 |
+ |
} |
| 57 |
+ |
|
| 58 |
|
void BaseAtomVisitor::visit(RigidBody *rb) { |
| 59 |
|
//vector<Atom*> myAtoms; |
| 60 |
|
//vector<Atom*>::iterator atomIter; |
| 88 |
|
void DefaultAtomVisitor::visit(Atom *atom) { |
| 89 |
|
AtomData *atomData; |
| 90 |
|
AtomInfo *atomInfo; |
| 91 |
< |
Vector3d pos; |
| 92 |
< |
Vector3d vel; |
| 86 |
< |
Vector3d frc; |
| 87 |
< |
Vector3d u; |
| 88 |
< |
|
| 91 |
> |
AtomType* atype = atom->getAtomType(); |
| 92 |
> |
|
| 93 |
|
if (isVisited(atom)) |
| 94 |
|
return; |
| 95 |
|
|
| 96 |
|
atomInfo = new AtomInfo; |
| 93 |
– |
|
| 94 |
– |
atomData = new AtomData; |
| 95 |
– |
atomData->setID("ATOMDATA"); |
| 96 |
– |
|
| 97 |
– |
pos = atom->getPos(); |
| 98 |
– |
vel = atom->getVel(); |
| 99 |
– |
frc = atom->getFrc(); |
| 97 |
|
atomInfo->atomTypeName = atom->getType(); |
| 98 |
< |
atomInfo->pos[0] = pos[0]; |
| 99 |
< |
atomInfo->pos[1] = pos[1]; |
| 100 |
< |
atomInfo->pos[2] = pos[2]; |
| 101 |
< |
atomInfo->vel[0] = vel[0]; |
| 105 |
< |
atomInfo->vel[1] = vel[1]; |
| 106 |
< |
atomInfo->vel[2] = vel[2]; |
| 98 |
> |
atomInfo->pos = atom->getPos(); |
| 99 |
> |
atomInfo->vel = atom->getVel(); |
| 100 |
> |
atomInfo->frc = atom->getFrc(); |
| 101 |
> |
atomInfo->vec = V3Zero; |
| 102 |
|
atomInfo->hasVelocity = true; |
| 108 |
– |
atomInfo->frc[0] = frc[0]; |
| 109 |
– |
atomInfo->frc[1] = frc[1]; |
| 110 |
– |
atomInfo->frc[2] = frc[2]; |
| 103 |
|
atomInfo->hasForce = true; |
| 104 |
< |
atomInfo->vec[0] = 0.0; |
| 105 |
< |
atomInfo->vec[1] = 0.0; |
| 106 |
< |
atomInfo->vec[2] = 0.0; |
| 104 |
> |
|
| 105 |
> |
FixedChargeAdapter fca = FixedChargeAdapter(atype); |
| 106 |
> |
if ( fca.isFixedCharge() ) { |
| 107 |
> |
atomInfo->hasCharge = true; |
| 108 |
> |
atomInfo->charge = fca.getCharge(); |
| 109 |
> |
} |
| 110 |
> |
|
| 111 |
> |
FluctuatingChargeAdapter fqa = FluctuatingChargeAdapter(atype); |
| 112 |
> |
if ( fqa.isFluctuatingCharge() ) { |
| 113 |
> |
atomInfo->hasCharge = true; |
| 114 |
> |
atomInfo->charge += atom->getFlucQPos(); |
| 115 |
> |
} |
| 116 |
|
|
| 117 |
+ |
if ((storageLayout_ & DataStorage::dslElectricField) && |
| 118 |
+ |
(atype->isElectrostatic())) { |
| 119 |
+ |
atomInfo->hasElectricField = true; |
| 120 |
+ |
atomInfo->eField = atom->getElectricField(); |
| 121 |
+ |
} |
| 122 |
+ |
|
| 123 |
+ |
atomData = new AtomData; |
| 124 |
+ |
atomData->setID("ATOMDATA"); |
| 125 |
|
atomData->addAtomInfo(atomInfo); |
| 126 |
|
|
| 127 |
|
atom->addProperty(atomData); |
| 132 |
|
void DefaultAtomVisitor::visit(DirectionalAtom *datom) { |
| 133 |
|
AtomData *atomData; |
| 134 |
|
AtomInfo *atomInfo; |
| 135 |
< |
Vector3d pos; |
| 127 |
< |
Vector3d vel; |
| 128 |
< |
Vector3d frc; |
| 129 |
< |
Vector3d u; |
| 135 |
> |
AtomType* atype = datom->getAtomType(); |
| 136 |
|
|
| 137 |
|
if (isVisited(datom)) |
| 138 |
|
return; |
| 139 |
|
|
| 140 |
< |
pos = datom->getPos(); |
| 141 |
< |
vel = datom->getVel(); |
| 142 |
< |
frc = datom->getFrc(); |
| 140 |
> |
atomInfo = new AtomInfo; |
| 141 |
> |
atomInfo->atomTypeName = datom->getType(); |
| 142 |
> |
atomInfo->pos = datom->getPos(); |
| 143 |
> |
atomInfo->vel = datom->getVel(); |
| 144 |
> |
atomInfo->frc = datom->getFrc(); |
| 145 |
> |
atomInfo->hasVelocity = true; |
| 146 |
> |
atomInfo->hasForce = true; |
| 147 |
|
|
| 148 |
< |
GayBerneAdapter gba = GayBerneAdapter(datom->getAtomType()); |
| 149 |
< |
MultipoleAdapter ma = MultipoleAdapter(datom->getAtomType()); |
| 148 |
> |
FixedChargeAdapter fca = FixedChargeAdapter(atype); |
| 149 |
> |
if ( fca.isFixedCharge() ) { |
| 150 |
> |
atomInfo->hasCharge = true; |
| 151 |
> |
atomInfo->charge = fca.getCharge(); |
| 152 |
> |
} |
| 153 |
> |
|
| 154 |
> |
FluctuatingChargeAdapter fqa = FluctuatingChargeAdapter(atype); |
| 155 |
> |
if ( fqa.isFluctuatingCharge() ) { |
| 156 |
> |
atomInfo->hasCharge = true; |
| 157 |
> |
atomInfo->charge += datom->getFlucQPos(); |
| 158 |
> |
} |
| 159 |
> |
|
| 160 |
> |
if ((storageLayout_ & DataStorage::dslElectricField) && |
| 161 |
> |
(atype->isElectrostatic())) { |
| 162 |
> |
atomInfo->hasElectricField = true; |
| 163 |
> |
atomInfo->eField = datom->getElectricField(); |
| 164 |
> |
} |
| 165 |
> |
|
| 166 |
> |
GayBerneAdapter gba = GayBerneAdapter(atype); |
| 167 |
> |
MultipoleAdapter ma = MultipoleAdapter(atype); |
| 168 |
|
|
| 169 |
|
if (gba.isGayBerne()) { |
| 170 |
< |
u = datom->getA().transpose()*V3Z; |
| 170 |
> |
atomInfo->hasVector = true; |
| 171 |
> |
atomInfo->vec = datom->getA().transpose()*V3Z; |
| 172 |
|
} else if (ma.isDipole()) { |
| 173 |
< |
u = datom->getDipole(); |
| 173 |
> |
atomInfo->hasVector = true; |
| 174 |
> |
atomInfo->vec = datom->getDipole(); |
| 175 |
|
} else if (ma.isQuadrupole()) { |
| 176 |
< |
u = datom->getQuadrupole().getColumn(2); |
| 176 |
> |
atomInfo->hasVector = true; |
| 177 |
> |
atomInfo->vec = datom->getA().transpose()*V3Z; |
| 178 |
|
} |
| 148 |
– |
atomData = new AtomData; |
| 149 |
– |
atomData->setID("ATOMDATA"); |
| 150 |
– |
atomInfo = new AtomInfo; |
| 179 |
|
|
| 180 |
< |
atomInfo->atomTypeName = datom->getType(); |
| 181 |
< |
atomInfo->pos[0] = pos[0]; |
| 154 |
< |
atomInfo->pos[1] = pos[1]; |
| 155 |
< |
atomInfo->pos[2] = pos[2]; |
| 156 |
< |
atomInfo->vel[0] = vel[0]; |
| 157 |
< |
atomInfo->vel[1] = vel[1]; |
| 158 |
< |
atomInfo->vel[2] = vel[2]; |
| 159 |
< |
atomInfo->hasVelocity = true; |
| 160 |
< |
atomInfo->frc[0] = frc[0]; |
| 161 |
< |
atomInfo->frc[1] = frc[1]; |
| 162 |
< |
atomInfo->frc[2] = frc[2]; |
| 163 |
< |
atomInfo->hasForce = true; |
| 164 |
< |
atomInfo->vec[0] = u[0]; |
| 165 |
< |
atomInfo->vec[1] = u[1]; |
| 166 |
< |
atomInfo->vec[2] = u[2]; |
| 167 |
< |
atomInfo->hasVector = true; |
| 168 |
< |
|
| 180 |
> |
atomData = new AtomData; |
| 181 |
> |
atomData->setID("ATOMDATA"); |
| 182 |
|
atomData->addAtomInfo(atomInfo); |
| 183 |
|
|
| 184 |
|
datom->addProperty(atomData); |
| 191 |
|
std::string result; |
| 192 |
|
|
| 193 |
|
sprintf(buffer, |
| 194 |
< |
"------------------------------------------------------------------\n"); |
| 194 |
> |
"--------------------------------------------------------------\n"); |
| 195 |
|
result += buffer; |
| 196 |
|
|
| 197 |
|
sprintf(buffer, "Visitor name: %s\n", visitorName.c_str()); |
| 202 |
|
result += buffer; |
| 203 |
|
|
| 204 |
|
sprintf(buffer, |
| 205 |
< |
"------------------------------------------------------------------\n"); |
| 205 |
> |
"--------------------------------------------------------------\n"); |
| 206 |
|
result += buffer; |
| 207 |
|
|
| 208 |
|
return result; |