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; |
20 |
– |
double* tau; |
42 |
|
double* A; |
43 |
< |
double* u_l; |
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 acumulated. |
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(); |
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 |
< |
|
40 |
< |
tau = entry_plug->tau; |
41 |
< |
|
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 |
< |
tau, |
78 |
> |
entry_plug->tau, |
79 |
|
&(entry_plug->lrPot), |
80 |
|
&passedCalcPot, |
81 |
|
&passedCalcStress, |
82 |
|
&isError ); |
83 |
|
|
55 |
– |
|
84 |
|
if( isError ){ |
85 |
|
sprintf( painCave.errMsg, |
86 |
|
"Error returned from the fortran force calculation.\n" ); |