ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/group/trunk/OOPSE_old/src/mdtools/libmdCode/TraPPE_ExFF.cpp
(Generate patch)

Comparing trunk/OOPSE_old/src/mdtools/libmdCode/TraPPE_ExFF.cpp (file contents):
Revision 291 by mmeineke, Wed Mar 5 20:35:54 2003 UTC vs.
Revision 296 by mmeineke, Thu Mar 6 20:05:39 2003 UTC

# Line 9 | Line 9 | using namespace std;
9   #include "SRI.hpp"
10   #include "simError.h"
11  
12 + #include <fortranWrappers.hpp>
13 +
14   #ifdef IS_MPI
15   #include "mpiForceField.h"
16   #endif // is_mpi
# Line 83 | Line 85 | namespace TPE {  // restrict the access of the folowin
85   #endif
86  
87   } // namespace
86
87
88 // declaration of functions needed to wrap the fortran module
89
90 extern "C" {
91
92  void forcefactory_( char* forceName,
93                      int* status,
94                      void (*wrapFunction)( void (*p1)( int* ident,
95                                                        double* mass,
96                                                        double* epslon,
97                                                        double* sigma,
98                                                        int* isDipole,
99                                                        int* isSSd,
100                                                        double* dipole,
101                                                        double* w0,
102                                                        double* v0,
103                                                        int* status ),
104                                            void (*p2)( int *nLocal,
105                                                        int *identArray,
106                                                        int *isError ),
107                                            void (*p3)( double* positionArray,
108                                                        double* forceArray,
109                                                        double* potentialEnergy,
110                                                        double* tau,
111                                                        short int* doPotentialCalc,
112                                                        int* isError)),
113                      int forceNameLength );
114 }
115
116
117 void TPEfunctionWrapper( void (*p1)( int* ident, double* mass, double* epslon,
118                                     double* sigma, int* isDipole, int* isSSD,
119                                     double* dipole, double* w0, double* v0,
120                                     int* status ),
121                         void (*p2)( int *nLocal, int *identArray, int *isError ),
122                         void (*p3)( double* positionArray,double* forceArray,
123                                     double* potentialEnergy, double* tau,
124                                     short int* doPotentialCalc, int* isError ) );
88  
126 void (*newTPEtype)( int* ident, double* mass, double* epslon, double* sigma,
127                    int* isDipole, int* isSSD, double* dipole, double* w0,
128                    double* v0, int* status );
129
130 void (*initTPEfortran) ( int *nLocal, int *identArray, int *isError );
131
132 TraPPE_ExFF* currentTPEwrap;
133
89   using namespace TPE;
90  
91  
# Line 148 | Line 103 | TraPPE_ExFF::TraPPE_ExFF(){
103    char errMsg[1000];
104  
105    // do the funtion wrapping
106 <  currentTPEwrap = this;
152 <  wrapMe();
106 >  wrapMeFF( this );
107  
108  
109   #ifdef IS_MPI
# Line 315 | Line 269 | TraPPE_ExFF::~TraPPE_ExFF(){
269   #endif // is_mpi
270   }
271  
272 + void TraPPE_ExFF::doForces( int calcPot ){
273  
274 < void TraPPE_ExFF::wrapMe( void ){
275 <  
276 <  char* currentFF = "TraPPE_Ex";
277 <  int isError = 0;
278 <  
324 <  forcefactory_( currentFF, &isError, TPEfunctionWrapper, strlen(currentFF) );
274 >  int i, isError;
275 >  double* frc;
276 >  double* pos;
277 >  double* tau;
278 >  short int passedCalcPot = (short int)calcPot;
279  
280 <  if( isError ){
281 <    
280 >  // forces are zeroed here, before any are acumulated.
281 >  // NOTE: do not rezero the forces in Fortran.
282 >
283 >  for(i=0; i<entry_plug->n_atoms; i++){
284 >    entry_plug->atoms[i]->zeroForces();
285 >  }
286 >
287 >  frc = Atom::getFrcArray();
288 >  pos = Atom::getPosArray();
289 >  tau = entry_plug->tau;
290 >
291 >  isError = 0;
292 >  fortranForceLoop( pos, frc, &(entry_plug->lrPot), tau,
293 >                    &passedCalcPot, &isError );
294 >
295 >
296 >  if( isError ){
297      sprintf( painCave.errMsg,
298 <             "TraPPE_ExFF error: an error was returned from fortran when the "
330 <             "the functions were being wrapped.\n" );
298 >             "Error returned from the fortran force calculation.\n" );
299      painCave.isFatal = 1;
300      simError();
301    }
302  
303   #ifdef IS_MPI
304 <  sprintf( checkPointMsg, "TraPPE_ExFF functions succesfully wrapped." );
304 >  sprintf( checkPointMsg,
305 >           "successfully returned from the force calculation.\n" );
306    MPIcheckPoint();
307   #endif // is_mpi
308 +
309   }
310    
311 + void TraPPE_ExFF::initFortran( void ){
312 +  
313 +  int nLocal = entry_plug->n_atoms;
314 +  int *ident;
315 +  int isError;
316 +  int i;
317  
318 < void TPEfunctionWrapper( void (*p1)( int* ident, double* mass, double* epslon,
319 <                                     double* sigma, int* isDipole,
320 <                                     int* isSSD, double* dipole, double* w0,
321 <                                     double* v0, int* isError ),
322 <                         void (*p2)( int*, int*, int* ),
323 <                         void (*p3)( double*,double*,double*,double*,
324 <                                     short int*, int* ) ){
318 >  ident = new int[nLocal];
319 >
320 >  for(i=0; i<nLocal; i++){
321 >    ident[i] = entry_plug->atoms[i]->getIdent();
322 >  }
323 >
324 >  isError = 0;
325 >  initfortran( &nLocal, ident, &isError );
326 >  
327 >  if(isError){
328 >    sprintf( painCave.errMsg,
329 >             "TraPPE_ExFF error: There was an error initializing the component list in fortran.\n" );
330 >    painCave.isFatal = 1;
331 >    simError();
332 >  }
333 >
334    
335 + #ifdef IS_MPI
336 +  sprintf( checkPointMsg, "TraPPE_ExFF successfully initialized the fortran component list.\n" );
337 +  MPIcheckPoint();
338 + #endif // is_mpi
339    
340 <  newTPEtype = p1;
341 <  initTPEfortran = p2;
353 <  currentTPEwrap->setTPEfortran( p3 );
340 >  delete[] ident;
341 >
342   }
343 +
344  
345  
346  
# Line 580 | Line 569 | void TraPPE_ExFF::initializeAtoms( void ){
569    // call new A_types in fortran
570    
571    int isError;
572 +  
573 +  // dummy variables
574 +  
575 +  int isGB = 0;
576 +  int isLJ = 1;
577 +  
578 +  
579    currentAtomType = headAtomType;
580    while( currentAtomType != NULL ){
581      
# Line 589 | Line 585 | void TraPPE_ExFF::initializeAtoms( void ){
585                        &(currentAtomType->mass),
586                        &(currentAtomType->epslon),
587                        &(currentAtomType->sigma),
588 <                      &(currentAtomType->isDipole),
588 >                      &isLJ,
589                        &(currentAtomType->isSSD),
590 <                      &(currentAtomType->dipole),
590 >                      &(currentAtomType->isDipole),
591 >                      &isGB,
592                        &(currentAtomType->w0),
593                        &(currentAtomType->v0),
594 +                      &(currentAtomType->dipole),
595                        &isError );
596        if( isError ){
597          sprintf( painCave.errMsg,
# Line 715 | Line 713 | void TraPPE_ExFF::initializeAtoms( void ){
713    MPIcheckPoint();
714   #endif // is_mpi
715  
716 +  initFortran();
717 +  entry_plug->refreshSim();
718 +
719   }
720  
721   void TraPPE_ExFF::initializeBonds( bond_pair* the_bonds ){

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines