ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/group/trunk/OOPSE/libmdtools/ForceFields.cpp
Revision: 428
Committed: Thu Mar 27 21:07:14 2003 UTC (21 years, 3 months ago) by mmeineke
File size: 2519 byte(s)
Log Message:
fixed the compile time bugs, Source builds and links

File Contents

# Content
1 #include <cstdlib>
2
3 #ifdef IS_MPI
4 #include <mpi.h>
5 #include <mpi++.h>
6 #endif // is_mpi
7
8
9 #include "simError.h"
10 #include "ForceFields.hpp"
11 #include "Atom.hpp"
12 #include "fortranWrappers.hpp"
13
14
15 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 entry_plug->rCut = 2.5 * bigSigma;
25 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 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 for(i=0; i<entry_plug->n_mol; i++ ){
57 entry_plug->molecules[i].calcForces();
58 }
59
60 frc = Atom::getFrcArray();
61 pos = Atom::getPosArray();
62 trq = Atom::getTrqArray();
63 A = Atom::getAmatArray();
64 u_l = Atom::getUlArray();
65 tau = entry_plug->tau;
66
67
68 isError = 0;
69 entry_plug->lrPot = 0.0;
70
71
72 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 }