ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/group/trunk/OOPSE/libmdtools/DUFF.cpp
(Generate patch)

Comparing trunk/OOPSE/libmdtools/DUFF.cpp (file contents):
Revision 561 by mmeineke, Fri Jun 20 20:29:36 2003 UTC vs.
Revision 950 by mmeineke, Fri Jan 16 15:01:14 2004 UTC

# Line 1 | Line 1
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;
# Line 15 | Line 15 | namespace TPE {  // restrict the access of the folowin
15   #include "mpiForceField.h"
16   #endif // is_mpi
17  
18 namespace TPE {  // restrict the access of the folowing to this file only.
18  
19 + // define some bond Types
20  
21 + #define FIXED_BOND    0
22 + #define HARMONIC_BOND 1
23 +
24 +
25 + namespace DUFF_NS {  // restrict the access of the folowing to this file only.
26 +
27 +
28    // Declare the structures that will be passed by MPI
29    
30    typedef struct{
# Line 25 | Line 32 | namespace TPE {  // restrict the access of the folowin
32      double mass;
33      double epslon;
34      double sigma;
35 +    double charge;
36      double dipole;
37      double w0;
38      double v0;
39 +    double v0p;
40 +    double rl;
41 +    double ru;
42 +    double rlp;
43 +    double rup;
44      int isSSD;
45 +    int isCharge;
46      int isDipole;
47      int ident;
48      int last;      //  0  -> default
# Line 39 | Line 53 | namespace TPE {  // restrict the access of the folowin
53    typedef struct{
54      char nameA[15];
55      char nameB[15];
42    char type[30];
56      double d0;
57 +    double k0;
58      int last;      //  0  -> default
59                     //  1  -> tells nodes to stop listening
60 +    int type;
61    } bondStruct;
62    
63    
# Line 130 | Line 145 | namespace TPE {  // restrict the access of the folowin
145          next->dipole   = info.dipole;
146          next->w0       = info.w0;
147          next->v0       = info.v0;
148 +        next->v0p      = info.v0p;
149 +        next->rl       = info.rl;
150 +        next->ru       = info.ru;
151 +        next->rlp      = info.rlp;
152 +        next->rup      = info.rup;
153          next->ident    = info.ident;
154        }
155      }
# Line 146 | Line 166 | namespace TPE {  // restrict the access of the folowin
166        info.dipole   = dipole;
167        info.w0       = w0;
168        info.v0       = v0;
169 +      info.v0p      = v0p;
170 +      info.rl       = rl;
171 +      info.ru       = ru;
172 +      info.rlp      = rlp;
173 +      info.rup      = rup;
174        info.ident    = ident;
175        info.last     = 0;
176      }
# Line 162 | Line 187 | namespace TPE {  // restrict the access of the folowin
187      double dipole;
188      double w0;
189      double v0;
190 +    double v0p;
191 +    double rl;
192 +    double ru;
193 +    double rlp;
194 +    double rup;
195      int ident;
196      LinkedAtomType* next;
197    };
# Line 172 | Line 202 | namespace TPE {  // restrict the access of the folowin
202        next = NULL;
203        nameA[0] = '\0';
204        nameB[0] = '\0';
175      type[0] = '\0';
205      }
206      ~LinkedBondType(){ if( next != NULL ) delete next; }
207  
# Line 207 | Line 236 | namespace TPE {  // restrict the access of the folowin
236          next = new LinkedBondType();
237          strcpy(next->nameA, info.nameA);
238          strcpy(next->nameB, info.nameB);
239 <        strcpy(next->type,  info.type);
239 >        next->type = info.type;
240          next->d0 = info.d0;
241 +        next->k0 = info.k0;
242        }
243      }
244      
# Line 216 | Line 246 | namespace TPE {  // restrict the access of the folowin
246      void duplicate( bondStruct &info ){
247        strcpy(info.nameA, nameA);
248        strcpy(info.nameB, nameB);
249 <      strcpy(info.type,  type);
249 >      info.type = type;
250        info.d0   = d0;
251 +      info.k0   = k0;
252        info.last = 0;
253      }
254  
# Line 226 | Line 257 | namespace TPE {  // restrict the access of the folowin
257  
258      char nameA[15];
259      char nameB[15];
260 <    char type[30];
260 >    int type;
261      double d0;
262 +    double k0;
263  
264      LinkedBondType* next;
265    };
# Line 410 | Line 442 | using namespace TPE;
442  
443   } // namespace
444  
445 < using namespace TPE;
445 > using namespace DUFF_NS;
446  
447  
448   //****************************************************************
# Line 424 | Line 456 | DUFF::DUFF(){
456    char* ffPath_env = "FORCE_PARAM_PATH";
457    char* ffPath;
458    char temp[200];
427  char errMsg[1000];
459  
460    headAtomType       = NULL;
461    currentAtomType    = NULL;
# Line 446 | Line 477 | DUFF::DUFF(){
477    // Init the atomStruct mpi type
478  
479    atomStruct atomProto; // mpiPrototype
480 <  int atomBC[3] = {15,6,4};  // block counts
480 >  int atomBC[3] = {15,12,5};  // block counts
481    MPI_Aint atomDspls[3];           // displacements
482    MPI_Datatype atomMbrTypes[3];    // member mpi types
483  
# Line 468 | Line 499 | DUFF::DUFF(){
499    // Init the bondStruct mpi type
500    
501    bondStruct bondProto; // mpiPrototype
502 <  int bondBC[3] = {60,1,1};  // block counts
502 >  int bondBC[3] = {30,2,2};  // block counts
503    MPI_Aint bondDspls[3];           // displacements
504    MPI_Datatype bondMbrTypes[3];    // member mpi types
505    
# Line 628 | Line 659 | void DUFF::readParams( void ){
659  
660   void DUFF::readParams( void ){
661  
631  int i, a, b, c, d;
662    int identNum;
633  char* atomA;
634  char* atomB;
635  char* atomC;
636  char* atomD;
663    
664    atomStruct atomInfo;
665    bondStruct bondInfo;
# Line 705 | Line 731 | void DUFF::readParams( void ){
731      while( currentAtomType != NULL ){
732        currentAtomType->duplicate( atomInfo );
733  
708
709
734        sendFrcStruct( &atomInfo, mpiAtomStructType );
735  
736        sprintf( checkPointMsg,
# Line 724 | Line 748 | void DUFF::readParams( void ){
748    else{
749      
750      // listen for node 0 to send out the force params
751 <    
751 >
752      MPIcheckPoint();
753  
754      headAtomType = new LinkedAtomType;
# Line 732 | Line 756 | void DUFF::readParams( void ){
756      
757      while( !atomInfo.last ){
758  
735
736
759        headAtomType->add( atomInfo );
760        
761        MPIcheckPoint();
# Line 754 | Line 776 | void DUFF::readParams( void ){
776    
777    int isGB = 0;
778    int isLJ = 1;
779 <  double GB_dummy = 0.0;
780 <  
781 <  
779 >  int isEAM =0;
780 >  int isCharge = 0;
781 >  double charge=0.0;
782 >    
783    currentAtomType = headAtomType->next;;
784    while( currentAtomType != NULL ){
785      
786 <    if(currentAtomType->isDipole) entry_plug->useDipole = 1;
786 >    if(currentAtomType->isDipole) entry_plug->useDipoles = 1;
787      if(currentAtomType->isSSD) {
788        entry_plug->useSticky = 1;
789 <      set_sticky_params( &(currentAtomType->w0), &(currentAtomType->v0));
789 >      set_sticky_params( &(currentAtomType->w0), &(currentAtomType->v0),
790 >                         &(currentAtomType->v0p),
791 >                         &(currentAtomType->rl), &(currentAtomType->ru),
792 >                         &(currentAtomType->rlp), &(currentAtomType->rup));
793      }
794  
795      if( currentAtomType->name[0] != '\0' ){
# Line 773 | Line 799 | void DUFF::readParams( void ){
799                   &(currentAtomType->isSSD),
800                   &(currentAtomType->isDipole),
801                   &isGB,
802 +                 &isEAM,
803 +                 &isCharge,
804                   &(currentAtomType->epslon),
805                   &(currentAtomType->sigma),
806 +                 &charge,
807                   &(currentAtomType->dipole),
808                   &isError );
809        if( isError ){
# Line 1189 | Line 1218 | void DUFF::initializeBonds( int nBonds, Bond** bondArr
1218        simError();
1219      }
1220      
1221 <    if( !strcmp( currentBondType->type, "fixed" ) ){
1222 <      
1221 >    switch( currentBondType->type ){
1222 >
1223 >    case FIXED_BOND:
1224 >            
1225        bondArray[i] = new ConstrainedBond( *the_atoms[a],
1226                                            *the_atoms[b],
1227                                            currentBondType->d0 );
1228        entry_plug->n_constraints++;
1229 +      break;
1230 +
1231 +    case HARMONIC_BOND:
1232 +      
1233 +      bondArray[i] = new HarmonicBond( *the_atoms[a],
1234 +                                       *the_atoms[b],
1235 +                                       currentBondType->d0,
1236 +                                       currentBondType->k0 );
1237 +      break;
1238 +      
1239 +    default:
1240 +
1241 +      break;
1242 +      // do nothing
1243      }
1244    }
1245   }
# Line 1259 | Line 1304 | void DUFF::initializeBends( int nBends, Bend** bendArr
1304          }
1305          
1306          gBend = new GhostBend( *the_atoms[a],
1307 <                               *the_atoms[b] );                        
1307 >                               *the_atoms[b]);
1308 >                                                                      
1309          gBend->setConstants( currentBendType->k1,
1310                               currentBendType->k2,
1311                               currentBendType->k3,
# Line 1275 | Line 1321 | void DUFF::initializeBends( int nBends, Bend** bendArr
1321                               currentBendType->k3,
1322                               currentBendType->t0 );
1323          bendArray[i] = qBend;
1324 <      }
1324 >      }      
1325      }
1326    }
1327   }
# Line 1382 | Line 1428 | int TPE::parseAtom( char *lineBuffer, int lineNum, ato
1428   }
1429  
1430  
1431 < int TPE::parseAtom( char *lineBuffer, int lineNum, atomStruct &info ){
1431 > int DUFF_NS::parseAtom( char *lineBuffer, int lineNum, atomStruct &info ){
1432  
1433    char* the_token;
1434    
# Line 1468 | Line 1514 | int TPE::parseAtom( char *lineBuffer, int lineNum, ato
1514        }
1515        
1516        info.v0 = atof( the_token );
1517 +      if( ( the_token = strtok( NULL, " \n\t,;" ) ) == NULL ){
1518 +        sprintf( painCave.errMsg,
1519 +                 "Error parseing AtomTypes: line %d\n", lineNum );
1520 +        painCave.isFatal = 1;
1521 +        simError();
1522 +      }
1523 +      
1524 +      info.v0p = atof( the_token );
1525 +
1526 +      if( ( the_token = strtok( NULL, " \n\t,;" ) ) == NULL ){
1527 +        sprintf( painCave.errMsg,
1528 +                 "Error parseing AtomTypes: line %d\n", lineNum );
1529 +        painCave.isFatal = 1;
1530 +        simError();
1531 +      }
1532 +      
1533 +      info.rl = atof( the_token );
1534 +
1535 +      if( ( the_token = strtok( NULL, " \n\t,;" ) ) == NULL ){
1536 +        sprintf( painCave.errMsg,
1537 +                 "Error parseing AtomTypes: line %d\n", lineNum );
1538 +        painCave.isFatal = 1;
1539 +        simError();
1540 +      }
1541 +      
1542 +      info.ru = atof( the_token );
1543 +
1544 +      if( ( the_token = strtok( NULL, " \n\t,;" ) ) == NULL ){
1545 +        sprintf( painCave.errMsg,
1546 +                 "Error parseing AtomTypes: line %d\n", lineNum );
1547 +        painCave.isFatal = 1;
1548 +        simError();
1549 +      }
1550 +      
1551 +      info.rlp = atof( the_token );
1552 +
1553 +      if( ( the_token = strtok( NULL, " \n\t,;" ) ) == NULL ){
1554 +        sprintf( painCave.errMsg,
1555 +                 "Error parseing AtomTypes: line %d\n", lineNum );
1556 +        painCave.isFatal = 1;
1557 +        simError();
1558 +      }
1559 +      
1560 +      info.rup = atof( the_token );
1561      }
1562 <    else info.v0 = info.w0 = 0.0;
1562 >    else info.v0 = info.w0 = info.v0p = info.rl = info.ru = info.rlp = info.rup = 0.0;
1563  
1564      return 1;
1565    }
1566    else return 0;
1567   }
1568  
1569 < int TPE::parseBond( char *lineBuffer, int lineNum, bondStruct &info ){
1569 > int DUFF_NS::parseBond( char *lineBuffer, int lineNum, bondStruct &info ){
1570  
1571    char* the_token;
1572 +  char bondType[30];
1573    
1574    the_token = strtok( lineBuffer, " \n\t,;" );
1575    if( the_token != NULL ){
# Line 1501 | Line 1592 | int TPE::parseBond( char *lineBuffer, int lineNum, bon
1592        simError();
1593      }
1594      
1595 <    strcpy( info.type, the_token );
1595 >    strcpy( bondType, the_token );
1596      
1597 <    if( !strcmp( info.type, "fixed" ) ){
1597 >    if( !strcmp( bondType, "fixed" ) ){
1598 >      info.type = FIXED_BOND;
1599 >      
1600        if( ( the_token = strtok( NULL, " \n\t,;" ) ) == NULL ){
1601          sprintf( painCave.errMsg,
1602                   "Error parseing BondTypes: line %d\n", lineNum );
# Line 1512 | Line 1605 | int TPE::parseBond( char *lineBuffer, int lineNum, bon
1605        }
1606        
1607        info.d0 = atof( the_token );
1608 +      
1609 +      info.k0=0.0;
1610      }
1611 +    else if( !strcmp( bondType, "harmonic" ) ){
1612 +      info.type = HARMONIC_BOND;
1613 +      
1614 +      if( ( the_token = strtok( NULL, " \n\t,;" ) ) == NULL ){
1615 +        sprintf( painCave.errMsg,
1616 +                 "Error parseing BondTypes: line %d\n", lineNum );
1617 +        painCave.isFatal = 1;
1618 +        simError();
1619 +      }
1620 +      
1621 +      info.d0 = atof( the_token );
1622 +
1623 +      if( ( the_token = strtok( NULL, " \n\t,;" ) ) == NULL ){
1624 +        sprintf( painCave.errMsg,
1625 +                 "Error parseing BondTypes: line %d\n", lineNum );
1626 +        painCave.isFatal = 1;
1627 +        simError();
1628 +      }
1629 +      
1630 +      info.k0 = atof( the_token );
1631 +    }
1632 +
1633      else{
1634        sprintf( painCave.errMsg,
1635                 "Unknown DUFF bond type \"%s\" at line %d\n",
1636 <               info.type,
1636 >               bondType,
1637                 lineNum );
1638        painCave.isFatal = 1;
1639        simError();
# Line 1528 | Line 1645 | int TPE::parseBend( char *lineBuffer, int lineNum, ben
1645   }
1646  
1647  
1648 < int TPE::parseBend( char *lineBuffer, int lineNum, bendStruct &info ){
1648 > int DUFF_NS::parseBend( char *lineBuffer, int lineNum, bendStruct &info ){
1649  
1650    char* the_token;
1651    
# Line 1616 | Line 1733 | int TPE::parseTorsion( char *lineBuffer, int lineNum,
1733    else return 0;
1734   }
1735  
1736 < int TPE::parseTorsion( char *lineBuffer, int lineNum, torsionStruct &info ){
1736 > int DUFF_NS::parseTorsion( char *lineBuffer, int lineNum, torsionStruct &info ){
1737    
1738    char*  the_token;
1739  

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines