ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/group/trunk/OOPSE/libmdtools/ForceFields.cpp
Revision: 484
Committed: Wed Apr 9 13:59:35 2003 UTC (21 years, 3 months ago) by gezelter
File size: 2564 byte(s)
Log Message:
Added volume and enthalpy to status file

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* A;
43 double* u_l;;
44 DirectionalAtom* dAtom;
45
46 short int passedCalcPot = (short int)calcPot;
47 short int passedCalcStress = (short int)calcStress;
48
49 // forces are zeroed here, before any are accumulated.
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
66 isError = 0;
67 entry_plug->lrPot = 0.0;
68
69 for (i=0; i<9; i++) {
70 entry_plug->tau[i] = 0.0;
71 }
72
73 fortranForceLoop( pos,
74 A,
75 u_l,
76 frc,
77 trq,
78 entry_plug->tau,
79 &(entry_plug->lrPot),
80 &passedCalcPot,
81 &passedCalcStress,
82 &isError );
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 }