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

Comparing trunk/src/integrators/LDForceManager.cpp (file contents):
Revision 1120 by chuckv, Fri Feb 2 18:55:21 2007 UTC vs.
Revision 1210 by gezelter, Wed Jan 23 03:45:33 2008 UTC

# Line 45 | Line 45
45   #include "utils/OOPSEConstant.hpp"
46   #include "hydrodynamics/Sphere.hpp"
47   #include "hydrodynamics/Ellipsoid.hpp"
48 < #include "openbabel/mol.hpp"
48 > #include "utils/ElementsTable.hpp"
49  
50 using namespace OpenBabel;
50   namespace oopse {
51  
52    LDForceManager::LDForceManager(SimInfo* info) : ForceManager(info){
# Line 153 | Line 152 | namespace oopse {
152               integrableObject != NULL;
153               integrableObject = mol->nextIntegrableObject(j)) {
154            Shape* currShape = NULL;
155 <          if (integrableObject->isDirectionalAtom()) {
156 <            DirectionalAtom* dAtom = static_cast<DirectionalAtom*>(integrableObject);
157 <            AtomType* atomType = dAtom->getAtomType();
155 >
156 >          if (integrableObject->isAtom()){
157 >            Atom* atom = static_cast<Atom*>(integrableObject);
158 >            AtomType* atomType = atom->getAtomType();
159              if (atomType->isGayBerne()) {
160 <              DirectionalAtomType* dAtomType = dynamic_cast<DirectionalAtomType*>(atomType);
161 <              
160 >              DirectionalAtomType* dAtomType = dynamic_cast<DirectionalAtomType*>(atomType);              
161                GenericData* data = dAtomType->getPropertyByName("GayBerne");
162                if (data != NULL) {
163                  GayBerneParamGenericData* gayBerneData = dynamic_cast<GayBerneParamGenericData*>(data);
# Line 166 | Line 165 | namespace oopse {
165                  if (gayBerneData != NULL) {  
166                    GayBerneParam gayBerneParam = gayBerneData->getData();
167                    currShape = new Ellipsoid(V3Zero,
169                                            gayBerneParam.GB_d / 2.0,
168                                              gayBerneParam.GB_l / 2.0,
169 +                                            gayBerneParam.GB_d / 2.0,
170                                              Mat3x3d::identity());
171                  } else {
172                    sprintf( painCave.errMsg,
# Line 182 | Line 181 | namespace oopse {
181                  painCave.isFatal = 1;
182                  simError();    
183                }
184 <            }
185 <          } else {
186 <            Atom* atom = static_cast<Atom*>(integrableObject);
187 <            AtomType* atomType = atom->getAtomType();
188 <            if (atomType->isLennardJones()){
189 <              GenericData* data = atomType->getPropertyByName("LennardJones");
190 <              if (data != NULL) {
191 <                LJParamGenericData* ljData = dynamic_cast<LJParamGenericData*>(data);
192 <                
193 <                if (ljData != NULL) {
194 <                  LJParam ljParam = ljData->getData();
195 <                  currShape = new Sphere(atom->getPos(), ljParam.sigma/2.0);
184 >            } else {
185 >              if (atomType->isLennardJones()){
186 >                GenericData* data = atomType->getPropertyByName("LennardJones");
187 >                if (data != NULL) {
188 >                  LJParamGenericData* ljData = dynamic_cast<LJParamGenericData*>(data);
189 >                  if (ljData != NULL) {
190 >                    LJParam ljParam = ljData->getData();
191 >                    currShape = new Sphere(atom->getPos(), ljParam.sigma/2.0);
192 >                  } else {
193 >                    sprintf( painCave.errMsg,
194 >                             "Can not cast GenericData to LJParam\n");
195 >                    painCave.severity = OOPSE_ERROR;
196 >                    painCave.isFatal = 1;
197 >                    simError();          
198 >                  }      
199 >                }
200 >              } else {
201 >                int obanum = etab.GetAtomicNum((atom->getType()).c_str());
202 >                if (obanum != 0) {
203 >                  currShape = new Sphere(atom->getPos(), etab.GetVdwRad(obanum));
204                  } else {
205                    sprintf( painCave.errMsg,
206 <                           "Can not cast GenericData to LJParam\n");
206 >                           "Could not find atom type in default element.txt\n");
207                    painCave.severity = OOPSE_ERROR;
208                    painCave.isFatal = 1;
209                    simError();          
210 <                }      
204 <              }
205 <            } else {
206 <              int obanum = etab.GetAtomicNum((atom->getType()).c_str());
207 <              if (obanum != 0) {
208 <                currShape = new Sphere(atom->getPos(), etab.GetVdwRad(obanum));
209 <              } else {
210 <                sprintf( painCave.errMsg,
211 <                         "Could not find atom type in default element.txt\n");
212 <                painCave.severity = OOPSE_ERROR;
213 <                painCave.isFatal = 1;
214 <                simError();          
210 >                }
211                }
212              }
213            }
# Line 247 | Line 243 | namespace oopse {
243      return props;
244    }
245    
246 <  void LDForceManager::postCalculation() {
246 >  void LDForceManager::postCalculation(bool needStress){
247      SimInfo::MoleculeIterator i;
248      Molecule::IntegrableObjectIterator  j;
249      Molecule* mol;
250      StuntDouble* integrableObject;
251 +    RealType mass;
252      Vector3d vel;
253      Vector3d pos;
254      Vector3d frc;
# Line 259 | Line 256 | namespace oopse {
256      Mat3x3d Atrans;
257      Vector3d Tb;
258      Vector3d ji;
262    RealType mass;
259      unsigned int index = 0;
260      bool doLangevinForces;
261      bool freezeMolecule;
262      int fdf;
267    int nIntegrated;
268    int nFrozen;
263  
264 +
265 +
266      fdf = 0;
267  
268      for (mol = info_->beginMolecule(i); mol != NULL; mol = info_->nextMolecule(i)) {
# Line 299 | Line 295 | namespace oopse {
295          
296          if (doLangevinForces) {  
297            vel =integrableObject->getVel();
298 +          mass = integrableObject->getMass();
299            if (integrableObject->isDirectional()){
300              //calculate angular velocity in lab frame
301              Mat3x3d I = integrableObject->getI();
# Line 317 | Line 314 | namespace oopse {
314                omega[1] = angMom[1] /I(1, 1);
315                omega[2] = angMom[2] /I(2, 2);
316              }
317 <            
317 >
318 >            //std::cerr << "I = " << I(0,0) << "\t" << I(1,1) << "\t" << I(2,2) << "\n\n";
319 >
320              //apply friction force and torque at center of resistance
321              A = integrableObject->getA();
322              Atrans = A.transpose();
323 +            //std::cerr << "A = " << integrableObject->getA() << "\n";
324 +            //std::cerr << "Atrans = " << A.transpose() << "\n\n";
325              Vector3d rcr = Atrans * hydroProps_[index]->getCOR();  
326 +            //std::cerr << "cor = " << hydroProps_[index]->getCOR() << "\n\n\n\n";
327 +            //std::cerr << "rcr = " << rcr << "\n\n";
328              Vector3d vcdLab = vel + cross(omega, rcr);
329 +        
330 +            //std::cerr << "velL = " << vel << "\n\n";
331 +            //std::cerr << "vcdL = " << vcdLab << "\n\n";
332              Vector3d vcdBody = A* vcdLab;
333 +            //std::cerr << "vcdB = " << vcdBody << "\n\n";
334              Vector3d frictionForceBody = -(hydroProps_[index]->getXitt() * vcdBody + hydroProps_[index]->getXirt() * omega);
335 +
336 +            //std::cerr << "xitt = " << hydroProps_[index]->getXitt() << "\n\n";
337 +            //std::cerr << "ffB = " << frictionForceBody << "\n\n";
338              Vector3d frictionForceLab = Atrans*frictionForceBody;
339 +            //std::cerr << "ffL = " << frictionForceLab << "\n\n";
340 +            //std::cerr << "frc = " << integrableObject->getFrc() << "\n\n";
341              integrableObject->addFrc(frictionForceLab);
342 +            //std::cerr << "frc = " << integrableObject->getFrc() << "\n\n";
343 +            //std::cerr << "ome = " << omega << "\n\n";
344              Vector3d frictionTorqueBody = - (hydroProps_[index]->getXitr() * vcdBody + hydroProps_[index]->getXirr() * omega);
345 +            //std::cerr << "ftB = " << frictionTorqueBody << "\n\n";
346              Vector3d frictionTorqueLab = Atrans*frictionTorqueBody;
347 +            //std::cerr << "ftL = " << frictionTorqueLab << "\n\n";
348 +            //std::cerr << "ftL2 = " << frictionTorqueLab+cross(rcr,frictionForceLab) << "\n\n";
349 +            //std::cerr << "trq = " << integrableObject->getTrq() << "\n\n";
350              integrableObject->addTrq(frictionTorqueLab+ cross(rcr, frictionForceLab));
351 <            
351 >            //std::cerr << "trq = " << integrableObject->getTrq() << "\n\n";
352 >
353              //apply random force and torque at center of resistance
354              Vector3d randomForceBody;
355              Vector3d randomTorqueBody;
356              genRandomForceAndTorque(randomForceBody, randomTorqueBody, index, variance_);
357 +            //std::cerr << "rfB = " << randomForceBody << "\n\n";
358 +            //std::cerr << "rtB = " << randomTorqueBody << "\n\n";
359              Vector3d randomForceLab = Atrans*randomForceBody;
360              Vector3d randomTorqueLab = Atrans* randomTorqueBody;
361              integrableObject->addFrc(randomForceLab);            
362 +            //std::cerr << "rfL = " << randomForceLab << "\n\n";
363 +            //std::cerr << "rtL = " << randomTorqueLab << "\n\n";
364 +            //std::cerr << "rtL2 = " << randomTorqueLab + cross(rcr, randomForceLab) << "\n\n";
365              integrableObject->addTrq(randomTorqueLab + cross(rcr, randomForceLab ));            
366              
367            } else {
368              //spherical atom
369              Vector3d frictionForce = -(hydroProps_[index]->getXitt() * vel);
370 +            //std::cerr << "xitt = " << hydroProps_[index]->getXitt() << "\n\n";
371              Vector3d randomForce;
372              Vector3d randomTorque;
373              genRandomForceAndTorque(randomForce, randomTorque, index, variance_);
# Line 362 | Line 387 | namespace oopse {
387      if(!simParams->getUsePeriodicBoundaryConditions())
388        veloMunge->removeAngularDrift();
389  
390 <    ForceManager::postCalculation();  
390 >    ForceManager::postCalculation(needStress);  
391    }
392  
393   void LDForceManager::genRandomForceAndTorque(Vector3d& force, Vector3d& torque, unsigned int index, RealType variance) {
# Line 370 | Line 395 | void LDForceManager::genRandomForceAndTorque(Vector3d&
395  
396      Vector<RealType, 6> Z;
397      Vector<RealType, 6> generalForce;
373
398          
399      Z[0] = randNumGen_.randNorm(0, variance);
400      Z[1] = randNumGen_.randNorm(0, variance);
401      Z[2] = randNumGen_.randNorm(0, variance);
402 +    //Z[3] = randNumGen_.randNorm(0, variance)*(2.0*M_PI);
403 +    //Z[4] = randNumGen_.randNorm(0, variance)*(2.0*M_PI);
404 +    //Z[5] = randNumGen_.randNorm(0, variance)*(2.0*M_PI);
405      Z[3] = randNumGen_.randNorm(0, variance);
406      Z[4] = randNumGen_.randNorm(0, variance);
407      Z[5] = randNumGen_.randNorm(0, variance);
# Line 389 | Line 416 | void LDForceManager::genRandomForceAndTorque(Vector3d&
416      torque[1] = generalForce[4];
417      torque[2] = generalForce[5];
418      
419 < }
419 > }
420  
421   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines