| 1 |
mmeineke |
561 |
#include <iostream> |
| 2 |
|
|
|
| 3 |
|
|
using namespace std; |
| 4 |
|
|
|
| 5 |
|
|
|
| 6 |
gezelter |
829 |
#include <stdlib.h> |
| 7 |
mmeineke |
377 |
|
| 8 |
|
|
#ifdef IS_MPI |
| 9 |
|
|
#include <mpi.h> |
| 10 |
|
|
#endif // is_mpi |
| 11 |
|
|
|
| 12 |
|
|
|
| 13 |
chuckv |
892 |
#ifdef PROFILE |
| 14 |
|
|
#include "mdProfile.hpp" |
| 15 |
|
|
#endif |
| 16 |
|
|
|
| 17 |
mmeineke |
377 |
#include "simError.h" |
| 18 |
|
|
#include "ForceFields.hpp" |
| 19 |
|
|
#include "Atom.hpp" |
| 20 |
|
|
#include "fortranWrappers.hpp" |
| 21 |
|
|
|
| 22 |
|
|
|
| 23 |
mmeineke |
420 |
void ForceFields::calcRcut( void ){ |
| 24 |
|
|
|
| 25 |
|
|
#ifdef IS_MPI |
| 26 |
|
|
double tempBig = bigSigma; |
| 27 |
mmeineke |
447 |
MPI_Allreduce( &tempBig, &bigSigma, 1, MPI_DOUBLE, MPI_MAX, |
| 28 |
|
|
MPI_COMM_WORLD); |
| 29 |
mmeineke |
420 |
#endif //is_mpi |
| 30 |
|
|
|
| 31 |
|
|
//calc rCut and rList |
| 32 |
|
|
|
| 33 |
mmeineke |
841 |
entry_plug->setDefaultRcut( 2.5 * bigSigma ); |
| 34 |
tim |
781 |
|
| 35 |
mmeineke |
420 |
} |
| 36 |
|
|
|
| 37 |
mmeineke |
377 |
void ForceFields::doForces( int calcPot, int calcStress ){ |
| 38 |
|
|
|
| 39 |
|
|
int i, isError; |
| 40 |
|
|
double* frc; |
| 41 |
|
|
double* pos; |
| 42 |
|
|
double* trq; |
| 43 |
|
|
double* A; |
| 44 |
mmeineke |
443 |
double* u_l;; |
| 45 |
mmeineke |
670 |
SimState* config; |
| 46 |
mmeineke |
377 |
|
| 47 |
|
|
short int passedCalcPot = (short int)calcPot; |
| 48 |
|
|
short int passedCalcStress = (short int)calcStress; |
| 49 |
|
|
|
| 50 |
gezelter |
484 |
// forces are zeroed here, before any are accumulated. |
| 51 |
mmeineke |
377 |
// NOTE: do not rezero the forces in Fortran. |
| 52 |
|
|
|
| 53 |
|
|
for(i=0; i<entry_plug->n_atoms; i++){ |
| 54 |
gezelter |
484 |
entry_plug->atoms[i]->zeroForces(); |
| 55 |
mmeineke |
377 |
} |
| 56 |
|
|
|
| 57 |
chuckv |
892 |
#ifdef PROFILE |
| 58 |
|
|
startProfile(pro7); |
| 59 |
|
|
#endif |
| 60 |
|
|
|
| 61 |
mmeineke |
423 |
for(i=0; i<entry_plug->n_mol; i++ ){ |
| 62 |
mmeineke |
428 |
entry_plug->molecules[i].calcForces(); |
| 63 |
mmeineke |
389 |
} |
| 64 |
|
|
|
| 65 |
chuckv |
892 |
#ifdef PROFILE |
| 66 |
|
|
endProfile( pro7 ); |
| 67 |
|
|
#endif |
| 68 |
|
|
|
| 69 |
mmeineke |
670 |
config = entry_plug->getConfiguration(); |
| 70 |
mmeineke |
597 |
|
| 71 |
mmeineke |
670 |
frc = config->getFrcArray(); |
| 72 |
|
|
pos = config->getPosArray(); |
| 73 |
|
|
trq = config->getTrqArray(); |
| 74 |
|
|
A = config->getAmatArray(); |
| 75 |
|
|
u_l = config->getUlArray(); |
| 76 |
mmeineke |
561 |
|
| 77 |
mmeineke |
377 |
isError = 0; |
| 78 |
|
|
entry_plug->lrPot = 0.0; |
| 79 |
mmeineke |
393 |
|
| 80 |
chuckv |
479 |
for (i=0; i<9; i++) { |
| 81 |
|
|
entry_plug->tau[i] = 0.0; |
| 82 |
|
|
} |
| 83 |
chuckv |
438 |
|
| 84 |
mmeineke |
841 |
|
| 85 |
chuckv |
892 |
#ifdef PROFILE |
| 86 |
|
|
startProfile(pro8); |
| 87 |
|
|
#endif |
| 88 |
|
|
|
| 89 |
mmeineke |
377 |
fortranForceLoop( pos, |
| 90 |
|
|
A, |
| 91 |
|
|
u_l, |
| 92 |
|
|
frc, |
| 93 |
|
|
trq, |
| 94 |
chuckv |
479 |
entry_plug->tau, |
| 95 |
mmeineke |
377 |
&(entry_plug->lrPot), |
| 96 |
|
|
&passedCalcPot, |
| 97 |
|
|
&passedCalcStress, |
| 98 |
|
|
&isError ); |
| 99 |
|
|
|
| 100 |
chuckv |
892 |
#ifdef PROFILE |
| 101 |
|
|
endProfile(pro8); |
| 102 |
|
|
#endif |
| 103 |
mmeineke |
841 |
|
| 104 |
|
|
|
| 105 |
mmeineke |
377 |
if( isError ){ |
| 106 |
|
|
sprintf( painCave.errMsg, |
| 107 |
|
|
"Error returned from the fortran force calculation.\n" ); |
| 108 |
|
|
painCave.isFatal = 1; |
| 109 |
|
|
simError(); |
| 110 |
|
|
} |
| 111 |
|
|
|
| 112 |
|
|
#ifdef IS_MPI |
| 113 |
|
|
sprintf( checkPointMsg, |
| 114 |
|
|
"returned from the force calculation.\n" ); |
| 115 |
|
|
MPIcheckPoint(); |
| 116 |
|
|
#endif // is_mpi |
| 117 |
mmeineke |
597 |
|
| 118 |
mmeineke |
377 |
|
| 119 |
|
|
} |
| 120 |
|
|
|
| 121 |
|
|
|
| 122 |
|
|
void ForceFields::initFortran(int ljMixPolicy, int useReactionField ){ |
| 123 |
|
|
|
| 124 |
|
|
int isError; |
| 125 |
|
|
|
| 126 |
|
|
isError = 0; |
| 127 |
|
|
initFortranFF( &ljMixPolicy, &useReactionField, &isError ); |
| 128 |
|
|
|
| 129 |
|
|
if(isError){ |
| 130 |
|
|
sprintf( painCave.errMsg, |
| 131 |
|
|
"ForceField error: There was an error initializing the forceField in fortran.\n" ); |
| 132 |
|
|
painCave.isFatal = 1; |
| 133 |
|
|
simError(); |
| 134 |
|
|
} |
| 135 |
|
|
|
| 136 |
|
|
|
| 137 |
|
|
#ifdef IS_MPI |
| 138 |
|
|
sprintf( checkPointMsg, "ForceField successfully initialized the fortran component list.\n" ); |
| 139 |
|
|
MPIcheckPoint(); |
| 140 |
|
|
#endif // is_mpi |
| 141 |
|
|
|
| 142 |
|
|
} |