ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/group/trunk/OOPSE/libmdtools/ForceFields.cpp
Revision: 626
Committed: Wed Jul 16 21:30:56 2003 UTC (20 years, 11 months ago) by mmeineke
File size: 2269 byte(s)
Log Message:
Changed how cutoffs were handled from C. Now notifyCutoffs in Fortran notifies those who need the information of any changes to cutoffs.

File Contents

# User Rev Content
1 mmeineke 561 #include <iostream>
2    
3     using namespace std;
4    
5    
6 mmeineke 377 #include <cstdlib>
7    
8     #ifdef IS_MPI
9     #include <mpi.h>
10     #endif // is_mpi
11    
12    
13     #include "simError.h"
14     #include "ForceFields.hpp"
15     #include "Atom.hpp"
16     #include "fortranWrappers.hpp"
17    
18    
19 mmeineke 420 void ForceFields::calcRcut( void ){
20    
21     #ifdef IS_MPI
22     double tempBig = bigSigma;
23 mmeineke 447 MPI_Allreduce( &tempBig, &bigSigma, 1, MPI_DOUBLE, MPI_MAX,
24     MPI_COMM_WORLD);
25 mmeineke 420 #endif //is_mpi
26    
27     //calc rCut and rList
28    
29 mmeineke 626 entry_plug->setRcut( 2.5 * bigSigma );
30 mmeineke 420 }
31    
32 mmeineke 377 void ForceFields::doForces( int calcPot, int calcStress ){
33    
34     int i, isError;
35     double* frc;
36     double* pos;
37     double* trq;
38     double* A;
39 mmeineke 443 double* u_l;;
40     DirectionalAtom* dAtom;
41 mmeineke 377
42     short int passedCalcPot = (short int)calcPot;
43     short int passedCalcStress = (short int)calcStress;
44    
45 gezelter 484 // forces are zeroed here, before any are accumulated.
46 mmeineke 377 // NOTE: do not rezero the forces in Fortran.
47    
48     for(i=0; i<entry_plug->n_atoms; i++){
49 gezelter 484 entry_plug->atoms[i]->zeroForces();
50 mmeineke 377 }
51    
52 mmeineke 423 for(i=0; i<entry_plug->n_mol; i++ ){
53 mmeineke 428 entry_plug->molecules[i].calcForces();
54 mmeineke 389 }
55    
56 mmeineke 597
57    
58 mmeineke 377 frc = Atom::getFrcArray();
59     pos = Atom::getPosArray();
60     trq = Atom::getTrqArray();
61     A = Atom::getAmatArray();
62     u_l = Atom::getUlArray();
63 mmeineke 561
64 mmeineke 377 isError = 0;
65     entry_plug->lrPot = 0.0;
66 mmeineke 393
67 chuckv 479 for (i=0; i<9; i++) {
68     entry_plug->tau[i] = 0.0;
69     }
70 chuckv 438
71 mmeineke 377 fortranForceLoop( pos,
72     A,
73     u_l,
74     frc,
75     trq,
76 chuckv 479 entry_plug->tau,
77 mmeineke 377 &(entry_plug->lrPot),
78     &passedCalcPot,
79     &passedCalcStress,
80     &isError );
81    
82     if( isError ){
83     sprintf( painCave.errMsg,
84     "Error returned from the fortran force calculation.\n" );
85     painCave.isFatal = 1;
86     simError();
87     }
88    
89     #ifdef IS_MPI
90     sprintf( checkPointMsg,
91     "returned from the force calculation.\n" );
92     MPIcheckPoint();
93     #endif // is_mpi
94 mmeineke 597
95 mmeineke 377
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     }