| 1 | 
< | 
#include <cstdlib> | 
| 2 | 
< | 
#include <cstdio> | 
| 3 | 
< | 
#include <cstring> | 
| 1 | 
> | 
#include <stdlib.h> | 
| 2 | 
> | 
#include <stdio.h> | 
| 3 | 
> | 
#include <string.h> | 
| 4 | 
  | 
 | 
| 5 | 
  | 
#include <iostream> | 
| 6 | 
  | 
using namespace std; | 
| 30 | 
  | 
    double mass; | 
| 31 | 
  | 
    double lattice_constant; | 
| 32 | 
  | 
    double eam_drho;  // The distance between each of the points indexed by rho. | 
| 33 | 
+ | 
    double eam_rcut;  // The cutoff radius for eam. | 
| 34 | 
  | 
    double eam_dr;    // The distance between each of the rho points.     | 
| 35 | 
  | 
    int eam_nrho;  // Number of points indexed by rho | 
| 36 | 
  | 
    int eam_nr;    // The number of points based on r (Both Phi(r) and Rho(r)). | 
| 36 | 
– | 
    double eam_rcut;  // The cutoff radius for eam. | 
| 37 | 
  | 
    int eam_ident; // Atomic number | 
| 38 | 
  | 
    int ident; | 
| 39 | 
  | 
    int last;      //  0  -> default | 
| 76 | 
  | 
    void add( atomStruct &info, double *the_eam_rvals, | 
| 77 | 
  | 
              double *the_eam_rhovals,double *the_eam_Frhovals ){ | 
| 78 | 
  | 
 | 
| 79 | 
– | 
      int i; | 
| 80 | 
– | 
 | 
| 79 | 
  | 
      // check for duplicates | 
| 80 | 
  | 
       | 
| 81 | 
  | 
      if( !strcmp( info.name, name ) ){ | 
| 162 | 
  | 
  char* ffPath_env = "FORCE_PARAM_PATH"; | 
| 163 | 
  | 
  char* ffPath; | 
| 164 | 
  | 
  char temp[200]; | 
| 167 | 
– | 
  char errMsg[1000]; | 
| 165 | 
  | 
 | 
| 166 | 
  | 
  headAtomType = NULL; | 
| 167 | 
  | 
  currentAtomType = NULL; | 
| 168 | 
  | 
 | 
| 169 | 
+ | 
  // Set eamRcut to 0.0 | 
| 170 | 
+ | 
  eamRcut = 0.0; | 
| 171 | 
+ | 
 | 
| 172 | 
  | 
  // do the funtion wrapping | 
| 173 | 
  | 
  wrapMeFF( this ); | 
| 174 | 
  | 
 | 
| 179 | 
  | 
  // Init the atomStruct mpi type | 
| 180 | 
  | 
 | 
| 181 | 
  | 
  atomStruct atomProto; // mpiPrototype | 
| 182 | 
< | 
  int atomBC[3] = {15,4,6};  // block counts | 
| 182 | 
> | 
  int atomBC[3] = {15,5,5};  // block counts | 
| 183 | 
  | 
  MPI_Aint atomDspls[3];           // displacements | 
| 184 | 
  | 
  MPI_Datatype atomMbrTypes[3];    // member mpi types | 
| 185 | 
  | 
 | 
| 266 | 
  | 
 | 
| 267 | 
  | 
 | 
| 268 | 
  | 
void EAM_FF::calcRcut( void ){ | 
| 269 | 
< | 
  double tempEamRcut; | 
| 270 | 
< | 
 | 
| 271 | 
< | 
  entry_plug->setRcut(eamRcut); | 
| 269 | 
> | 
   | 
| 270 | 
> | 
#ifdef IS_MPI | 
| 271 | 
> | 
  double tempEamRcut = eamRcut; | 
| 272 | 
> | 
  MPI_Allreduce( &tempEamRcut, &eamRcut, 1, MPI_DOUBLE, MPI_MAX, | 
| 273 | 
> | 
                 MPI_COMM_WORLD); | 
| 274 | 
> | 
#endif  //is_mpi | 
| 275 | 
> | 
  entry_plug->setDefaultRcut(eamRcut); | 
| 276 | 
  | 
} | 
| 277 | 
  | 
 | 
| 278 | 
  | 
 | 
| 302 | 
  | 
  info.last = 1; // initialize last to have the last set.  | 
| 303 | 
  | 
                 // if things go well, last will be set to 0 | 
| 304 | 
  | 
 | 
| 301 | 
– | 
  int i; | 
| 305 | 
  | 
  int identNum; | 
| 306 | 
  | 
  double *eam_rvals;    // Z of r values | 
| 307 | 
  | 
  double *eam_rhovals;  // rho of r values | 
| 407 | 
  | 
    MPIcheckPoint(); | 
| 408 | 
  | 
 | 
| 409 | 
  | 
    headAtomType = new LinkedAtomType; | 
| 410 | 
< | 
    recieveFrcStruct( &info, mpiAtomStructType ); | 
| 410 | 
> | 
    receiveFrcStruct( &info, mpiAtomStructType ); | 
| 411 | 
  | 
 | 
| 412 | 
  | 
    while( !info.last ){ | 
| 413 | 
  | 
       | 
| 433 | 
  | 
       | 
| 434 | 
  | 
      MPIcheckPoint(); | 
| 435 | 
  | 
 | 
| 436 | 
< | 
      recieveFrcStruct( &info, mpiAtomStructType ); | 
| 436 | 
> | 
      receiveFrcStruct( &info, mpiAtomStructType ); | 
| 437 | 
  | 
 | 
| 438 | 
  | 
 | 
| 439 | 
  | 
    } | 
| 449 | 
  | 
  int isDipole = 0; | 
| 450 | 
  | 
  int isSSD = 0; | 
| 451 | 
  | 
  int isGB = 0; | 
| 452 | 
< | 
  int isEAM= 1; | 
| 452 | 
> | 
  int isEAM = 1; | 
| 453 | 
> | 
  int isCharge = 0; | 
| 454 | 
  | 
  double dipole = 0.0; | 
| 455 | 
+ | 
  double charge = 0.0; | 
| 456 | 
  | 
  double eamSigma = 0.0; | 
| 457 | 
  | 
  double eamEpslon = 0.0; | 
| 458 | 
  | 
   | 
| 467 | 
  | 
                 &isDipole, | 
| 468 | 
  | 
                 &isGB, | 
| 469 | 
  | 
                 &isEAM, | 
| 470 | 
+ | 
                 &isCharge, | 
| 471 | 
  | 
                 &eamEpslon, | 
| 472 | 
  | 
                 &eamSigma, | 
| 473 | 
+ | 
                 &charge, | 
| 474 | 
  | 
                 &dipole, | 
| 475 | 
  | 
                 &isError ); | 
| 476 | 
  | 
      if( isError ){ | 
| 485 | 
  | 
  } | 
| 486 | 
  | 
       | 
| 487 | 
  | 
  entry_plug->useLJ = 0; | 
| 488 | 
< | 
 | 
| 488 | 
> | 
  entry_plug->useEAM = 1; | 
| 489 | 
  | 
  // Walk down again and send out EAM type | 
| 490 | 
  | 
  currentAtomType = headAtomType->next; | 
| 491 | 
  | 
  while( currentAtomType != NULL ){ | 
| 492 | 
  | 
     | 
| 493 | 
  | 
    if( currentAtomType->name[0] != '\0' ){ | 
| 494 | 
  | 
      isError = 0; | 
| 495 | 
< | 
      cerr << "Calling newEAMtype for type "<<currentAtomType->eam_ident <<"\n"; | 
| 495 | 
> | 
 | 
| 496 | 
  | 
      newEAMtype( &(currentAtomType->lattice_constant), | 
| 497 | 
  | 
                  &(currentAtomType->eam_nrho), | 
| 498 | 
  | 
                  &(currentAtomType->eam_drho), | 
| 504 | 
  | 
                  currentAtomType->eam_Frhovals, | 
| 505 | 
  | 
                  &(currentAtomType->eam_ident), | 
| 506 | 
  | 
                  &isError); | 
| 507 | 
< | 
      cerr << "Returned from newEAMtype\n"; | 
| 507 | 
> | 
 | 
| 508 | 
  | 
      if( isError ){ | 
| 509 | 
  | 
        sprintf( painCave.errMsg, | 
| 510 | 
  | 
                 "Error initializing the \"%s\" atom type in fortran EAM\n", | 
| 524 | 
  | 
  MPIcheckPoint(); | 
| 525 | 
  | 
#endif // is_mpi | 
| 526 | 
  | 
 | 
| 520 | 
– | 
  cerr << "Done sending eamtypes to fortran\n"; | 
| 527 | 
  | 
 | 
| 528 | 
+ | 
 | 
| 529 | 
  | 
} | 
| 530 | 
  | 
 | 
| 531 | 
  | 
 | 
| 532 | 
  | 
void EAM_FF::initializeAtoms( int nAtoms, Atom** the_atoms ){ | 
| 533 | 
  | 
   | 
| 534 | 
  | 
  int i; | 
| 535 | 
< | 
 | 
| 535 | 
> | 
   | 
| 536 | 
  | 
  // initialize the atoms | 
| 537 | 
  | 
   | 
| 531 | 
– | 
 | 
| 532 | 
– | 
  Atom* thisAtom; | 
| 533 | 
– | 
 | 
| 538 | 
  | 
  for( i=0; i<nAtoms; i++ ){ | 
| 539 | 
  | 
     | 
| 540 | 
  | 
    currentAtomType = headAtomType->find( the_atoms[i]->getType() ); | 
| 548 | 
  | 
     | 
| 549 | 
  | 
    the_atoms[i]->setMass( currentAtomType->mass ); | 
| 550 | 
  | 
    the_atoms[i]->setIdent( currentAtomType->ident ); | 
| 547 | 
– | 
    the_atoms[i]->setEAM(); | 
| 551 | 
  | 
 | 
| 552 | 
+ | 
    if (eamRcut < currentAtomType->eam_rcut) eamRcut = currentAtomType->eam_rcut; | 
| 553 | 
+ | 
     | 
| 554 | 
  | 
  } | 
| 555 | 
  | 
} | 
| 556 | 
  | 
 | 
| 1018 | 
  | 
    myEam_rhovals[j+0] = atof( the_token ); | 
| 1019 | 
  | 
 | 
| 1020 | 
  | 
    // Value 2 | 
| 1021 | 
< | 
    if ( (the_token = strtok( eam_read_buffer, " \n\t,;")) == NULL){ | 
| 1021 | 
> | 
    if ( (the_token = strtok( NULL, " \n\t,;")) == NULL){ | 
| 1022 | 
  | 
      sprintf( painCave.errMsg,  | 
| 1023 | 
  | 
               "Error parseing EAM nrho: line in %s\n", eamPotFile ); | 
| 1024 | 
  | 
      painCave.isFatal = 1; | 
| 1028 | 
  | 
    myEam_rhovals[j+1] = atof( the_token ); | 
| 1029 | 
  | 
 | 
| 1030 | 
  | 
    // Value 3 | 
| 1031 | 
< | 
    if ( (the_token = strtok( eam_read_buffer, " \n\t,;")) == NULL){ | 
| 1031 | 
> | 
    if ( (the_token = strtok( NULL, " \n\t,;")) == NULL){ | 
| 1032 | 
  | 
      sprintf( painCave.errMsg,  | 
| 1033 | 
  | 
               "Error parseing EAM nrho: line in %s\n", eamPotFile ); | 
| 1034 | 
  | 
      painCave.isFatal = 1; | 
| 1038 | 
  | 
    myEam_rhovals[j+2] = atof( the_token ); | 
| 1039 | 
  | 
 | 
| 1040 | 
  | 
    // Value 4 | 
| 1041 | 
< | 
    if ( (the_token = strtok( eam_read_buffer, " \n\t,;")) == NULL){ | 
| 1041 | 
> | 
    if ( (the_token = strtok( NULL, " \n\t,;")) == NULL){ | 
| 1042 | 
  | 
      sprintf( painCave.errMsg,  | 
| 1043 | 
  | 
               "Error parseing EAM nrho: line in %s\n", eamPotFile ); | 
| 1044 | 
  | 
      painCave.isFatal = 1; | 
| 1048 | 
  | 
    myEam_rhovals[j+3] = atof( the_token ); | 
| 1049 | 
  | 
 | 
| 1050 | 
  | 
    // Value 5 | 
| 1051 | 
< | 
    if ( (the_token = strtok( eam_read_buffer, " \n\t,;")) == NULL){ | 
| 1051 | 
> | 
    if ( (the_token = strtok( NULL, " \n\t,;")) == NULL){ | 
| 1052 | 
  | 
      sprintf( painCave.errMsg,  | 
| 1053 | 
  | 
               "Error parseing EAM nrho: line in %s\n", eamPotFile ); | 
| 1054 | 
  | 
      painCave.isFatal = 1; | 
| 1056 | 
  | 
    } | 
| 1057 | 
  | 
   | 
| 1058 | 
  | 
    myEam_rhovals[j+4] = atof( the_token ); | 
| 1059 | 
< | 
 | 
| 1059 | 
> | 
  | 
| 1060 | 
  | 
  } | 
| 1061 | 
  | 
  *eam_rvals = myEam_rvals; | 
| 1062 | 
  | 
  *eam_rhovals = myEam_rhovals; |