ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/group/trunk/OOPSE/libmdtools/ForceFields.cpp
Revision: 377
Committed: Fri Mar 21 17:42:12 2003 UTC (21 years, 3 months ago) by mmeineke
Original Path: branches/mmeineke/OOPSE/libmdtools/ForceFields.cpp
File size: 1820 byte(s)
Log Message:
New OOPSE Tree

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 frc = Atom::getFrcArray();
35 pos = Atom::getPosArray();
36 trq = Atom::getTrqArray();
37 A = Atom::getAmatArray();
38 u_l = Atom::getUlArray();
39
40 tau = entry_plug->tau;
41
42 isError = 0;
43 entry_plug->lrPot = 0.0;
44 fortranForceLoop( pos,
45 A,
46 u_l,
47 frc,
48 trq,
49 tau,
50 &(entry_plug->lrPot),
51 &passedCalcPot,
52 &passedCalcStress,
53 &isError );
54
55
56 if( isError ){
57 sprintf( painCave.errMsg,
58 "Error returned from the fortran force calculation.\n" );
59 painCave.isFatal = 1;
60 simError();
61 }
62
63 #ifdef IS_MPI
64 sprintf( checkPointMsg,
65 "returned from the force calculation.\n" );
66 MPIcheckPoint();
67 #endif // is_mpi
68
69 }
70
71
72 void ForceFields::initFortran(int ljMixPolicy, int useReactionField ){
73
74 int isError;
75
76 isError = 0;
77 initFortranFF( &ljMixPolicy, &useReactionField, &isError );
78
79 if(isError){
80 sprintf( painCave.errMsg,
81 "ForceField error: There was an error initializing the forceField in fortran.\n" );
82 painCave.isFatal = 1;
83 simError();
84 }
85
86
87 #ifdef IS_MPI
88 sprintf( checkPointMsg, "ForceField successfully initialized the fortran component list.\n" );
89 MPIcheckPoint();
90 #endif // is_mpi
91
92 }