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

Comparing:
trunk/src/visitors/AtomVisitor.cpp (file contents), Revision 1455 by gezelter, Thu Jun 24 20:44:18 2010 UTC vs.
branches/development/src/visitors/AtomVisitor.cpp (file contents), Revision 1873 by gezelter, Fri May 10 16:09:34 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).          
39 < * [4]  Vardeman & Gezelter, in progress (2009).                        
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   */
42  
43   #include <cstring>
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;
# Line 78 | Line 88 | namespace OpenMD {
88    void DefaultAtomVisitor::visit(Atom *atom) {
89      AtomData *atomData;
90      AtomInfo *atomInfo;
91 <    Vector3d  pos;
92 <    
91 >    AtomType* atype = atom->getAtomType();
92 >              
93      if (isVisited(atom))
94        return;
95      
96      atomInfo = new AtomInfo;
87    
88    atomData = new AtomData;
89    atomData->setID("ATOMDATA");
90    
91    pos = atom->getPos();
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->dipole[0] = 0.0;
102 <    atomInfo->dipole[1] = 0.0;
103 <    atomInfo->dipole[2] = 0.0;
98 >    atomInfo->pos = atom->getPos();
99 >    atomInfo->vel = atom->getVel();
100 >    atomInfo->frc = atom->getFrc();
101 >    atomInfo->vec = V3Zero;
102 >    atomInfo->hasVelocity = true;
103 >    atomInfo->hasForce = true;
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);
# Line 107 | Line 132 | namespace OpenMD {
132    void DefaultAtomVisitor::visit(DirectionalAtom *datom) {
133      AtomData *atomData;
134      AtomInfo *atomInfo;
135 <    Vector3d  pos;
111 <    Vector3d  u;
135 >    AtomType* atype = datom->getAtomType();
136  
137      if (isVisited(datom))
138        return;
139 +    
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 <    pos = datom->getPos();
149 <    if (datom->getAtomType()->isGayBerne()) {
150 <        u = datom->getA().transpose()*V3Z;        
151 <    } else if (datom->getAtomType()->isMultipole()) {
120 <        u = datom->getElectroFrame().getColumn(2);
148 >    FixedChargeAdapter fca = FixedChargeAdapter(atype);
149 >    if ( fca.isFixedCharge() ) {
150 >      atomInfo->hasCharge = true;
151 >      atomInfo->charge = fca.getCharge();
152      }
153 <    atomData = new AtomData;
154 <    atomData->setID("ATOMDATA");
155 <    atomInfo = new AtomInfo;
153 >          
154 >    FluctuatingChargeAdapter fqa = FluctuatingChargeAdapter(atype);
155 >    if ( fqa.isFluctuatingCharge() ) {
156 >      atomInfo->hasCharge = true;
157 >      atomInfo->charge += datom->getFlucQPos();
158 >    }
159  
160 <    atomInfo->atomTypeName = datom->getType();
161 <    atomInfo->pos[0] = pos[0];
162 <    atomInfo->pos[1] = pos[1];
163 <    atomInfo->pos[2] = pos[2];
164 <    atomInfo->dipole[0] = u[0];
131 <    atomInfo->dipole[1] = u[1];
132 <    atomInfo->dipole[2] = u[2];
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 +      atomInfo->hasVector = true;
171 +      atomInfo->vec = datom->getA().transpose()*V3Z;
172 +    } else if (ma.isDipole()) {
173 +      atomInfo->hasVector = true;
174 +      atomInfo->vec = datom->getDipole();
175 +    } else if (ma.isQuadrupole()) {
176 +      atomInfo->hasVector = true;
177 +      atomInfo->vec = datom->getA().transpose()*V3Z;
178 +    }
179 +
180 +    atomData = new AtomData;
181 +    atomData->setID("ATOMDATA");  
182      atomData->addAtomInfo(atomInfo);
183  
184      datom->addProperty(atomData);
# Line 143 | Line 191 | namespace OpenMD {
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());
# Line 154 | Line 202 | namespace OpenMD {
202      result += buffer;
203  
204      sprintf(buffer,
205 <            "------------------------------------------------------------------\n");
205 >            "--------------------------------------------------------------\n");
206      result += buffer;
207  
208      return result;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines