ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/group/trunk/OOPSE/libmdtools/ForceFields.cpp
Revision: 472
Committed: Mon Apr 7 21:16:35 2003 UTC (21 years, 2 months ago) by mmeineke
File size: 2966 byte(s)
Log Message:
doing some testing in sticky through Symplectic.

File Contents

# Content
1 #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 void ForceFields::calcRcut( void ){
15
16 #ifdef IS_MPI
17 double tempBig = bigSigma;
18 MPI_Allreduce( &tempBig, &bigSigma, 1, MPI_DOUBLE, MPI_MAX,
19 MPI_COMM_WORLD);
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 DirectionalAtom* dAtom;
46
47 double ut[3];
48
49 //u_l = new double[entry_plug->n_atoms];
50
51 short int passedCalcPot = (short int)calcPot;
52 short int passedCalcStress = (short int)calcStress;
53
54 // forces are zeroed here, before any are acumulated.
55 // NOTE: do not rezero the forces in Fortran.
56
57
58 for(i=0; i<entry_plug->n_atoms; i++){
59 entry_plug->atoms[i]->zeroForces();
60
61 // if( entry_plug->atoms[i]->isDirectional() ){
62 // dAtom = (DirectionalAtom *)entry_plug->atoms[i];
63 // dAtom->getU(ut);
64
65
66 // if(dAtom->getIndex()== 1){
67 // std::cerr << "atom 2's u_l = " << ut[0] << ", " << ut[1]
68 // << ", " << ut[2] << "\n";
69 // }
70 // }
71
72 }
73
74 for(i=0; i<entry_plug->n_mol; i++ ){
75 entry_plug->molecules[i].calcForces();
76 }
77
78 frc = Atom::getFrcArray();
79 pos = Atom::getPosArray();
80 trq = Atom::getTrqArray();
81 A = Atom::getAmatArray();
82 u_l = Atom::getUlArray();
83 tau = entry_plug->tau;
84
85
86 isError = 0;
87 entry_plug->lrPot = 0.0;
88 tau[0] = 0.0;
89 tau[1] = 0.0;
90 tau[2] = 0.0;
91
92
93
94
95 fortranForceLoop( pos,
96 A,
97 u_l,
98 frc,
99 trq,
100 tau,
101 &(entry_plug->lrPot),
102 &passedCalcPot,
103 &passedCalcStress,
104 &isError );
105
106
107 // delete[] u_l;
108
109 if( isError ){
110 sprintf( painCave.errMsg,
111 "Error returned from the fortran force calculation.\n" );
112 painCave.isFatal = 1;
113 simError();
114 }
115
116 #ifdef IS_MPI
117 sprintf( checkPointMsg,
118 "returned from the force calculation.\n" );
119 MPIcheckPoint();
120 #endif // is_mpi
121
122 }
123
124
125 void ForceFields::initFortran(int ljMixPolicy, int useReactionField ){
126
127 int isError;
128
129 isError = 0;
130 initFortranFF( &ljMixPolicy, &useReactionField, &isError );
131
132 if(isError){
133 sprintf( painCave.errMsg,
134 "ForceField error: There was an error initializing the forceField in fortran.\n" );
135 painCave.isFatal = 1;
136 simError();
137 }
138
139
140 #ifdef IS_MPI
141 sprintf( checkPointMsg, "ForceField successfully initialized the fortran component list.\n" );
142 MPIcheckPoint();
143 #endif // is_mpi
144
145 }