ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/group/trunk/OOPSE/libmdtools/ForceFields.cpp
Revision: 438
Committed: Mon Mar 31 21:50:59 2003 UTC (21 years, 3 months ago) by chuckv
File size: 2522 byte(s)
Log Message:
Fixes in MPI force calc and in Trappe_Ex parsing.

File Contents

# User Rev Content
1 mmeineke 377 #include <cstdlib>
2    
3     #ifdef IS_MPI
4     #include <mpi.h>
5 mmeineke 428 #include <mpi++.h>
6 mmeineke 377 #endif // is_mpi
7    
8    
9     #include "simError.h"
10     #include "ForceFields.hpp"
11     #include "Atom.hpp"
12     #include "fortranWrappers.hpp"
13    
14    
15 mmeineke 420 void ForceFields::calcRcut( void ){
16    
17     #ifdef IS_MPI
18     double tempBig = bigSigma;
19     MPI::COMM_WORLD.Allreduce( &tempBig, &bigSigma, 1, MPI_DOUBLE, MPI_MAX );
20     #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* tau;
43     double* A;
44     double* u_l;
45    
46     short int passedCalcPot = (short int)calcPot;
47     short int passedCalcStress = (short int)calcStress;
48    
49     // forces are zeroed here, before any are acumulated.
50     // NOTE: do not rezero the forces in Fortran.
51    
52     for(i=0; i<entry_plug->n_atoms; i++){
53     entry_plug->atoms[i]->zeroForces();
54     }
55    
56 mmeineke 423 for(i=0; i<entry_plug->n_mol; i++ ){
57 mmeineke 428 entry_plug->molecules[i].calcForces();
58 mmeineke 389 }
59    
60 mmeineke 377 frc = Atom::getFrcArray();
61     pos = Atom::getPosArray();
62     trq = Atom::getTrqArray();
63     A = Atom::getAmatArray();
64     u_l = Atom::getUlArray();
65 mmeineke 424 tau = entry_plug->tau;
66 mmeineke 377
67 mmeineke 424
68 mmeineke 377 isError = 0;
69     entry_plug->lrPot = 0.0;
70 mmeineke 393
71 chuckv 438
72 mmeineke 393
73 mmeineke 377 fortranForceLoop( pos,
74     A,
75     u_l,
76     frc,
77     trq,
78     tau,
79     &(entry_plug->lrPot),
80     &passedCalcPot,
81     &passedCalcStress,
82     &isError );
83    
84    
85 chuckv 438
86    
87 mmeineke 377 if( isError ){
88     sprintf( painCave.errMsg,
89     "Error returned from the fortran force calculation.\n" );
90     painCave.isFatal = 1;
91     simError();
92     }
93    
94     #ifdef IS_MPI
95     sprintf( checkPointMsg,
96     "returned from the force calculation.\n" );
97     MPIcheckPoint();
98     #endif // is_mpi
99    
100     }
101    
102    
103     void ForceFields::initFortran(int ljMixPolicy, int useReactionField ){
104    
105     int isError;
106    
107     isError = 0;
108     initFortranFF( &ljMixPolicy, &useReactionField, &isError );
109    
110     if(isError){
111     sprintf( painCave.errMsg,
112     "ForceField error: There was an error initializing the forceField in fortran.\n" );
113     painCave.isFatal = 1;
114     simError();
115     }
116    
117    
118     #ifdef IS_MPI
119     sprintf( checkPointMsg, "ForceField successfully initialized the fortran component list.\n" );
120     MPIcheckPoint();
121     #endif // is_mpi
122    
123     }