1 |
mmeineke |
299 |
#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 |
mmeineke |
362 |
void ForceFields::doForces( int calcPot, int calcStress ){ |
15 |
mmeineke |
299 |
|
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 |
mmeineke |
362 |
short int passedCalcStress = (short int)calcStress; |
26 |
mmeineke |
299 |
|
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 |
mmeineke |
362 |
fortranForceLoop( pos, |
44 |
|
|
A, |
45 |
|
|
u_l, |
46 |
|
|
frc, |
47 |
|
|
trq, |
48 |
|
|
tau, |
49 |
|
|
&(entry_plug->lrPot), |
50 |
|
|
&passedCalcPot, |
51 |
|
|
&passedCalcStress, |
52 |
|
|
&isError ); |
53 |
mmeineke |
299 |
|
54 |
|
|
|
55 |
|
|
if( isError ){ |
56 |
|
|
sprintf( painCave.errMsg, |
57 |
|
|
"Error returned from the fortran force calculation.\n" ); |
58 |
|
|
painCave.isFatal = 1; |
59 |
|
|
simError(); |
60 |
|
|
} |
61 |
|
|
|
62 |
|
|
#ifdef IS_MPI |
63 |
|
|
sprintf( checkPointMsg, |
64 |
|
|
"returned from the force calculation.\n" ); |
65 |
|
|
MPIcheckPoint(); |
66 |
|
|
#endif // is_mpi |
67 |
|
|
|
68 |
|
|
} |
69 |
|
|
|
70 |
|
|
|
71 |
mmeineke |
359 |
void ForceFields::initFortran(int ljMixPolicy, int useReactionField ){ |
72 |
mmeineke |
299 |
|
73 |
|
|
int isError; |
74 |
mmeineke |
359 |
|
75 |
mmeineke |
299 |
isError = 0; |
76 |
mmeineke |
359 |
initfortran( &ljMixPolicy, &useReactionField, &isError ); |
77 |
mmeineke |
299 |
|
78 |
|
|
if(isError){ |
79 |
|
|
sprintf( painCave.errMsg, |
80 |
mmeineke |
359 |
"ForceField error: There was an error initializing the forceField in fortran.\n" ); |
81 |
mmeineke |
299 |
painCave.isFatal = 1; |
82 |
|
|
simError(); |
83 |
|
|
} |
84 |
|
|
|
85 |
|
|
|
86 |
|
|
#ifdef IS_MPI |
87 |
|
|
sprintf( checkPointMsg, "ForceField successfully initialized the fortran component list.\n" ); |
88 |
|
|
MPIcheckPoint(); |
89 |
|
|
#endif // is_mpi |
90 |
|
|
|
91 |
|
|
delete[] ident; |
92 |
|
|
|
93 |
|
|
} |