DihedralTable Class Reference

#include <GromacsTopFile.h>

List of all members.

Public Member Functions

int size () const
int getIndex (const Real *c, int mult, int funct)
void addType (const char *typea, const char *typeb, const Real *c, int mult, int funct)
void getParams (int num, Real *c, int *mult, int *funct) const
int getParams (const char *typea, const char *typeb, const char *typec, const char *typed, int funct, Real *c, int *mult) const


Detailed Description

Definition at line 332 of file GromacsTopFile.h.


Member Function Documentation

void DihedralTable::addType ( const char *  typea,
const char *  typeb,
const Real c,
int  mult,
int  funct 
)

Definition at line 1169 of file GromacsTopFile.C.

References ResizeArray< Elem >::add().

Referenced by getIndex(), and GromacsTopFile::GromacsTopFile().

01170                                                               {
01171   float *cNew;
01172   int i;
01173 
01174   if(typea != NULL) typeaArray.add(strdup(typea));
01175   if(typeb != NULL) typebArray.add(strdup(typeb));
01176   functArray.add(funct);
01177 
01178   if(funct==1) multArray.add(mult);
01179   else multArray.add(0);
01180 
01181   if(funct==1 || funct==2) { /* for these we only need two params */
01182     cNew = new float[2];
01183     cNew[0]=c[0];
01184     cNew[1]=c[1];
01185   } else if(funct==3) { /* for RB we need all 6 */
01186     cNew = new float[6];
01187     for(i=0;i<6;i++) {
01188       cNew[i]=c[i];
01189     }
01190   } else { /* error */
01191     fprintf(stderr,"Bad function number %d - don't know what to do!\n",
01192             funct);
01193     exit(1);
01194   }
01195   
01196   /* now push the actual parameters */
01197   cArray.add(cNew);
01198 }

int DihedralTable::getIndex ( const Real c,
int  mult,
int  funct 
)

Definition at line 1041 of file GromacsTopFile.C.

References addType(), and j.

Referenced by GromacsTopFile::GromacsTopFile().

01041                                                                {
01042   /* check to see if it is in the table already */
01043   int i,j,jmax;
01044   if(funct==1 || funct==2) { /* for these we only need two params */
01045     jmax=2;
01046   } else { /* for RB we need all 6 */
01047     jmax=6;
01048   }
01049 
01050   for(i=0;i<cArray.size();i++) {
01051     int mismatch=0;
01052     if(mult != multArray[i]) continue;
01053     if(funct != functArray[i]) continue;
01054 
01055     for(j=0;j<jmax;j++) {
01056       if(fabs(c[j]-cArray[i][j])>=0.00001) {
01057         mismatch=1;
01058         break;
01059       }
01060     }
01061     if(!mismatch) {
01062       /* all of the parameters matched */
01063       return i;
01064     }
01065   }
01066   
01067   /* nope, it wasn't in the table add a new element! */
01068   addType(NULL,NULL,c,mult,funct);
01069   return cArray.size()-1;
01070 }

int DihedralTable::getParams ( const char *  typea,
const char *  typeb,
const char *  typec,
const char *  typed,
int  funct,
Real c,
int *  mult 
) const

Definition at line 1227 of file GromacsTopFile.C.

References j.

01229                                                                    {
01230   int i,j;
01231   const char *comparea, *compareb;
01232   
01233   if(funct == 1 || funct == 3) { /* for these, we use the inner atoms */
01234     comparea = typeb;
01235     compareb = typec;
01236   } else { /* use the outer atoms */
01237     comparea = typea;
01238     compareb = typed;
01239   }
01240 
01241   for(i=0;i<cArray.size();i++) {
01242     if(typeaArray[i] == NULL || typebArray[i] == NULL)
01243       continue; /* no atom types specified */
01244     if(functArray[i] != funct)
01245       continue; /* wrong function type */
01246 
01247     if( (0==strcmp(comparea,typeaArray[i]) &&  /* A--B */
01248          0==strcmp(compareb,typebArray[i]))    /*  or  */
01249      || (0==strcmp(compareb,typeaArray[i]) &&
01250          0==strcmp(comparea,typebArray[i]))    /* B--A */
01251           ) {
01252       if(funct==1 || funct==2) { /* for these we only need two params */
01253         c[0]=cArray[i][0];
01254         c[1]=cArray[i][1];
01255         if(funct==1) {
01256           *mult = multArray[i];
01257         }
01258       } else if(funct==3) { /* for RB we need all 6 */
01259         for(j=0;j<6;j++) {
01260           c[j]=cArray[i][j];
01261         }
01262       }
01263       return i;
01264     }
01265   }
01266   return -1;
01267 }

void DihedralTable::getParams ( int  num,
Real c,
int *  mult,
int *  funct 
) const

Definition at line 1129 of file GromacsTopFile.C.

Referenced by GromacsTopFile::getDihedralParams(), and GromacsTopFile::GromacsTopFile().

01129                                                                             {
01130   int i;
01131 
01132   *funct=functArray[num]; /* first set the function */
01133 
01134   if(*funct==1 || *funct==2) { /* for these we only need two params */
01135     c[0]=cArray[num][0];
01136     c[1]=cArray[num][1];
01137   } else if(*funct==3) { /* for RB we need all 6 */
01138     for(i=0;i<6;i++) {
01139       c[i]=cArray[num][i];
01140     }
01141   } else { /* error */
01142     fprintf(stderr,"Bad function number %d - don't know what to do!\n",
01143             *funct);
01144     exit(1);
01145   }
01146 
01147   if(*funct==1) { /* return the multiplicity */
01148     *mult=multArray[num];
01149   }
01150 }

int DihedralTable::size (  )  const [inline]

Definition at line 347 of file GromacsTopFile.h.

References ResizeArray< Elem >::size().

Referenced by GromacsTopFile::getNumDihedralParams().

00347 { return functArray.size(); }


The documentation for this class was generated from the following files:
Generated on Wed Nov 22 01:17:20 2017 for NAMD by  doxygen 1.4.7