ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/group/trunk/OOPSE/libmdtools/ForceFields.cpp
Revision: 420
Committed: Thu Mar 27 17:32:03 2003 UTC (21 years, 3 months ago) by mmeineke
File size: 2508 byte(s)
Log Message:
LJ_FF has been converted to the new Molecule model. TraPPE_Ex is currently being updated.
SimSetups routines are writtten, but not yet called.

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     MPI::COMM_WORLD.Allreduce( &tempBig, &bigSigma, 1, MPI_DOUBLE, MPI_MAX );
19     #endif //is_mpi
20    
21     //calc rCut and rList
22    
23     entry_plug->rCut = 2.5 bigSigma;
24     if(entry_plug->rCut > (entry_plug->box_x / 2.0))
25     entry_plug->rCut = entry_plug->box_x / 2.0;
26     if(entry_plug->rCut > (entry_plug->box_y / 2.0))
27     entry_plug->rCut = entry_plug->box_y / 2.0;
28     if(entry_plug->rCut > (entry_plug->box_z / 2.0))
29     entry_plug->rCut = entry_plug->box_z / 2.0;
30    
31     entry_plug->rList = entry_plug->rCut + 1.0;
32    
33     }
34    
35 mmeineke 377 void ForceFields::doForces( int calcPot, int calcStress ){
36    
37     int i, isError;
38     double* frc;
39     double* pos;
40     double* trq;
41     double* tau;
42     double* A;
43     double* u_l;
44    
45     short int passedCalcPot = (short int)calcPot;
46     short int passedCalcStress = (short int)calcStress;
47    
48     // forces are zeroed here, before any are acumulated.
49     // NOTE: do not rezero the forces in Fortran.
50    
51     for(i=0; i<entry_plug->n_atoms; i++){
52     entry_plug->atoms[i]->zeroForces();
53     }
54    
55 mmeineke 389 for(i=0; i<entry_plug->n_SRI; i++ ){
56     entry_plug->sr_interactions[i]->calc_forces();
57     }
58    
59 mmeineke 377 frc = Atom::getFrcArray();
60     pos = Atom::getPosArray();
61     trq = Atom::getTrqArray();
62     A = Atom::getAmatArray();
63     u_l = Atom::getUlArray();
64    
65     tau = entry_plug->tau;
66    
67     isError = 0;
68     entry_plug->lrPot = 0.0;
69 mmeineke 393
70    
71 mmeineke 377 fortranForceLoop( pos,
72     A,
73     u_l,
74     frc,
75     trq,
76     tau,
77     &(entry_plug->lrPot),
78     &passedCalcPot,
79     &passedCalcStress,
80     &isError );
81    
82    
83     if( isError ){
84     sprintf( painCave.errMsg,
85     "Error returned from the fortran force calculation.\n" );
86     painCave.isFatal = 1;
87     simError();
88     }
89    
90     #ifdef IS_MPI
91     sprintf( checkPointMsg,
92     "returned from the force calculation.\n" );
93     MPIcheckPoint();
94     #endif // is_mpi
95    
96     }
97    
98    
99     void ForceFields::initFortran(int ljMixPolicy, int useReactionField ){
100    
101     int isError;
102    
103     isError = 0;
104     initFortranFF( &ljMixPolicy, &useReactionField, &isError );
105    
106     if(isError){
107     sprintf( painCave.errMsg,
108     "ForceField error: There was an error initializing the forceField in fortran.\n" );
109     painCave.isFatal = 1;
110     simError();
111     }
112    
113    
114     #ifdef IS_MPI
115     sprintf( checkPointMsg, "ForceField successfully initialized the fortran component list.\n" );
116     MPIcheckPoint();
117     #endif // is_mpi
118    
119     }