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 1237 by gezelter, Fri Apr 18 16:55:15 2008 UTC vs.
branches/development/src/integrators/LDForceManager.cpp (file contents), Revision 1710 by gezelter, Fri May 18 21:44:02 2012 UTC

# Line 6 | Line 6
6   * redistribute this software in source and binary code form, provided
7   * that the following conditions are met:
8   *
9 < * 1. Acknowledgement of the program authors must be made in any
10 < *    publication of scientific results based in part on use of the
11 < *    program.  An acceptable form of acknowledgement is citation of
12 < *    the article in which the program was described (Matthew
13 < *    A. Meineke, Charles F. Vardeman II, Teng Lin, Christopher
14 < *    J. Fennell and J. Daniel Gezelter, "OOPSE: An Object-Oriented
15 < *    Parallel Simulation Engine for Molecular Dynamics,"
16 < *    J. Comput. Chem. 26, pp. 252-271 (2005))
17 < *
18 < * 2. Redistributions of source code must retain the above copyright
9 > * 1. Redistributions of source code must retain the above copyright
10   *    notice, this list of conditions and the following disclaimer.
11   *
12 < * 3. Redistributions in binary form must reproduce the above copyright
12 > * 2. Redistributions in binary form must reproduce the above copyright
13   *    notice, this list of conditions and the following disclaimer in the
14   *    documentation and/or other materials provided with the
15   *    distribution.
# Line 37 | Line 28
28   * arising out of the use of or inability to use software, even if the
29   * University of Notre Dame has been advised of the possibility of
30   * such damages.
31 + *
32 + * SUPPORT OPEN SCIENCE!  If you use OpenMD or its source code in your
33 + * research, please cite the appropriate papers when you publish your
34 + * work.  Good starting points are:
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]  Kuang & Gezelter,  J. Chem. Phys. 133, 164101 (2010).
40 + * [5]  Vardeman, Stocker & Gezelter, J. Chem. Theory Comput. 7, 834 (2011).
41   */
42   #include <fstream>
43   #include <iostream>
44   #include "integrators/LDForceManager.hpp"
45   #include "math/CholeskyDecomposition.hpp"
46 < #include "utils/OOPSEConstant.hpp"
46 > #include "utils/PhysicalConstants.hpp"
47   #include "hydrodynamics/Sphere.hpp"
48   #include "hydrodynamics/Ellipsoid.hpp"
49   #include "utils/ElementsTable.hpp"
50 + #include "types/LennardJonesAdapter.hpp"
51 + #include "types/GayBerneAdapter.hpp"
52  
53 < namespace oopse {
53 > namespace OpenMD {
54  
55    LDForceManager::LDForceManager(SimInfo* info) : ForceManager(info), forceTolerance_(1e-6), maxIterNum_(4) {
56      simParams = info->getSimParams();
# Line 62 | Line 65 | namespace oopse {
65          sprintf( painCave.errMsg,
66                   "langevinBufferRadius must be specified "
67                   "when useSphericalBoundaryConditions is turned on.\n");
68 <        painCave.severity = OOPSE_ERROR;
68 >        painCave.severity = OPENMD_ERROR;
69          painCave.isFatal = 1;
70          simError();  
71        }
# Line 73 | Line 76 | namespace oopse {
76          sprintf( painCave.errMsg,
77                   "frozenBufferRadius must be specified "
78                   "when useSphericalBoundaryConditions is turned on.\n");
79 <        painCave.severity = OOPSE_ERROR;
79 >        painCave.severity = OPENMD_ERROR;
80          painCave.isFatal = 1;
81          simError();  
82        }
# Line 82 | Line 85 | namespace oopse {
85          sprintf( painCave.errMsg,
86                   "frozenBufferRadius has been set smaller than the "
87                   "langevinBufferRadius.  This is probably an error.\n");
88 <        painCave.severity = OOPSE_WARNING;
88 >        painCave.severity = OPENMD_WARNING;
89          painCave.isFatal = 0;
90          simError();  
91        }
# Line 120 | Line 123 | namespace oopse {
123                   "HydroPropFile must be set to a file name if Langevin Dynamics\n"
124                   "\tis specified for rigidBodies which contain more than one atom\n"
125                   "\tTo create a HydroPropFile, run the \"Hydro\" program.\n");
126 <        painCave.severity = OOPSE_ERROR;
126 >        painCave.severity = OPENMD_ERROR;
127          painCave.isFatal = 1;
128          simError();  
129        }      
# Line 137 | Line 140 | namespace oopse {
140            } else {
141              sprintf( painCave.errMsg,
142                       "Can not find resistance tensor for atom [%s]\n", integrableObject->getType().c_str());
143 <            painCave.severity = OOPSE_ERROR;
143 >            painCave.severity = OPENMD_ERROR;
144              painCave.isFatal = 1;
145              simError();  
146            }        
# Line 156 | Line 159 | namespace oopse {
159            if (integrableObject->isAtom()){
160              Atom* atom = static_cast<Atom*>(integrableObject);
161              AtomType* atomType = atom->getAtomType();
162 <            if (atomType->isGayBerne()) {
163 <              DirectionalAtomType* dAtomType = dynamic_cast<DirectionalAtomType*>(atomType);              
164 <              GenericData* data = dAtomType->getPropertyByName("GayBerne");
165 <              if (data != NULL) {
166 <                GayBerneParamGenericData* gayBerneData = dynamic_cast<GayBerneParamGenericData*>(data);
164 <                
165 <                if (gayBerneData != NULL) {  
166 <                  GayBerneParam gayBerneParam = gayBerneData->getData();
167 <                  currShape = new Ellipsoid(V3Zero,
168 <                                            gayBerneParam.GB_l / 2.0,
169 <                                            gayBerneParam.GB_d / 2.0,
170 <                                            Mat3x3d::identity());
171 <                } else {
172 <                  sprintf( painCave.errMsg,
173 <                           "Can not cast GenericData to GayBerneParam\n");
174 <                  painCave.severity = OOPSE_ERROR;
175 <                  painCave.isFatal = 1;
176 <                  simError();  
177 <                }
178 <              } else {
179 <                sprintf( painCave.errMsg, "Can not find Parameters for GayBerne\n");
180 <                painCave.severity = OOPSE_ERROR;
181 <                painCave.isFatal = 1;
182 <                simError();    
183 <              }
162 >            GayBerneAdapter gba = GayBerneAdapter(atomType);
163 >            if (gba.isGayBerne()) {
164 >              currShape = new Ellipsoid(V3Zero, gba.getL() / 2.0,
165 >                                        gba.getD() / 2.0,
166 >                                        Mat3x3d::identity());
167              } else {
168 <              if (atomType->isLennardJones()){
169 <                GenericData* data = atomType->getPropertyByName("LennardJones");
170 <                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 <                }
168 >              LennardJonesAdapter lja = LennardJonesAdapter(atomType);
169 >              if (lja.isLennardJones()){
170 >                currShape = new Sphere(atom->getPos(), lja.getSigma()/2.0);
171                } else {
172                  int aNum = etab.GetAtomicNum((atom->getType()).c_str());
173                  if (aNum != 0) {
# Line 204 | Line 175 | namespace oopse {
175                  } else {
176                    sprintf( painCave.errMsg,
177                             "Could not find atom type in default element.txt\n");
178 <                  painCave.severity = OOPSE_ERROR;
178 >                  painCave.severity = OPENMD_ERROR;
179                    painCave.isFatal = 1;
180                    simError();          
181                  }
182                }
183              }
184            }
185 +
186 +          if (!simParams->haveTargetTemp()) {
187 +            sprintf(painCave.errMsg, "You can't use LangevinDynamics without a targetTemp!\n");
188 +            painCave.isFatal = 1;
189 +            painCave.severity = OPENMD_ERROR;
190 +            simError();
191 +          }
192 +
193 +          if (!simParams->haveViscosity()) {
194 +            sprintf(painCave.errMsg, "You can't use LangevinDynamics without a viscosity!\n");
195 +            painCave.isFatal = 1;
196 +            painCave.severity = OPENMD_ERROR;
197 +            simError();
198 +          }
199 +
200 +
201            HydroProp* currHydroProp = currShape->getHydroProp(simParams->getViscosity(),simParams->getTargetTemp());
202            std::map<std::string, HydroProp*>::iterator iter = hydroPropMap.find(integrableObject->getType());
203            if (iter != hydroPropMap.end())
# Line 223 | Line 210 | namespace oopse {
210          }
211        }
212      }
213 <    variance_ = 2.0 * OOPSEConstant::kb*simParams->getTargetTemp()/simParams->getDt();
213 >    variance_ = 2.0 * PhysicalConstants::kb*simParams->getTargetTemp()/simParams->getDt();
214    }  
215  
216    std::map<std::string, HydroProp*> LDForceManager::parseFrictionFile(const std::string& filename) {
# Line 243 | Line 230 | namespace oopse {
230      return props;
231    }
232    
233 <  void LDForceManager::postCalculation(bool needStress){
233 >  void LDForceManager::postCalculation(){
234      SimInfo::MoleculeIterator i;
235      Molecule::IntegrableObjectIterator  j;
236      Molecule* mol;
# Line 326 | Line 313 | namespace oopse {
313              //estimate velocity at full-step using everything but friction forces:          
314  
315              frc = integrableObject->getFrc();
316 <            Vector3d velStep = vel + (dt2_ /mass * OOPSEConstant::energyConvert) * frc;
316 >            Vector3d velStep = vel + (dt2_ /mass * PhysicalConstants::energyConvert) * frc;
317  
318              Tb = integrableObject->lab2Body(integrableObject->getTrq());
319 <            Vector3d angMomStep = angMom + (dt2_ * OOPSEConstant::energyConvert) * Tb;                            
319 >            Vector3d angMomStep = angMom + (dt2_ * PhysicalConstants::energyConvert) * Tb;                            
320  
321              Vector3d omegaLab;
322              Vector3d vcdLab;
# Line 375 | Line 362 | namespace oopse {
362                
363                // re-estimate velocities at full-step using friction forces:
364                
365 <              velStep = vel + (dt2_ / mass * OOPSEConstant::energyConvert) * (frc + frictionForceLab);
366 <              angMomStep = angMom + (dt2_ * OOPSEConstant::energyConvert) * (Tb + frictionTorqueBody);
365 >              velStep = vel + (dt2_ / mass * PhysicalConstants::energyConvert) * (frc + frictionForceLab);
366 >              angMomStep = angMom + (dt2_ * PhysicalConstants::energyConvert) * (Tb + frictionTorqueBody);
367  
368                // check for convergence (if the vectors have converged, fdot and tdot will both be 1.0):
369                
# Line 411 | Line 398 | namespace oopse {
398              //estimate velocity at full-step using everything but friction forces:          
399  
400              frc = integrableObject->getFrc();
401 <            Vector3d velStep = vel + (dt2_ / mass * OOPSEConstant::energyConvert) * frc;
401 >            Vector3d velStep = vel + (dt2_ / mass * PhysicalConstants::energyConvert) * frc;
402  
403              Vector3d frictionForce(0.0);
404              Vector3d oldFF;  // used to test for convergence
# Line 426 | Line 413 | namespace oopse {
413  
414                // re-estimate velocities at full-step using friction forces:
415                
416 <              velStep = vel + (dt2_ / mass * OOPSEConstant::energyConvert) * (frc + frictionForce);
416 >              velStep = vel + (dt2_ / mass * PhysicalConstants::energyConvert) * (frc + frictionForce);
417  
418                // check for convergence (if the vector has converged, fdot will be 1.0):
419                
# Line 452 | Line 439 | namespace oopse {
439      if(!simParams->getUsePeriodicBoundaryConditions())
440        veloMunge->removeAngularDrift();
441  
442 <    ForceManager::postCalculation(needStress);  
442 >    ForceManager::postCalculation();  
443    }
444  
445   void LDForceManager::genRandomForceAndTorque(Vector3d& force, Vector3d& torque, unsigned int index, RealType variance) {

Comparing:
trunk/src/integrators/LDForceManager.cpp (property svn:keywords), Revision 1237 by gezelter, Fri Apr 18 16:55:15 2008 UTC vs.
branches/development/src/integrators/LDForceManager.cpp (property svn:keywords), Revision 1710 by gezelter, Fri May 18 21:44:02 2012 UTC

# Line 0 | Line 1
1 + Author Id Revision Date

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines