Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Class Members | File Members

GromacsTopFile Class Reference

#include <GromacsTopFile.h>

List of all members.

Public Member Functions

 GromacsTopFile (char *filename)
char * getSystemName () const
int getNumAtoms () const
int getNumBonds () const
int getNumAngles () const
int getNumDihedrals () const
int getNumAtomParams () const
int getNumBondParams () const
int getNumAngleParams () const
int getNumDihedralParams () const
void getAtom (int num, int *residue_number, char *residue_name, char *atom_name, char *atom_type, int *atom_typenum, Real *charge, Real *mass) const
void getAtomParams (int num, char *type) const
void getBond (int num, int *atomi, int *atomj, int *bondtype) const
void getBondParams (int num, Real *b0, Real *kB, int *funct) const
void getAngle (int num, int *atomi, int *atomj, int *atomk, int *angletype) const
void getAngleParams (int num, Real *th0, Real *kth, int *funct) const
void getDihedral (int num, int *atomi, int *atomj, int *atomk, int *atoml, int *type) const
void getDihedralParams (int num, Real *c, int *mult, int *funct) const
void getVDWParams (int typea, int typeb, Real *c6, Real *c12, Real *c6pair, Real *c7) const


Constructor & Destructor Documentation

GromacsTopFile::GromacsTopFile char *  filename  ) 
 

Definition at line 43 of file GromacsTopFile.C.

References ResizeArray< Elem >::add(), AtomTable::addType(), DihedralTable::addType(), AngleTable::addType(), BondTable::addType(), VDWTable::addType(), ANGLES, ANGLETYPES, ATOMS, ATOMTYPES, BONDS, BONDTYPES, DEFAULTS, DIHEDRALS, DIHEDRALTYPES, DihedralTable::getIndex(), AngleTable::getIndex(), BondTable::getIndex(), AtomTable::getParams(), DihedralTable::getParams(), AngleTable::getParams(), BondTable::getParams(), j, JOULES_PER_CALORIE, LINESIZE, LONGNAMESIZE, MOLECULES, MOLECULETYPE, NAMD_die(), NAMESIZE, NONBOND, PI, ResizeArray< Elem >::size(), and SYSTEM.

00043                                              {
00044   /* open the file */
00045   FILE *f = fopen(filename,"r");
00046   char buf[LINESIZE];
00047   char modename[20];
00048   int mode;
00049   if(f==NULL) {
00050     sprintf(buf,"Error opening file '%s'",filename);
00051     NAMD_die(buf);
00052   }
00053 
00054   /* really bad parser XXX probably just works on the files we
00055      happen to have REWRITE THIS SOON.  It should allow for \- line
00056      continuations, check for errors in the file, etc. */
00057   while(fgets(buf,LINESIZE-1,f)) {
00058     char testchar;
00059     int i,j;
00060 
00061     /* defaults */
00062     int nbfunc, combrule;
00063     char genpairs[20];
00064     
00065     /* atom buffers */
00066     int num, resnum, chargegp, typenum;
00067     char type[NAMESIZE+1], restype[NAMESIZE+1], atomname[NAMESIZE+1];
00068     char particletype[NAMESIZE+1];
00069     float charge, mass, c6, c12, junkf;
00070 
00071     /* moltype buffers */
00072     int nrexcl;
00073     char molname[LONGNAMESIZE+1];
00074 
00075     /* molInst buffers */
00076     int copies;
00077     MolInst *moleculeinstance;
00078 
00079     /* general atomset buffers */
00080     int atomi, atomj, atomk, atoml;
00081     char typea[NAMESIZE+1],typeb[NAMESIZE+1],
00082       typec[NAMESIZE+1],typed[NAMESIZE+1];
00083     const char *tmptypea,*tmptypeb,*tmptypec,*tmptyped;
00084     int funct, index;
00085     float c0,c1;
00086     
00087     /* bonds */
00088     float b0,kB,th0,kth;
00089 
00090     /* dihedrals */
00091     float c[6];
00092     int mult=0;
00093 
00094     /* check for comments */
00095     if(sscanf(buf," %c",&testchar)==1) {
00096       if(testchar == ';') continue;
00097     }
00098     else { /* this is a blank line */
00099       continue;
00100     }
00101 
00102     /* check for a new mode */
00103     if(sscanf(buf," [ %19[^] ] ]",modename)==1) {
00104       /* switch the mode */
00105       if(0==strcmp(modename,"atoms"))              mode = ATOMS;
00106       else if(0==strcmp(modename,"atomtypes"))     mode = ATOMTYPES;
00107       else if(0==strcmp(modename,"moleculetype"))  mode = MOLECULETYPE;
00108       else if(0==strcmp(modename,"molecules"))     mode = MOLECULES;
00109       else if(0==strcmp(modename,"system"))        mode = SYSTEM;
00110       else if(0==strcmp(modename,"bonds"))         mode = BONDS;
00111       else if(0==strcmp(modename,"bondtypes"))     mode = BONDTYPES;
00112       else if(0==strcmp(modename,"angles"))        mode = ANGLES;
00113       else if(0==strcmp(modename,"angletypes"))    mode = ANGLETYPES;
00114       else if(0==strcmp(modename,"dihedrals"))     mode = DIHEDRALS;
00115       else if(0==strcmp(modename,"dihedraltypes")) mode = DIHEDRALTYPES;
00116       else if(0==strcmp(modename,"defaults"))      mode = DEFAULTS;
00117       else if(0==strcmp(modename,"nonbond_params")) mode = NONBOND;
00118       else {    
00119         fprintf(stderr,"Warning: unknown mode %s\n",modename);
00120         mode = UNKNOWN;
00121       }
00122 
00123       continue;
00124     }
00125 
00126     /* now do the appropriate thing based on the current mode */
00127     switch(mode) {
00128     case SYSTEM:
00129       systemName = strdup(buf);
00130       break;
00131 
00132     case DEFAULTS:
00133       i = sscanf(buf," %d %d %20s %f %f",
00134                  &nbfunc,&combrule,genpairs,&fudgeLJ,&fudgeQQ);
00135       if(i < 3) { // didn't get enough parameters 
00136         fprintf(stderr,"syntax error in DEFAULTS\n");
00137         exit(1);
00138       }
00139       if(nbfunc != 1) { // I don't know how it works with nbfunc=2
00140         fprintf(stderr,"Non-bonded function != 1 unsupported in DEFAULTS\n");
00141         exit(1);
00142       }
00143       if(combrule != 1) { // same here
00144         fprintf(stderr,"Combination rule != 1 unsupported in DEFAULTS\n");
00145         exit(1);
00146       }
00147       if(0==strcmp(genpairs,"yes")) {
00148         genPairs=1;
00149         if(i!=5) {
00150           fprintf(stderr,"syntax error in DEFAULTS\n");
00151           exit(1);
00152         }
00153         // else fudgeLJ and fudgeQQ got written automatically
00154       }
00155       else genPairs=0;
00156 
00157       break;
00158 
00159     case NONBOND:
00160       if(5 != sscanf(buf," %5s %5s %d %f %f",
00161                      typea, typeb, &funct, &c6, &c12)) {
00162         fprintf(stderr,"Syntax error in NONBOND\n");
00163         exit(1);
00164       }
00165       // convert kJ/mol*nm6 to kcal/mol*A6 and ..12 ..12
00166       c6 =  c6/JOULES_PER_CALORIE*1E6;
00167       c12= c12/JOULES_PER_CALORIE*1E12;
00168       vdwTable.addType(typea,typeb,c6,c12);
00169       break;
00170 
00171     case BONDS:
00172       i = sscanf(buf," %d %d %d %f %f",
00173                  &atomi,&atomj,&funct,&c0,&c1);
00174       atomi--; // shift right away to a zero-indexing
00175       atomj--;
00176       if(i==3) {
00177        tmptypea = genericMols[genericMols.size()-1]->getAtom(atomi)->getType();
00178        tmptypeb = genericMols[genericMols.size()-1]->getAtom(atomj)->getType();
00179         /* find the index and parameters */
00180         index = bondTable.getParams(tmptypea, tmptypeb, funct, &b0, &kB);
00181         if(index==-1) {
00182           fprintf(stderr,"Required bondtype %s--%s (function %d) not found.\n",
00183                   tmptypea,tmptypeb,funct);
00184           exit(1);
00185         }
00186       }
00187       else if(i==5) {
00188         /* first set the values of b0 and kB correctly */
00189         b0 = c0*10; /* convert nm to A */
00190         if(funct==1) { /* harmonic potential */
00191           /* convert kJ/nm2 to kcal/A2 and use E=kx2 instead of half that. */
00192           kB = c1/JOULES_PER_CALORIE/100/2;
00193         }
00194         else if(funct==2) { /* special fourth-order potential */
00195           /* convert to the normal harmonic constant and kJ/nm2 to kcal/A2 */
00196           kB = 2*c1*c0*c0/JOULES_PER_CALORIE/100;
00197           kB /= 2; /* use the NAMD system where E=kx2 */
00198         }
00199         else {
00200           fprintf(stderr,"I don't know what funct=%d means in BONDS\n",funct);
00201           exit(1);
00202         }
00203         /* look up the index */
00204         index = bondTable.getIndex(b0,kB,funct);
00205       }
00206       else {
00207         fprintf(stderr,"Syntax error in BONDS\n");
00208         exit(1);
00209       }
00210 
00211       genericMols[genericMols.size()-1]->addBond(atomi,atomj,index);
00212       break;
00213       
00214     case BONDTYPES:
00215       if(5 != sscanf(buf," %5s %5s %d %f %f",
00216                      typea,typeb,&funct,&c0,&c1)) {
00217         fprintf(stderr,"Syntax error in BONDTYPES\n");
00218         exit(1);
00219       }
00220 
00221       /* first set the values of b0 and kB correctly */
00222       b0 = c0*10; /* convert nm to A */
00223       if(funct==1) { /* harmonic potential */
00224         /* convert kJ/nm2 to kcal/A2 and use E=kx2 instead of half that. */
00225         kB = c1/JOULES_PER_CALORIE/100/2;
00226       }
00227       else if(funct==2) { /* special fourth-order potential */
00228         /* convert to the normal harmonic constant and kJ/nm2 to kcal/A2 */
00229         kB = 2*c1*c0*c0/JOULES_PER_CALORIE/100;
00230         kB /= 2; /* use the NAMD system where E=kx2 */
00231       }
00232       else {
00233  fprintf(stderr,"I don't know what funct=%d means in BONDTYPES\n",funct);
00234         exit(1);
00235       }
00236 
00237       bondTable.addType(typea,typeb,b0,kB,funct);
00238       break;
00239 
00240     case ANGLES:
00241       i = sscanf(buf," %d %d %d %d %f %f",
00242                      &atomi,&atomj,&atomk,&funct,&c0,&c1);
00243       atomi--; // shift right away to a zero-indexing
00244       atomj--;
00245       atomk--;
00246       if(i == 4) { /* we have to look up the last two parameters */
00247        tmptypea = genericMols[genericMols.size()-1]->getAtom(atomi)->getType();
00248        tmptypeb = genericMols[genericMols.size()-1]->getAtom(atomj)->getType();
00249        tmptypec = genericMols[genericMols.size()-1]->getAtom(atomk)->getType();
00250         /* find the index and parameters */
00251         index = angleTable.getParams(tmptypea, tmptypeb, tmptypec,
00252                                         funct, &th0, &kth);
00253         if(index==-1) {
00254           fprintf(stderr,
00255                   "Required angletype %s--%s--%s (function %d) not found.\n",
00256                   tmptypea,tmptypeb,tmptypec,funct);
00257           exit(1);
00258         }
00259       }
00260       else if(i == 6) {
00261         /* first set the values of th0 and kth correctly */
00262         if(funct == 1) {
00263           th0 = c0; /* both are in degrees */
00264           kth = c1/JOULES_PER_CALORIE/2; /* convert kJ/rad2 to kcal/rad2 and use E=kx2 */
00265         }
00266         else if(funct == 2) {
00267           th0 = c0; /* both are in degrees */
00268           /* convert G96 kJ to kcal/rad2 and use E=kx2 */
00269           kth = sin(th0*PI/180)*sin(th0*PI/180)*c1/JOULES_PER_CALORIE/2;
00270         }
00271         else {
00272           fprintf(stderr,"I don't know what funct=%d means in ANGLES\n",funct);
00273           exit(1);
00274         }
00275         /* add the angle type to our table */
00276         index = angleTable.getIndex(th0,kth,funct);
00277       }
00278       else {
00279         fprintf(stderr,"Syntax error (%d args) in ANGLES: %s\n",i,buf);
00280         exit(1);
00281       }
00282 
00283       /* add the angle to our table */
00284       genericMols[genericMols.size()-1]->addAngle(atomi,atomj,atomk,index);
00285       break;
00286 
00287     case ANGLETYPES:
00288       if(6 != sscanf(buf," %5s %5s %5s %d %f %f",
00289                      typea,typeb,typec,&funct,&c0,&c1)) {
00290         fprintf(stderr,"Syntax error in ANGLETYPES\n");
00291         exit(1);
00292       }
00293       /* first set the values of th0 and kth correctly */
00294       if(funct == 1) {
00295         th0 = c0; /* both are in degrees */
00296         kth = c1/JOULES_PER_CALORIE/2; /* convert kJ/rad2 to kcal/rad2 and use E=kx2 */
00297       }
00298       else if(funct == 2) {
00299         th0 = c0; /* both are in degrees */
00300         /* convert G96 kJ to kcal/rad2 and use E=kx2 */
00301         kth = sin(th0*PI/180)*sin(th0*PI/180)*c1/JOULES_PER_CALORIE/2;
00302       }
00303       else {
00304         fprintf(stderr,"I don't know what funct=%d means in ANGLETYPES\n",
00305                 funct);
00306         exit(1);
00307       }
00308       angleTable.addType(typea,typeb,typec,th0,kth,funct);
00309       break;
00310 
00311     case DIHEDRALS:
00312       i = sscanf(buf," %d %d %d %d %d %f %f %f %f %f %f",
00313                  &atomi,&atomj,&atomk,&atoml,&funct,
00314                  &c[0],&c[1],&c[2],&c[3],&c[4],&c[5]);
00315       atomi--; // shift right away to a zero-indexing
00316       atomj--;
00317       atomk--;
00318       atoml--;
00319       if(i==5) { /* we have to look up the parameters */
00320        tmptypea = genericMols[genericMols.size()-1]->getAtom(atomi)->getType();
00321        tmptypeb = genericMols[genericMols.size()-1]->getAtom(atomj)->getType();
00322        tmptypec = genericMols[genericMols.size()-1]->getAtom(atomk)->getType();
00323        tmptyped = genericMols[genericMols.size()-1]->getAtom(atoml)->getType();
00324         /* find the index and parameters */
00325         index = dihedralTable.getParams(tmptypea, tmptypeb, tmptypec,
00326                                         tmptyped, funct, c, &mult);
00327         if(index==-1) {
00328           fprintf(stderr,
00329              "Required dihedraltype %s--%s--%s--%s (function %d) not found.\n",
00330                   tmptypea,tmptypeb,tmptypec,tmptyped,funct);
00331           exit(1);
00332         }
00333       }
00334       else if(i==7 || i==8 || i==11) { /* the parameters are given */
00335         if(funct==1 || funct==2) { /* we should have two parameters */
00336           if(i!=7+(funct==1)) {    /* plus a multiplicity for funct==1 */
00337             fprintf(stderr,"Must have 7 args for funct=1,2\n");
00338             exit(1);
00339           }
00340           c[0] = c[0]; /* both in deg */
00341           c[1] = c[1]/JOULES_PER_CALORIE; /* convert kJ to kcal and still use E=kx2*/
00342           /* for funct==1 these are both divided by rad^2 */
00343           if(funct==1) {
00344             mult=(int)(c[2]+0.5); /* round to nearest integer :p */
00345           }
00346         }
00347         else if(funct==3) {
00348           if(i!=11){
00349             fprintf(stderr,"Must have 11 args for funct=3\n");
00350             exit(1);
00351           }
00352 
00353           for(j=0;j<6;j++) {
00354             c[j] = c[j]/JOULES_PER_CALORIE; /* convert kJ to kcal and E=Cn cos^n */
00355           }
00356         }
00357         else {
00358           fprintf(stderr,
00359                   "I don't know what funct=%d means in DIHEDRALS\n",funct);
00360           exit(1);
00361         }
00362         index = dihedralTable.getIndex(c,mult,funct);
00363       }
00364       else {
00365         fprintf(stderr,"Syntax error (%d args) in DIHEDRALS: %s\n",i,buf);
00366         exit(1);
00367       }
00368 
00369       /* add the dihedrals to our table */
00370       genericMols[genericMols.size()-1]->addDihedral(atomi,atomj,atomk,atoml,
00371                                                      index);
00372       break;
00373     case DIHEDRALTYPES:
00374       i = sscanf(buf," %5s %5s %d %f %f %f %f %f %f",
00375                  typea,typeb,&funct,&c[0],&c[1],&c[2],&c[3],&c[4],&c[5]);
00376       if(funct == 1 || funct == 2) {
00377         if(i!=5+(funct==1)) { /* 6 for f=2, 5 for f=1 */
00378           fprintf(stderr,"Syntax error in DIHEDRALTYPES: %s\n",buf);
00379           exit(1);
00380         }
00381         c[0] = c[0]; /* both in deg */
00382         c[1] = c[1]/JOULES_PER_CALORIE; /* convert kJ to kcal and still use E=kx2*/
00383         /* for funct==1 these are both divided by rad^2 */
00384         if(funct==1) {
00385           mult=(int)(c[2]+0.5); /* round to nearest integer :p */
00386         }
00387       }
00388       else if(funct == 3) {
00389         if(i!=9) {
00390           fprintf(stderr,"Syntax error in DIHEDRALTYPES\n");
00391           exit(1);
00392         }
00393         for(j=0;j<6;j++) {
00394           c[j] = c[j]/JOULES_PER_CALORIE; /* convert kJ to kcal and E=Cn cos^n */
00395         }
00396       }
00397       else {
00398         fprintf(stderr,"I don't know what funct=%d means in DIHEDRALTYPES\n",
00399                 funct);
00400         exit(1);
00401       }
00402       dihedralTable.addType(typea,typeb,c,mult,funct);
00403       break;
00404       
00405     case ATOMS:
00406       i = sscanf(buf," %d %5s %d %5s %5s %d %f %f",
00407                    &num, type, &resnum, restype,
00408                  atomname, &chargegp, &charge, &mass);
00409       if(i==7) { /* XXX temporary - I should be able to get more
00410                     params */
00411         typenum = atomTable.getParams(type,&mass,&junkf,&junkf,&junkf);
00412         i=8;
00413       }
00414       else {
00415         if(i!=8) {
00416           fprintf(stderr,"Syntax error in ATOMS\n");
00417           exit(1);
00418         }
00419         // just get the type number
00420         typenum = atomTable.getParams(type,&junkf,&junkf,&junkf,&junkf);
00421       }
00422       genericMols[genericMols.size()-1]->addAtom(type,typenum,resnum,
00423                                                  restype,atomname,charge,mass);
00424       break;
00425 
00426     case ATOMTYPES:
00427       if(6 != sscanf(buf," %5s %f %f %5s %f %f",type,&mass,&charge,
00428                      particletype,&c6,&c12)) {
00429         fprintf(stderr,"Syntax error in ATOMTYPES: %s\n",buf);
00430         exit(1);
00431       }
00432       /* conversions:
00433          c6  - kJ/mol nm6  -> kcal/mol A6
00434          c12 - kJ/mol nm12 -> kcal/mol A12 */
00435       atomTable.addType(type,mass,charge,
00436                             c6/JOULES_PER_CALORIE*1E6,
00437                             c12/JOULES_PER_CALORIE*1E12);
00438       break;
00439 
00440     case MOLECULETYPE:
00441       if(2!=sscanf(buf," %20s %d",molname,&nrexcl)) {
00442         fprintf(stderr,"Syntax error in MOLECULETYPE: %s\n",buf);
00443         exit(1);
00444       }
00445 
00446       /* add another generic molecule holder */
00447       genericMols.add(new GenericMol(molname));
00448       break;
00449 
00450     case MOLECULES:
00451       if(2!=sscanf(buf," %20s %d",molname,&copies)) {
00452         fprintf(stderr,"Syntax error in MOLECULES: %s\n",buf);
00453         exit(1);
00454       }
00455       
00456       /* search for the specified molecule and make a molInst of it*/
00457       moleculeinstance = NULL;
00458       for(i=0;i<genericMols.size();i++) {
00459         if(0==strcmp(molname,genericMols[i]->getName())) {
00460           moleculeinstance = new MolInst(genericMols[i],copies);
00461           break;
00462         }
00463       }
00464 
00465       if(moleculeinstance==NULL) {
00466         fprintf(stderr,"Molecule %s undefined.\n",molname);
00467         exit(1);
00468       }
00469       
00470       /* put it at the end of the list */
00471       molInsts.add(moleculeinstance);
00472 
00473       break;
00474     }
00475   }
00476 
00477   fclose(f);
00478 }


Member Function Documentation

void GromacsTopFile::getAngle int  num,
int *  atomi,
int *  atomj,
int *  atomk,
int *  angletype
const
 

Definition at line 548 of file GromacsTopFile.C.

References GenericAngle::getAtomi(), GenericAngle::getAtomj(), GenericAngle::getAtomk(), GenericAngle::getType(), and ResizeArray< Elem >::size().

00549                                                 {
00550   /* figure out what instance this angle is in */
00551   int nangles=0;
00552   int natoms=0;
00553   int i;
00554   for(i=0;i<molInsts.size();i++) {
00555     int molangles = molInsts[i]->getMol()->getNumAngles();
00556     int molatoms = molInsts[i]->getMol()->getNumAtoms();
00557     int newangles = molInsts[i]->getNumAngles();
00558     int newatoms = molInsts[i]->getNumAtoms();
00559     
00560     if(nangles+newangles-1 >= n) {
00561       /* the angle is in this MolInst */
00562       int localnum = (n-nangles) % molangles; /* number within this inst */
00563       int instnum = (n-nangles) / molangles;  /* number of instances before */
00564       int addatoms = natoms+instnum*molatoms; /* extra atms to add to atmi */
00565 
00566       const GenericAngle *a = molInsts[i]->getMol()->getAngle(localnum);
00567 
00568       *atomi = a->getAtomi() + addatoms;
00569       *atomj = a->getAtomj() + addatoms;
00570       *atomk = a->getAtomk() + addatoms;
00571       *angletype = a->getType();
00572       break;
00573     }
00574 
00575     nangles += newangles;
00576     natoms += newatoms;
00577   }
00578 }

void GromacsTopFile::getAngleParams int  num,
Real th0,
Real kth,
int *  funct
const
 

void GromacsTopFile::getAtom int  num,
int *  residue_number,
char *  residue_name,
char *  atom_name,
char *  atom_type,
int *  atom_typenum,
Real charge,
Real mass
const
 

Definition at line 630 of file GromacsTopFile.C.

References GenericAtom::getAtomName(), GenericAtom::getCharge(), GenericAtom::getMass(), GenericAtom::getResNum(), GenericAtom::getResType(), GenericAtom::getType(), GenericAtom::getTypeNum(), and ResizeArray< Elem >::size().

Referenced by PDB::PDB().

00634         {
00635   int natoms=0,n=num; // zero-indexed array
00636   int resnum=0;
00637   /* figure out what instance the atom is in, and what residue number
00638      it has */
00639   int i;
00640 
00641   for(i=0;i<molInsts.size();i++) {
00642     int numnew = molInsts[i]->getNumAtoms(); /* atoms in this MolInst */
00643     int resmol = molInsts[i]->getMol()->getNumRes(); /* # res/mol */
00644     int newres = molInsts[i]->getNumRes(); /* residues in this MolInst */
00645 
00646     if(natoms+numnew-1 >= n) {
00647       /* the atom is in this molInst */
00648       int localnum = (n-natoms) % molInsts[i]->getMol()->getNumAtoms();
00649       int instnum  = (n-natoms) / molInsts[i]->getMol()->getNumAtoms();
00650       
00651       // getAtom is zero-indexed
00652       const GenericAtom *a = molInsts[i]->getMol()->getAtom(localnum);
00653       int residue = resnum + resmol*instnum + a->getResNum();
00654 
00655       *residue_number = residue;
00656       strncpy(residue_name,a->getResType(),11);
00657       strncpy(atom_name,a->getAtomName(),11);
00658       strncpy(atom_type,a->getType(),11);
00659       *charge=a->getCharge();
00660       *mass=a->getMass();
00661       *atom_typenum=a->getTypeNum();
00662       break;
00663     }
00664 
00665     /* go to the next molInst */
00666     natoms += numnew;
00667     resnum += newres;
00668   }
00669 }

void GromacsTopFile::getAtomParams int  num,
char *  type
const [inline]
 

Definition at line 480 of file GromacsTopFile.h.

References AtomTable::getType().

Referenced by getVDWParams().

00480                                                 {
00481     atomTable.getType(num,type);
00482   }

void GromacsTopFile::getBond int  num,
int *  atomi,
int *  atomj,
int *  bondtype
const
 

Definition at line 514 of file GromacsTopFile.C.

References GenericBond::getAtomi(), GenericBond::getAtomj(), GenericBond::getType(), and ResizeArray< Elem >::size().

00514                                                                                {
00515   /* figure out what instance this bond is in */
00516   int nbonds=0;
00517   int natoms=0;
00518   int i;
00519   for(i=0;i<molInsts.size();i++) {
00520     int molbonds = molInsts[i]->getMol()->getNumBonds();
00521     int molatoms = molInsts[i]->getMol()->getNumAtoms();
00522     int newbonds = molInsts[i]->getNumBonds();
00523     int newatoms = molInsts[i]->getNumAtoms();
00524     
00525     if(nbonds+newbonds-1 >= n) {
00526       /* the bond is in this MolInst */
00527       int localnum = (n-nbonds) % molbonds;   /* number within this inst */
00528       int instnum = (n-nbonds) / molbonds;    /* number of instances before */
00529       int addatoms = natoms+instnum*molatoms; /* extra atoms to add to atomi */
00530 
00531       const GenericBond *b = molInsts[i]->getMol()->getBond(localnum);
00532 
00533       *atomi = b->getAtomi() + addatoms;
00534       *atomj = b->getAtomj() + addatoms;
00535       *bondtype = b->getType();
00536       break;
00537     }
00538 
00539     nbonds += newbonds;
00540     natoms += newatoms;
00541   }
00542 }

void GromacsTopFile::getBondParams int  num,
Real b0,
Real kB,
int *  funct
const
 

void GromacsTopFile::getDihedral int  num,
int *  atomi,
int *  atomj,
int *  atomk,
int *  atoml,
int *  type
const
 

Definition at line 583 of file GromacsTopFile.C.

References GenericDihedral::getAtomi(), GenericDihedral::getAtomj(), GenericDihedral::getAtomk(), GenericDihedral::getAtoml(), GenericDihedral::getType(), and ResizeArray< Elem >::size().

00584                                                            {
00585   /* figure out what instance this angle is in */
00586   int ndihedrals=0;
00587   int natoms=0;
00588   int i;
00589   for(i=0;i<molInsts.size();i++) {
00590     int moldihedrals = molInsts[i]->getMol()->getNumDihedrals();
00591     int molatoms = molInsts[i]->getMol()->getNumAtoms();
00592     int newdihedrals = molInsts[i]->getNumDihedrals();
00593     int newatoms = molInsts[i]->getNumAtoms();
00594     
00595     if(ndihedrals+newdihedrals-1 >= n) {
00596       /* the dihedral is in this MolInst */
00597       int localnum = (n-ndihedrals) % moldihedrals; /* number in this inst */
00598       int instnum = (n-ndihedrals) / moldihedrals; /* number of insts before */
00599       int addatoms = natoms+instnum*molatoms; /*extra atms to add to atmi*/
00600 
00601       const GenericDihedral *a = molInsts[i]->getMol()->getDihedral(localnum);
00602 
00603       *atomi = a->getAtomi() + addatoms;
00604       *atomj = a->getAtomj() + addatoms;
00605       *atomk = a->getAtomk() + addatoms;
00606       *atoml = a->getAtoml() + addatoms;
00607       *type = a->getType();
00608       break;
00609     }
00610 
00611     ndihedrals += newdihedrals;
00612     natoms += newatoms;
00613   }
00614 }

void GromacsTopFile::getDihedralParams int  num,
Real c,
int *  mult,
int *  funct
const
 

int GromacsTopFile::getNumAngleParams  )  const [inline]
 

Definition at line 458 of file GromacsTopFile.h.

References AngleTable::size().

00458 { return angleTable.size(); }

int GromacsTopFile::getNumAngles  )  const
 

Definition at line 491 of file GromacsTopFile.C.

References ResizeArray< Elem >::size().

00491                                        {
00492   int n=0,i;
00493   for(i=0;i<molInsts.size();i++) {
00494     n += molInsts[i]->getNum() *
00495          molInsts[i]->getMol()->getNumAngles();
00496   }
00497   return n;
00498 }

int GromacsTopFile::getNumAtomParams  )  const [inline]
 

Definition at line 456 of file GromacsTopFile.h.

References AtomTable::size().

00456 { return atomTable.size(); }

int GromacsTopFile::getNumAtoms  )  const
 

Definition at line 617 of file GromacsTopFile.C.

References ResizeArray< Elem >::size().

Referenced by PDB::PDB().

00617                                       {
00618   int n=0;
00619   int i;
00620   for(i=0;i<molInsts.size();i++) {
00621     n += molInsts[i]->getNum() *
00622          molInsts[i]->getMol()->getNumAtoms();
00623   }
00624   return n;
00625 }

int GromacsTopFile::getNumBondParams  )  const [inline]
 

Definition at line 457 of file GromacsTopFile.h.

References BondTable::size().

00457 { return bondTable.size(); }

int GromacsTopFile::getNumBonds  )  const
 

Definition at line 481 of file GromacsTopFile.C.

References ResizeArray< Elem >::size().

00481                                       {
00482   int n=0,i;
00483   for(i=0;i<molInsts.size();i++) {
00484     n += molInsts[i]->getNum() *
00485          molInsts[i]->getMol()->getNumBonds();
00486   }
00487   return n;
00488 }

int GromacsTopFile::getNumDihedralParams  )  const [inline]
 

Definition at line 459 of file GromacsTopFile.h.

References DihedralTable::size().

00459 { return dihedralTable.size(); }

int GromacsTopFile::getNumDihedrals  )  const
 

Definition at line 501 of file GromacsTopFile.C.

References ResizeArray< Elem >::size().

00501                                           {
00502   int n=0,i;
00503   for(i=0;i<molInsts.size();i++) {
00504     n += molInsts[i]->getNum() *
00505          molInsts[i]->getMol()->getNumDihedrals();
00506   }
00507   return n;
00508 }

char* GromacsTopFile::getSystemName  )  const [inline]
 

Definition at line 447 of file GromacsTopFile.h.

00447 { return systemName; }

void GromacsTopFile::getVDWParams int  typea,
int  typeb,
Real c6,
Real c12,
Real c6pair,
Real c7
const
 

Definition at line 1228 of file GromacsTopFile.C.

References getAtomParams(), AtomTable::getParams(), VDWTable::getParams(), and Real.

01229                                                                           {
01230   int i,ret;
01231   Real c6a,c6b,c12a,c12b, mjunk, qjunk;
01232   char typea[11]="",typeb[11]="";
01233 
01234   /* get the string names corresponding to numa and numb */
01235   getAtomParams(numa,typea);
01236   getAtomParams(numb,typeb);
01237   if(typea[0]==0) { /* found a bug in my use of strncpy here once */
01238     fprintf(stderr,"Failed to get name of atom %d\n",numa);
01239     exit(1);
01240   }
01241   if(typeb[0]==0) {
01242     fprintf(stderr,"Failed to get name of atom %d\n",numb);
01243     exit(1);
01244   }
01245 
01246   /* first try - use the VDW table */
01247   i = vdwTable.getParams(typea,typeb,c6,c12,c6pair,c12pair);
01248 
01249   if(i==-1) {
01250     /* fallback - use the individual atom's parameters */
01251     ret = atomTable.getParams(typea, &mjunk, &qjunk, &c6a, &c12a);
01252     if(ret==-1) {
01253       fprintf(stderr,"Couldn't find atom type %s\n",typea);
01254       exit(1);
01255     }
01256     ret = atomTable.getParams(typeb, &mjunk, &qjunk, &c6b, &c12b);
01257     if(ret==-1) {
01258       fprintf(stderr,"Couldn't find atom type %s\n",typeb);
01259       exit(1);
01260     }
01261     
01262     *c6  = (float)(sqrt(c6a * c6b));
01263     *c12 = (float)(sqrt(c12a*c12b));
01264   }
01265 
01266   /* XXX we need to put exclusions in here, including those implied by
01267      the use of RB. This may be a  little tricky because we will not
01268      be able to support any other kinds of dihedral bonds with the
01269      same end pair as any RB dihedral.  OR else, maybe NAMD will
01270      support the exclusions directly? */
01271 
01272   if(!genPairs) {
01273     return; /* we're done */
01274   }    
01275 
01276   *c6pair  = *c6  * fudgeLJ;
01277   *c12pair = *c12 * fudgeLJ;
01278   /* now we're really done */
01279 }


The documentation for this class was generated from the following files:
Generated on Fri May 25 04:07:22 2012 for NAMD by  doxygen 1.3.9.1