ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/group/trunk/OOPSE/libmdtools/ForceFields.cpp
Revision: 479
Committed: Tue Apr 8 15:20:44 2003 UTC (21 years, 3 months ago) by chuckv
File size: 2941 byte(s)
Log Message:
fixes for NVT

File Contents

# User Rev Content
1 mmeineke 377 #include <cstdlib>
2    
3     #ifdef IS_MPI
4     #include <mpi.h>
5     #endif // is_mpi
6    
7    
8     #include "simError.h"
9     #include "ForceFields.hpp"
10     #include "Atom.hpp"
11     #include "fortranWrappers.hpp"
12    
13    
14 mmeineke 420 void ForceFields::calcRcut( void ){
15    
16     #ifdef IS_MPI
17     double tempBig = bigSigma;
18 mmeineke 447 MPI_Allreduce( &tempBig, &bigSigma, 1, MPI_DOUBLE, MPI_MAX,
19     MPI_COMM_WORLD);
20 mmeineke 420 #endif //is_mpi
21    
22     //calc rCut and rList
23    
24 mmeineke 428 entry_plug->rCut = 2.5 * bigSigma;
25 mmeineke 420 if(entry_plug->rCut > (entry_plug->box_x / 2.0))
26     entry_plug->rCut = entry_plug->box_x / 2.0;
27     if(entry_plug->rCut > (entry_plug->box_y / 2.0))
28     entry_plug->rCut = entry_plug->box_y / 2.0;
29     if(entry_plug->rCut > (entry_plug->box_z / 2.0))
30     entry_plug->rCut = entry_plug->box_z / 2.0;
31    
32     entry_plug->rList = entry_plug->rCut + 1.0;
33    
34     }
35    
36 mmeineke 377 void ForceFields::doForces( int calcPot, int calcStress ){
37    
38     int i, isError;
39     double* frc;
40     double* pos;
41     double* trq;
42     double* A;
43 mmeineke 443 double* u_l;;
44     DirectionalAtom* dAtom;
45 mmeineke 377
46 mmeineke 443 double ut[3];
47    
48     //u_l = new double[entry_plug->n_atoms];
49    
50 mmeineke 377 short int passedCalcPot = (short int)calcPot;
51     short int passedCalcStress = (short int)calcStress;
52    
53     // forces are zeroed here, before any are acumulated.
54     // NOTE: do not rezero the forces in Fortran.
55    
56 mmeineke 443
57 mmeineke 377 for(i=0; i<entry_plug->n_atoms; i++){
58     entry_plug->atoms[i]->zeroForces();
59 mmeineke 443
60 mmeineke 447 // if( entry_plug->atoms[i]->isDirectional() ){
61     // dAtom = (DirectionalAtom *)entry_plug->atoms[i];
62     // dAtom->getU(ut);
63 mmeineke 443
64    
65 mmeineke 447 // if(dAtom->getIndex()== 1){
66     // std::cerr << "atom 2's u_l = " << ut[0] << ", " << ut[1]
67     // << ", " << ut[2] << "\n";
68     // }
69     // }
70 mmeineke 443
71 mmeineke 377 }
72    
73 mmeineke 423 for(i=0; i<entry_plug->n_mol; i++ ){
74 mmeineke 428 entry_plug->molecules[i].calcForces();
75 mmeineke 389 }
76    
77 mmeineke 377 frc = Atom::getFrcArray();
78     pos = Atom::getPosArray();
79     trq = Atom::getTrqArray();
80     A = Atom::getAmatArray();
81     u_l = Atom::getUlArray();
82    
83 mmeineke 424
84 mmeineke 377 isError = 0;
85     entry_plug->lrPot = 0.0;
86 mmeineke 393
87 chuckv 479 for (i=0; i<9; i++) {
88     entry_plug->tau[i] = 0.0;
89     }
90 chuckv 438
91 mmeineke 377 fortranForceLoop( pos,
92     A,
93     u_l,
94     frc,
95     trq,
96 chuckv 479 entry_plug->tau,
97 mmeineke 377 &(entry_plug->lrPot),
98     &passedCalcPot,
99     &passedCalcStress,
100     &isError );
101    
102 mmeineke 443 // delete[] u_l;
103 chuckv 438
104 mmeineke 377 if( isError ){
105     sprintf( painCave.errMsg,
106     "Error returned from the fortran force calculation.\n" );
107     painCave.isFatal = 1;
108     simError();
109     }
110    
111     #ifdef IS_MPI
112     sprintf( checkPointMsg,
113     "returned from the force calculation.\n" );
114     MPIcheckPoint();
115     #endif // is_mpi
116    
117     }
118    
119    
120     void ForceFields::initFortran(int ljMixPolicy, int useReactionField ){
121    
122     int isError;
123    
124     isError = 0;
125     initFortranFF( &ljMixPolicy, &useReactionField, &isError );
126    
127     if(isError){
128     sprintf( painCave.errMsg,
129     "ForceField error: There was an error initializing the forceField in fortran.\n" );
130     painCave.isFatal = 1;
131     simError();
132     }
133    
134    
135     #ifdef IS_MPI
136     sprintf( checkPointMsg, "ForceField successfully initialized the fortran component list.\n" );
137     MPIcheckPoint();
138     #endif // is_mpi
139    
140     }