1 |
mmeineke |
377 |
#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 |
mmeineke |
389 |
for(i=0; i<entry_plug->n_SRI; i++ ){ |
35 |
|
|
entry_plug->sr_interactions[i]->calc_forces(); |
36 |
|
|
} |
37 |
|
|
|
38 |
mmeineke |
377 |
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 |
|
|
fortranForceLoop( pos, |
49 |
|
|
A, |
50 |
|
|
u_l, |
51 |
|
|
frc, |
52 |
|
|
trq, |
53 |
|
|
tau, |
54 |
|
|
&(entry_plug->lrPot), |
55 |
|
|
&passedCalcPot, |
56 |
|
|
&passedCalcStress, |
57 |
|
|
&isError ); |
58 |
|
|
|
59 |
|
|
|
60 |
|
|
if( isError ){ |
61 |
|
|
sprintf( painCave.errMsg, |
62 |
|
|
"Error returned from the fortran force calculation.\n" ); |
63 |
|
|
painCave.isFatal = 1; |
64 |
|
|
simError(); |
65 |
|
|
} |
66 |
|
|
|
67 |
|
|
#ifdef IS_MPI |
68 |
|
|
sprintf( checkPointMsg, |
69 |
|
|
"returned from the force calculation.\n" ); |
70 |
|
|
MPIcheckPoint(); |
71 |
|
|
#endif // is_mpi |
72 |
|
|
|
73 |
|
|
} |
74 |
|
|
|
75 |
|
|
|
76 |
|
|
void ForceFields::initFortran(int ljMixPolicy, int useReactionField ){ |
77 |
|
|
|
78 |
|
|
int isError; |
79 |
|
|
|
80 |
|
|
isError = 0; |
81 |
|
|
initFortranFF( &ljMixPolicy, &useReactionField, &isError ); |
82 |
|
|
|
83 |
|
|
if(isError){ |
84 |
|
|
sprintf( painCave.errMsg, |
85 |
|
|
"ForceField error: There was an error initializing the forceField in fortran.\n" ); |
86 |
|
|
painCave.isFatal = 1; |
87 |
|
|
simError(); |
88 |
|
|
} |
89 |
|
|
|
90 |
|
|
|
91 |
|
|
#ifdef IS_MPI |
92 |
|
|
sprintf( checkPointMsg, "ForceField successfully initialized the fortran component list.\n" ); |
93 |
|
|
MPIcheckPoint(); |
94 |
|
|
#endif // is_mpi |
95 |
|
|
|
96 |
|
|
} |