ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/group/trunk/OOPSE/libmdtools/ForceFields.cpp
Revision: 393
Committed: Mon Mar 24 18:33:51 2003 UTC (21 years, 3 months ago) by mmeineke
File size: 1919 byte(s)
Log Message:
little bug fixes here and there

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::doForces( int calcPot, int calcStress ){
15
16 int i, isError;
17 double* frc;
18 double* pos;
19 double* trq;
20 double* tau;
21 double* A;
22 double* u_l;
23
24 short int passedCalcPot = (short int)calcPot;
25 short int passedCalcStress = (short int)calcStress;
26
27 // forces are zeroed here, before any are acumulated.
28 // NOTE: do not rezero the forces in Fortran.
29
30 for(i=0; i<entry_plug->n_atoms; i++){
31 entry_plug->atoms[i]->zeroForces();
32 }
33
34 for(i=0; i<entry_plug->n_SRI; i++ ){
35 entry_plug->sr_interactions[i]->calc_forces();
36 }
37
38 frc = Atom::getFrcArray();
39 pos = Atom::getPosArray();
40 trq = Atom::getTrqArray();
41 A = Atom::getAmatArray();
42 u_l = Atom::getUlArray();
43
44 tau = entry_plug->tau;
45
46 isError = 0;
47 entry_plug->lrPot = 0.0;
48
49
50 fortranForceLoop( pos,
51 A,
52 u_l,
53 frc,
54 trq,
55 tau,
56 &(entry_plug->lrPot),
57 &passedCalcPot,
58 &passedCalcStress,
59 &isError );
60
61
62 if( isError ){
63 sprintf( painCave.errMsg,
64 "Error returned from the fortran force calculation.\n" );
65 painCave.isFatal = 1;
66 simError();
67 }
68
69 #ifdef IS_MPI
70 sprintf( checkPointMsg,
71 "returned from the force calculation.\n" );
72 MPIcheckPoint();
73 #endif // is_mpi
74
75 }
76
77
78 void ForceFields::initFortran(int ljMixPolicy, int useReactionField ){
79
80 int isError;
81
82 isError = 0;
83 initFortranFF( &ljMixPolicy, &useReactionField, &isError );
84
85 if(isError){
86 sprintf( painCave.errMsg,
87 "ForceField error: There was an error initializing the forceField in fortran.\n" );
88 painCave.isFatal = 1;
89 simError();
90 }
91
92
93 #ifdef IS_MPI
94 sprintf( checkPointMsg, "ForceField successfully initialized the fortran component list.\n" );
95 MPIcheckPoint();
96 #endif // is_mpi
97
98 }