ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/group/trunk/OOPSE/libmdtools/ForceFields.cpp
(Generate patch)

Comparing trunk/OOPSE/libmdtools/ForceFields.cpp (file contents):
Revision 597 by mmeineke, Mon Jul 14 21:28:54 2003 UTC vs.
Revision 1097 by gezelter, Mon Apr 12 20:32:20 2004 UTC

# Line 3 | Line 3 | using namespace std;
3   using namespace std;
4  
5  
6 < #include <cstdlib>
6 > #include <stdlib.h>
7  
8   #ifdef IS_MPI
9   #include <mpi.h>
10   #endif // is_mpi
11  
12  
13 + #ifdef PROFILE
14 + #include "mdProfile.hpp"
15 + #endif
16 +
17   #include "simError.h"
18   #include "ForceFields.hpp"
19   #include "Atom.hpp"
# Line 26 | Line 30 | void ForceFields::calcRcut( void ){
30  
31    //calc rCut and rList
32  
33 <  entry_plug->rCut = 2.5 * bigSigma;
34 <  if(entry_plug->rCut > (entry_plug->boxLx / 2.0))
35 <    entry_plug->rCut = entry_plug->boxLx / 2.0;
36 <  if(entry_plug->rCut > (entry_plug->boxLy / 2.0))
37 <    entry_plug->rCut = entry_plug->boxLy / 2.0;
34 <  if(entry_plug->rCut > (entry_plug->boxLz / 2.0))
35 <    entry_plug->rCut = entry_plug->boxLz / 2.0;
33 >  entry_plug->setDefaultRcut( 2.5 * bigSigma );  
34 >    
35 > }
36 >
37 > void ForceFields::setRcut( double LJrcut ) {
38    
39 <  entry_plug->rList = entry_plug->rCut + 1.0;
39 > #ifdef IS_MPI
40 >  double tempBig = bigSigma;
41 >  MPI_Allreduce( &tempBig, &bigSigma, 1, MPI_DOUBLE, MPI_MAX,
42 >                 MPI_COMM_WORLD);
43 > #endif  //is_mpi
44    
45 +  if (LJrcut < 2.5 * bigSigma) {
46 +    sprintf( painCave.errMsg,
47 +             "Setting Lennard-Jones cutoff radius to %lf.\n"
48 +             "\tThis value is smaller than %lf, which is\n"
49 +             "\t2.5 * bigSigma, where bigSigma is the largest\n"
50 +             "\tvalue of sigma present in the simulation.\n"
51 +             "\tThis is potentially a problem since the LJ potential may\n"
52 +             "\tbe appreciable at this distance.  If you don't want the\n"
53 +             "\tsmaller cutoff, change the LJrcut variable.\n",
54 +             LJrcut, 2.5*bigSigma);
55 +    painCave.isFatal = 0;
56 +    simError();
57 +  } else {
58 +    sprintf( painCave.errMsg,
59 +             "Setting Lennard-Jones cutoff radius to %lf.\n"
60 +             "\tThis value is larger than %lf, which is\n"
61 +             "\t2.5 * bigSigma, where bigSigma is the largest\n"
62 +             "\tvalue of sigma present in the simulation. This should\n"
63 +             "\tnot be a problem, but could adversely effect performance.\n",
64 +             LJrcut, 2.5*bigSigma);
65 +    painCave.isFatal = 0;
66 +    simError();
67 +  }
68 +  
69 +  //calc rCut and rList
70 +  
71 +  entry_plug->setDefaultRcut( LJrcut );
72   }
73  
74   void ForceFields::doForces( int calcPot, int calcStress ){
# Line 46 | Line 79 | void ForceFields::doForces( int calcPot, int calcStres
79    double* trq;
80    double* A;
81    double* u_l;;
82 <  DirectionalAtom* dAtom;
82 >  SimState* config;
83  
84    short int passedCalcPot = (short int)calcPot;
85    short int passedCalcStress = (short int)calcStress;
# Line 58 | Line 91 | void ForceFields::doForces( int calcPot, int calcStres
91      entry_plug->atoms[i]->zeroForces();    
92    }
93  
94 + #ifdef PROFILE
95 +  startProfile(pro7);
96 + #endif
97 +  
98    for(i=0; i<entry_plug->n_mol; i++ ){
99 +    // CalcForces in molecules takes care of mapping rigid body coordinates
100 +    // into atomic coordinates
101      entry_plug->molecules[i].calcForces();
102    }
103  
104 + #ifdef PROFILE
105 +  endProfile( pro7 );
106 + #endif
107 +
108 +  config = entry_plug->getConfiguration();
109    
110 <  
111 <  frc = Atom::getFrcArray();
112 <  pos = Atom::getPosArray();
113 <  trq = Atom::getTrqArray();
114 <  A   = Atom::getAmatArray();
71 <  u_l = Atom::getUlArray();
110 >  frc = config->getFrcArray();
111 >  pos = config->getPosArray();
112 >  trq = config->getTrqArray();
113 >  A   = config->getAmatArray();
114 >  u_l = config->getUlArray();
115  
116    isError = 0;
117    entry_plug->lrPot = 0.0;
# Line 77 | Line 120 | void ForceFields::doForces( int calcPot, int calcStres
120      entry_plug->tau[i] = 0.0;
121    }
122  
123 +
124 + #ifdef PROFILE
125 +  startProfile(pro8);
126 + #endif
127 +
128    fortranForceLoop( pos,
129                      A,
130                      u_l,
# Line 88 | Line 136 | void ForceFields::doForces( int calcPot, int calcStres
136                      &passedCalcStress,
137                      &isError );
138  
139 + #ifdef PROFILE
140 +  endProfile(pro8);
141 + #endif
142 +
143 +
144    if( isError ){
145      sprintf( painCave.errMsg,
146               "Error returned from the fortran force calculation.\n" );
# Line 95 | Line 148 | void ForceFields::doForces( int calcPot, int calcStres
148      simError();
149    }
150  
151 +  for(i=0; i<entry_plug->n_mol; i++ ){
152 +    entry_plug->molecules[i].atoms2rigidBodies();
153 +  }
154 +
155 +
156   #ifdef IS_MPI
157    sprintf( checkPointMsg,
158             "returned from the force calculation.\n" );

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines