NAMD
Public Member Functions | List of all members
DihedralTable Class Reference

#include <GromacsTopFile.h>

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< T >::add().

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

1170  {
1171  float *cNew;
1172  int i;
1173 
1174  if(typea != NULL) typeaArray.add(strdup(typea));
1175  if(typeb != NULL) typebArray.add(strdup(typeb));
1176  functArray.add(funct);
1177 
1178  if(funct==1) multArray.add(mult);
1179  else multArray.add(0);
1180 
1181  if(funct==1 || funct==2) { /* for these we only need two params */
1182  cNew = new float[2];
1183  cNew[0]=c[0];
1184  cNew[1]=c[1];
1185  } else if(funct==3) { /* for RB we need all 6 */
1186  cNew = new float[6];
1187  for(i=0;i<6;i++) {
1188  cNew[i]=c[i];
1189  }
1190  } else { /* error */
1191  fprintf(stderr,"Bad function number %d - don't know what to do!\n",
1192  funct);
1193  exit(1);
1194  }
1195 
1196  /* now push the actual parameters */
1197  cArray.add(cNew);
1198 }
int add(const Elem &elem)
Definition: ResizeArray.h:97
int DihedralTable::getIndex ( const Real c,
int  mult,
int  funct 
)

Definition at line 1041 of file GromacsTopFile.C.

References addType(), and ResizeArray< T >::size().

Referenced by GromacsTopFile::GromacsTopFile().

1041  {
1042  /* check to see if it is in the table already */
1043  int i,j,jmax;
1044  if(funct==1 || funct==2) { /* for these we only need two params */
1045  jmax=2;
1046  } else { /* for RB we need all 6 */
1047  jmax=6;
1048  }
1049 
1050  for(i=0;i<cArray.size();i++) {
1051  int mismatch=0;
1052  if(mult != multArray[i]) continue;
1053  if(funct != functArray[i]) continue;
1054 
1055  for(j=0;j<jmax;j++) {
1056  if(fabs(c[j]-cArray[i][j])>=0.00001) {
1057  mismatch=1;
1058  break;
1059  }
1060  }
1061  if(!mismatch) {
1062  /* all of the parameters matched */
1063  return i;
1064  }
1065  }
1066 
1067  /* nope, it wasn't in the table add a new element! */
1068  addType(NULL,NULL,c,mult,funct);
1069  return cArray.size()-1;
1070 }
void addType(const char *typea, const char *typeb, const Real *c, int mult, int funct)
int size(void) const
Definition: ResizeArray.h:127
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().

1129  {
1130  int i;
1131 
1132  *funct=functArray[num]; /* first set the function */
1133 
1134  if(*funct==1 || *funct==2) { /* for these we only need two params */
1135  c[0]=cArray[num][0];
1136  c[1]=cArray[num][1];
1137  } else if(*funct==3) { /* for RB we need all 6 */
1138  for(i=0;i<6;i++) {
1139  c[i]=cArray[num][i];
1140  }
1141  } else { /* error */
1142  fprintf(stderr,"Bad function number %d - don't know what to do!\n",
1143  *funct);
1144  exit(1);
1145  }
1146 
1147  if(*funct==1) { /* return the multiplicity */
1148  *mult=multArray[num];
1149  }
1150 }
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 ResizeArray< T >::size().

1229  {
1230  int i,j;
1231  const char *comparea, *compareb;
1232 
1233  if(funct == 1 || funct == 3) { /* for these, we use the inner atoms */
1234  comparea = typeb;
1235  compareb = typec;
1236  } else { /* use the outer atoms */
1237  comparea = typea;
1238  compareb = typed;
1239  }
1240 
1241  for(i=0;i<cArray.size();i++) {
1242  if(typeaArray[i] == NULL || typebArray[i] == NULL)
1243  continue; /* no atom types specified */
1244  if(functArray[i] != funct)
1245  continue; /* wrong function type */
1246 
1247  if( (0==strcmp(comparea,typeaArray[i]) && /* A--B */
1248  0==strcmp(compareb,typebArray[i])) /* or */
1249  || (0==strcmp(compareb,typeaArray[i]) &&
1250  0==strcmp(comparea,typebArray[i])) /* B--A */
1251  ) {
1252  if(funct==1 || funct==2) { /* for these we only need two params */
1253  c[0]=cArray[i][0];
1254  c[1]=cArray[i][1];
1255  if(funct==1) {
1256  *mult = multArray[i];
1257  }
1258  } else if(funct==3) { /* for RB we need all 6 */
1259  for(j=0;j<6;j++) {
1260  c[j]=cArray[i][j];
1261  }
1262  }
1263  return i;
1264  }
1265  }
1266  return -1;
1267 }
int size(void) const
Definition: ResizeArray.h:127
int DihedralTable::size ( ) const
inline

Definition at line 347 of file GromacsTopFile.h.

References ResizeArray< T >::size().

Referenced by GromacsTopFile::getNumDihedralParams().

347 { return functArray.size(); }
int size(void) const
Definition: ResizeArray.h:127

The documentation for this class was generated from the following files: