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

Comparing:
trunk/src/brains/ForceManager.cpp (file contents), Revision 1215 by xsun, Wed Jan 23 21:22:37 2008 UTC vs.
branches/development/src/brains/ForceManager.cpp (file contents), Revision 1469 by gezelter, Mon Jul 19 14:07:59 2010 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]  Vardeman & Gezelter, in progress (2009).                        
40   */
41  
42   /**
# Line 50 | Line 50
50   #include "brains/ForceManager.hpp"
51   #include "primitives/Molecule.hpp"
52   #include "UseTheForce/doForces_interface.h"
53 < #define __C
53 > #define __OPENMD_C
54   #include "UseTheForce/DarkSide/fInteractionMap.h"
55   #include "utils/simError.h"
56   #include "primitives/Bond.hpp"
57   #include "primitives/Bend.hpp"
58 < namespace oopse {
58 > #include "primitives/Torsion.hpp"
59 > #include "primitives/Inversion.hpp"
60  
61 <  void ForceManager::calcForces(bool needPotential, bool needStress) {
61 > namespace OpenMD {
62 >  
63 >  ForceManager::ForceManager(SimInfo * info) : info_(info),
64 >                                               NBforcesInitialized_(false) {
65 >    std::cerr << __PRETTY_FUNCTION__ << "\n";
66 >    lj_ = new LJ(info_->getForceField());
67 >  }
68 >
69 >  void ForceManager::calcForces() {
70      
71 +    std::cerr << __PRETTY_FUNCTION__ << "\n";
72      if (!info_->isFortranInitialized()) {
73        info_->update();
74      }
75      
76 +    if (!NBforcesInitialized_) {
77 +      lj_->initialize();    
78 +    }
79 +
80      preCalculation();
81      
82      calcShortRangeInteraction();
83  
84 <    calcLongRangeInteraction(needPotential, needStress);
84 >    calcLongRangeInteraction();
85  
86 <    postCalculation(needStress);
86 >    postCalculation();
87      
88    }
89    
# Line 83 | Line 97 | namespace oopse {
97      
98      // forces are zeroed here, before any are accumulated.
99      // NOTE: do not rezero the forces in Fortran.
100 <
100 >    
101      for (mol = info_->beginMolecule(mi); mol != NULL;
102           mol = info_->nextMolecule(mi)) {
103        for(atom = mol->beginAtom(ai); atom != NULL; atom = mol->nextAtom(ai)) {
104          atom->zeroForcesAndTorques();
105        }
106 <      
106 >          
107        //change the positions of atoms which belong to the rigidbodies
108        for (rb = mol->beginRigidBody(rbIter); rb != NULL;
109             rb = mol->nextRigidBody(rbIter)) {
110          rb->zeroForcesAndTorques();
111        }        
112 +          
113      }
114      
115      // Zero out the stress tensor
# Line 108 | Line 123 | namespace oopse {
123      Bond* bond;
124      Bend* bend;
125      Torsion* torsion;
126 +    Inversion* inversion;
127      SimInfo::MoleculeIterator mi;
128      Molecule::RigidBodyIterator rbIter;
129      Molecule::BondIterator bondIter;;
130      Molecule::BendIterator  bendIter;
131      Molecule::TorsionIterator  torsionIter;
132 +    Molecule::InversionIterator  inversionIter;
133      RealType bondPotential = 0.0;
134      RealType bendPotential = 0.0;
135      RealType torsionPotential = 0.0;
136 +    RealType inversionPotential = 0.0;
137  
138      //calculate short range interactions    
139      for (mol = info_->beginMolecule(mi); mol != NULL;
# Line 139 | Line 157 | namespace oopse {
157          RealType angle;
158          bend->calcForce(angle);
159          RealType currBendPot = bend->getPotential();          
160 +        
161          bendPotential += bend->getPotential();
162          std::map<Bend*, BendDataSet>::iterator i = bendDataSets.find(bend);
163          if (i == bendDataSets.end()) {
# Line 175 | Line 194 | namespace oopse {
194            i->second.prev.potential = i->second.curr.potential;
195            i->second.curr.angle = angle;
196            i->second.curr.potential = currTorsionPot;
197 +          i->second.deltaV =  fabs(i->second.curr.potential -  
198 +                                   i->second.prev.potential);
199 +        }      
200 +      }      
201 +
202 +      for (inversion = mol->beginInversion(inversionIter);
203 +           inversion != NULL;
204 +           inversion = mol->nextInversion(inversionIter)) {
205 +        RealType angle;
206 +        inversion->calcForce(angle);
207 +        RealType currInversionPot = inversion->getPotential();
208 +        inversionPotential += inversion->getPotential();
209 +        std::map<Inversion*, InversionDataSet>::iterator i = inversionDataSets.find(inversion);
210 +        if (i == inversionDataSets.end()) {
211 +          InversionDataSet dataSet;
212 +          dataSet.prev.angle = dataSet.curr.angle = angle;
213 +          dataSet.prev.potential = dataSet.curr.potential = currInversionPot;
214 +          dataSet.deltaV = 0.0;
215 +          inversionDataSets.insert(std::map<Inversion*, InversionDataSet>::value_type(inversion, dataSet));
216 +        }else {
217 +          i->second.prev.angle = i->second.curr.angle;
218 +          i->second.prev.potential = i->second.curr.potential;
219 +          i->second.curr.angle = angle;
220 +          i->second.curr.potential = currInversionPot;
221            i->second.deltaV =  fabs(i->second.curr.potential -  
222                                     i->second.prev.potential);
223          }      
# Line 182 | Line 225 | namespace oopse {
225      }
226      
227      RealType  shortRangePotential = bondPotential + bendPotential +
228 <      torsionPotential;    
228 >      torsionPotential +  inversionPotential;    
229      Snapshot* curSnapshot = info_->getSnapshotManager()->getCurrentSnapshot();
230      curSnapshot->statData[Stats::SHORT_RANGE_POTENTIAL] = shortRangePotential;
231      curSnapshot->statData[Stats::BOND_POTENTIAL] = bondPotential;
232      curSnapshot->statData[Stats::BEND_POTENTIAL] = bendPotential;
233      curSnapshot->statData[Stats::DIHEDRAL_POTENTIAL] = torsionPotential;
234 +    curSnapshot->statData[Stats::INVERSION_POTENTIAL] = inversionPotential;
235      
236    }
237    
238 <  void ForceManager::calcLongRangeInteraction(bool needPotential,
195 <                                              bool needStress) {
238 >  void ForceManager::calcLongRangeInteraction() {
239      Snapshot* curSnapshot;
240      DataStorage* config;
241      RealType* frc;
# Line 201 | Line 244 | namespace oopse {
244      RealType* A;
245      RealType* electroFrame;
246      RealType* rc;
247 +    RealType* particlePot;
248      
249      //get current snapshot from SimInfo
250      curSnapshot = info_->getSnapshotManager()->getCurrentSnapshot();
# Line 212 | Line 256 | namespace oopse {
256      trq = config->getArrayPointer(DataStorage::dslTorque);
257      A   = config->getArrayPointer(DataStorage::dslAmat);
258      electroFrame = config->getArrayPointer(DataStorage::dslElectroFrame);
259 +    particlePot = config->getArrayPointer(DataStorage::dslParticlePot);
260  
261      //calculate the center of mass of cutoff group
262      SimInfo::MoleculeIterator mi;
# Line 243 | Line 288 | namespace oopse {
288      RealType longRangePotential[LR_POT_TYPES];
289      RealType lrPot = 0.0;
290      Vector3d totalDipole;
246    short int passedCalcPot = needPotential;
247    short int passedCalcStress = needStress;
291      int isError = 0;
292  
293      for (int i=0; i<LR_POT_TYPES;i++){
# Line 259 | Line 302 | namespace oopse {
302                  trq,
303                  tau.getArrayPointer(),
304                  longRangePotential,
305 <                &passedCalcPot,
263 <                &passedCalcStress,
305 >                particlePot,
306                  &isError );
307      
308      if( isError ){
# Line 289 | Line 331 | namespace oopse {
331    }
332  
333    
334 <  void ForceManager::postCalculation(bool needStress) {
334 >  void ForceManager::postCalculation() {
335      SimInfo::MoleculeIterator mi;
336      Molecule* mol;
337      Molecule::RigidBodyIterator rbIter;
# Line 302 | Line 344 | namespace oopse {
344           mol = info_->nextMolecule(mi)) {
345        for (rb = mol->beginRigidBody(rbIter); rb != NULL;
346             rb = mol->nextRigidBody(rbIter)) {
347 <        if (needStress) {          
348 <          Mat3x3d rbTau = rb->calcForcesAndTorquesAndVirial();
307 <          tau += rbTau;
308 <        } else{
309 <          rb->calcForcesAndTorques();
310 <        }
347 >        Mat3x3d rbTau = rb->calcForcesAndTorquesAndVirial();
348 >        tau += rbTau;
349        }
350      }
351 <
314 <    if (needStress) {
351 >    
352   #ifdef IS_MPI
353 <      Mat3x3d tmpTau(tau);
354 <      MPI_Allreduce(tmpTau.getArrayPointer(), tau.getArrayPointer(),
355 <                    9, MPI_REALTYPE, MPI_SUM, MPI_COMM_WORLD);
353 >    Mat3x3d tmpTau(tau);
354 >    MPI_Allreduce(tmpTau.getArrayPointer(), tau.getArrayPointer(),
355 >                  9, MPI_REALTYPE, MPI_SUM, MPI_COMM_WORLD);
356   #endif
357 <      curSnapshot->statData.setTau(tau);
321 <    }
357 >    curSnapshot->statData.setTau(tau);
358    }
359  
360 < } //end namespace oopse
360 > } //end namespace OpenMD

Comparing:
trunk/src/brains/ForceManager.cpp (property svn:keywords), Revision 1215 by xsun, Wed Jan 23 21:22:37 2008 UTC vs.
branches/development/src/brains/ForceManager.cpp (property svn:keywords), Revision 1469 by gezelter, Mon Jul 19 14:07:59 2010 UTC

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

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines