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

Comparing branches/development/src/visitors/AtomVisitor.cpp (file contents):
Revision 1465 by chuckv, Fri Jul 9 23:08:25 2010 UTC vs.
Revision 1872 by gezelter, Fri May 10 15:10:41 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    void BaseAtomVisitor::visit(RigidBody *rb) {
# Line 78 | Line 83 | namespace OpenMD {
83    void DefaultAtomVisitor::visit(Atom *atom) {
84      AtomData *atomData;
85      AtomInfo *atomInfo;
86 <    Vector3d  pos;
87 <    Vector3d  vel;
83 <    Vector3d  frc;
84 <    Vector3d  u;
85 <    RealType  c;
86 <
86 >    AtomType* atype = atom->getAtomType();
87 >              
88      if (isVisited(atom))
89        return;
90      
91      atomInfo = new AtomInfo;
91    
92    atomData = new AtomData;
93    atomData->setID("ATOMDATA");
94    
95    pos = atom->getPos();
96    vel = atom->getVel();
97    frc = atom->getFrc();
92      atomInfo->atomTypeName = atom->getType();
93 <    atomInfo->pos[0] = pos[0];
94 <    atomInfo->pos[1] = pos[1];
95 <    atomInfo->pos[2] = pos[2];
96 <    atomInfo->vel[0] = vel[0];
103 <    atomInfo->vel[1] = vel[1];
104 <    atomInfo->vel[2] = vel[2];
93 >    atomInfo->pos = atom->getPos();
94 >    atomInfo->vel = atom->getVel();
95 >    atomInfo->frc = atom->getFrc();
96 >    atomInfo->vec = V3Zero;
97      atomInfo->hasVelocity = true;
106    atomInfo->frc[0] = frc[0];
107    atomInfo->frc[1] = frc[1];
108    atomInfo->frc[2] = frc[2];
98      atomInfo->hasForce = true;
99 <    atomInfo->vec[0] = 0.0;
100 <    atomInfo->vec[1] = 0.0;
101 <    atomInfo->vec[2] = 0.0;
102 <    
99 >        
100 >    FixedChargeAdapter fca = FixedChargeAdapter(atype);
101 >    if ( fca.isFixedCharge() ) {
102 >      atomInfo->hasCharge = true;
103 >      atomInfo->charge = fca.getCharge();
104 >    }
105 >          
106 >    FluctuatingChargeAdapter fqa = FluctuatingChargeAdapter(atype);
107 >    if ( fqa.isFluctuatingCharge() ) {
108 >      atomInfo->hasCharge = true;
109 >      atomInfo->charge += atom->getFlucQPos();
110 >    }
111 >
112 >    if (atype->isElectrostatic()) {
113 >      atomInfo->hasElectricField = true;
114 >      atomInfo->eField = atom->getElectricField();
115 >    }
116 >
117 >    atomData = new AtomData;
118 >    atomData->setID("ATOMDATA");  
119      atomData->addAtomInfo(atomInfo);
120      
121      atom->addProperty(atomData);
# Line 121 | Line 126 | namespace OpenMD {
126    void DefaultAtomVisitor::visit(DirectionalAtom *datom) {
127      AtomData *atomData;
128      AtomInfo *atomInfo;
129 <    Vector3d  pos;
125 <    Vector3d  vel;
126 <    Vector3d  frc;
127 <    Vector3d  u;
128 <    RealType  c;
129 >    AtomType* atype = datom->getAtomType();
130  
131      if (isVisited(datom))
132        return;
133      
133    pos = datom->getPos();
134    vel = datom->getVel();
135    frc = datom->getFrc();
136    if (datom->getAtomType()->isGayBerne()) {
137        u = datom->getA().transpose()*V3Z;        
138    } else if (datom->getAtomType()->isMultipole()) {
139        u = datom->getElectroFrame().getColumn(2);
140    }
141    atomData = new AtomData;
142    atomData->setID("ATOMDATA");
134      atomInfo = new AtomInfo;
144
135      atomInfo->atomTypeName = datom->getType();
136 <    atomInfo->pos[0] = pos[0];
137 <    atomInfo->pos[1] = pos[1];
138 <    atomInfo->pos[2] = pos[2];
149 <    atomInfo->vel[0] = vel[0];
150 <    atomInfo->vel[1] = vel[1];
151 <    atomInfo->vel[2] = vel[2];
136 >    atomInfo->pos = datom->getPos();
137 >    atomInfo->vel = datom->getVel();
138 >    atomInfo->frc = datom->getFrc();
139      atomInfo->hasVelocity = true;
153    atomInfo->frc[0] = frc[0];
154    atomInfo->frc[1] = frc[1];
155    atomInfo->frc[2] = frc[2];
140      atomInfo->hasForce = true;
157    atomInfo->vec[0] = u[0];
158    atomInfo->vec[1] = u[1];
159    atomInfo->vec[2] = u[2];
160    atomInfo->hasVector = true;
141  
142 +    FixedChargeAdapter fca = FixedChargeAdapter(atype);
143 +    if ( fca.isFixedCharge() ) {
144 +      atomInfo->hasCharge = true;
145 +      atomInfo->charge = fca.getCharge();
146 +    }
147 +          
148 +    FluctuatingChargeAdapter fqa = FluctuatingChargeAdapter(atype);
149 +    if ( fqa.isFluctuatingCharge() ) {
150 +      atomInfo->hasCharge = true;
151 +      atomInfo->charge += datom->getFlucQPos();
152 +    }
153 +
154 +    if (atype->isElectrostatic()) {
155 +      atomInfo->hasElectricField = true;
156 +      atomInfo->eField = datom->getElectricField();
157 +    }
158 +
159 +    GayBerneAdapter gba = GayBerneAdapter(atype);
160 +    MultipoleAdapter ma = MultipoleAdapter(atype);
161 +    
162 +    if (gba.isGayBerne()) {
163 +      atomInfo->hasVector = true;
164 +      atomInfo->vec = datom->getA().transpose()*V3Z;
165 +    } else if (ma.isDipole()) {
166 +      atomInfo->hasVector = true;
167 +      atomInfo->vec = datom->getDipole();
168 +    } else if (ma.isQuadrupole()) {
169 +      atomInfo->hasVector = true;
170 +      atomInfo->vec = datom->getA().transpose()*V3Z;
171 +    }
172 +
173 +    atomData = new AtomData;
174 +    atomData->setID("ATOMDATA");  
175      atomData->addAtomInfo(atomInfo);
176  
177      datom->addProperty(atomData);
# Line 171 | Line 184 | namespace OpenMD {
184      std::string result;
185  
186      sprintf(buffer,
187 <            "------------------------------------------------------------------\n");
187 >            "--------------------------------------------------------------\n");
188      result += buffer;
189  
190      sprintf(buffer, "Visitor name: %s\n", visitorName.c_str());
# Line 182 | Line 195 | namespace OpenMD {
195      result += buffer;
196  
197      sprintf(buffer,
198 <            "------------------------------------------------------------------\n");
198 >            "--------------------------------------------------------------\n");
199      result += buffer;
200  
201      return result;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines