ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/group/trunk/OOPSE/libmdtools/ForceFields.cpp
Revision: 424
Committed: Thu Mar 27 20:36:16 2003 UTC (21 years, 3 months ago) by mmeineke
File size: 2501 byte(s)
Log Message:
fixing some compile time bugs

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 mmeineke 424
46 mmeineke 377 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     entry_plug->molecules[i]->calc_forces();
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    
72 mmeineke 377 fortranForceLoop( pos,
73     A,
74     u_l,
75     frc,
76     trq,
77     tau,
78     &(entry_plug->lrPot),
79     &passedCalcPot,
80     &passedCalcStress,
81     &isError );
82    
83    
84     if( isError ){
85     sprintf( painCave.errMsg,
86     "Error returned from the fortran force calculation.\n" );
87     painCave.isFatal = 1;
88     simError();
89     }
90    
91     #ifdef IS_MPI
92     sprintf( checkPointMsg,
93     "returned from the force calculation.\n" );
94     MPIcheckPoint();
95     #endif // is_mpi
96    
97     }
98    
99    
100     void ForceFields::initFortran(int ljMixPolicy, int useReactionField ){
101    
102     int isError;
103    
104     isError = 0;
105     initFortranFF( &ljMixPolicy, &useReactionField, &isError );
106    
107     if(isError){
108     sprintf( painCave.errMsg,
109     "ForceField error: There was an error initializing the forceField in fortran.\n" );
110     painCave.isFatal = 1;
111     simError();
112     }
113    
114    
115     #ifdef IS_MPI
116     sprintf( checkPointMsg, "ForceField successfully initialized the fortran component list.\n" );
117     MPIcheckPoint();
118     #endif // is_mpi
119    
120     }