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

Parameters Class Reference

#include <Parameters.h>

List of all members.

Public Member Functions

 Parameters ()
 Parameters (SimParameters *, StringList *f)
 Parameters (Ambertoppar *, BigReal)
void read_parm (Ambertoppar *, BigReal)
 Parameters (const GromacsTopFile *gf, Bool min)
 ~Parameters ()
char * atom_type_name (Index a)
void read_parameter_file (char *)
void read_charmm_parameter_file (char *)
void done_reading_files ()
void done_reading_structure ()
void assign_vdw_index (char *, Atom *)
void assign_bond_index (char *, char *, Bond *)
void assign_angle_index (char *, char *, char *, Angle *)
void assign_dihedral_index (char *, char *, char *, char *, Dihedral *, int)
void assign_improper_index (char *, char *, char *, char *, Improper *, int)
void assign_crossterm_index (char *, char *, char *, char *, char *, char *, char *, char *, Crossterm *)
void send_Parameters (Communicate *)
void receive_Parameters (MIStream *)
void get_bond_params (Real *k, Real *x0, Index index)
void get_angle_params (Real *k, Real *theta0, Real *k_ub, Real *r_ub, Index index)
int get_improper_multiplicity (Index index)
int get_dihedral_multiplicity (Index index)
void get_improper_params (Real *k, int *n, Real *delta, Index index, int mult)
void get_dihedral_params (Real *k, int *n, Real *delta, Index index, int mult)
void get_vdw_params (Real *sigma, Real *epsilon, Real *sigma14, Real *epsilon14, Index index)
int get_vdw_pair_params (Index ind1, Index ind2, Real *, Real *, Real *, Real *)
int get_num_vdw_params (void)
void print_bond_params ()
void print_angle_params ()
void print_dihedral_params ()
void print_improper_params ()
void print_crossterm_params ()
void print_vdw_params ()
void print_vdw_pair_params ()
void print_param_summary ()

Public Attributes

BondValuebond_array
AngleValueangle_array
DihedralValuedihedral_array
ImproperValueimproper_array
CrosstermValuecrossterm_array
VdwValuevdw_array
IndexedVdwPairvdw_pair_tree
int NumBondParams
int NumAngleParams
int NumDihedralParams
int NumImproperParams
int NumCrosstermParams


Constructor & Destructor Documentation

Parameters::Parameters  ) 
 

Definition at line 161 of file Parameters.C.

00161                        {
00162   initialize();
00163 }

Parameters::Parameters SimParameters ,
StringList f
 

Definition at line 209 of file Parameters.C.

References StringList::data, done_reading_files(), StringList::next, SimParameters::paraTypeCharmmOn, SimParameters::paraTypeXplorOn, read_charmm_parameter_file(), read_parameter_file(), and simParams.

00210 {
00211   initialize();
00212 
00213   //****** BEGIN CHARMM/XPLOR type changes
00215   if (simParams->paraTypeXplorOn)
00216   {
00217     paramType = paraXplor;
00218   }
00219   else if (simParams->paraTypeCharmmOn)
00220   {
00221     paramType = paraCharmm;
00222   }
00223   //****** END CHARMM/XPLOR type changes
00224 
00225   /* Set up AllFilesRead flag to FALSE.  Once all of the files    */
00226   /* have been read in, then this will be set to true and the     */
00227   /* arrays of parameters will be set up        */
00228   AllFilesRead = FALSE;
00229 
00230   if (NULL != f) 
00231   {
00232     do
00233     {
00234       //****** BEGIN CHARMM/XPLOR type changes
00235       if (paramType == paraXplor)
00236       {
00237         read_parameter_file(f->data);
00238       }
00239       else if (paramType == paraCharmm)
00240       {
00241         read_charmm_parameter_file(f->data);
00242       }
00243       //****** END CHARMM/XPLOR type changes
00244       f = f->next;
00245     } while ( f != NULL );
00246 
00247     done_reading_files();
00248   }
00249 
00250 }

Parameters::Parameters Ambertoppar ,
BigReal 
 

Definition at line 5178 of file Parameters.C.

References Ambertoppar, and read_parm().

05179 {
05180   initialize();
05181 
05182   // Read in parm parameters
05183   read_parm(amber_data,vdw14);
05184 }

Parameters::Parameters const GromacsTopFile gf,
Bool  min
 

Definition at line 5318 of file Parameters.C.

References read_parm().

05319 {
05320   initialize();
05321 
05322   // Read in parm parameters
05323   read_parm(gf,min);
05324 }

Parameters::~Parameters  ) 
 

Definition at line 262 of file Parameters.C.

References angle_array, bond_array, crossterm_array, dihedral_array, improper_array, ResizeArray< Elem >::resize(), ResizeArray< Elem >::size(), vdw_array, and vdw_pair_tree.

00264 {
00265         if (atomTypeNames)
00266           delete [] atomTypeNames;
00267 
00268   if (bondp != NULL)
00269     free_bond_tree(bondp);
00270 
00271   if (anglep != NULL)
00272     free_angle_tree(anglep);
00273 
00274   if (dihedralp != NULL)
00275     free_dihedral_list(dihedralp);
00276 
00277   if (improperp != NULL)
00278     free_improper_list(improperp);
00279 
00280   if (crosstermp != NULL)
00281     free_crossterm_list(crosstermp);
00282 
00283   if (vdwp != NULL)
00284     free_vdw_tree(vdwp);
00285 
00286   if (vdw_pairp != NULL)
00287     free_vdw_pair_list();
00288 
00289   if (bond_array != NULL)
00290     delete [] bond_array;
00291 
00292   if (angle_array != NULL)
00293     delete [] angle_array;
00294 
00295   if (dihedral_array != NULL)
00296     delete [] dihedral_array;
00297 
00298   if (improper_array != NULL)
00299     delete [] improper_array;
00300 
00301   if (crossterm_array != NULL)
00302     delete [] crossterm_array;
00303 
00304   if (vdw_array != NULL)
00305     delete [] vdw_array;
00306   
00307   if (vdw_pair_tree != NULL)
00308     free_vdw_pair_tree(vdw_pair_tree);
00309 
00310   if (maxDihedralMults != NULL)
00311     delete [] maxDihedralMults;
00312 
00313   if (maxImproperMults != NULL)
00314     delete [] maxImproperMults;
00315 
00316   for( int i = 0; i < error_msgs.size(); ++i ) {
00317     delete [] error_msgs[i];
00318   }
00319   error_msgs.resize(0);
00320 }


Member Function Documentation

void Parameters::assign_angle_index char *  ,
char *  ,
char *  ,
Angle
 

Definition at line 3368 of file Parameters.C.

References Angle, angle::angle_type, angle_params::atom1name, angle_params::atom2name, angle_params::atom3name, angle_params::index, angle_params::left, NAMD_die(), and angle_params::right.

Referenced by getAngleData().

03371 {
03372   struct angle_params *ptr;  //  Current position in tree
03373   int comp_val;      //  value from strcasecmp
03374   int found=0;      //  flag 1->found a match
03375   char tmp_name[15];    //  Temporary atom name
03376 
03377   /*  Check to make sure the files have all been read    */
03378   if (!AllFilesRead)
03379   {
03380     NAMD_die("Tried to assign angle index before all parameter files were read");
03381   }
03382 
03383   /*  We need atom1 < atom3.  If that was not what we were   */
03384   /*  passed, switch them            */
03385   if (strcasecmp(atom1, atom3) > 0)
03386   {
03387     strcpy(tmp_name, atom1);
03388     strcpy(atom1, atom3);
03389     strcpy(atom3, tmp_name);
03390   }
03391 
03392   /*  Start at the top            */
03393   ptr=anglep;
03394 
03395   /*  While we don't have a match and we haven't reached the  */
03396   /*  bottom of the tree, compare values        */
03397   while (!found && (ptr != NULL))
03398   {
03399     comp_val = strcasecmp(atom1, ptr->atom1name);
03400 
03401     if (comp_val == 0)
03402     {
03403       /*  Atom 1 matches, so compare atom 2    */
03404       comp_val = strcasecmp(atom2, ptr->atom2name);
03405       
03406       if (comp_val == 0)
03407       {
03408         /*  Atoms 1&2 match, try atom 3    */
03409         comp_val = strcasecmp(atom3, ptr->atom3name);
03410       }
03411     }
03412 
03413     if (comp_val == 0)
03414     {
03415       /*  Found a match        */
03416       found = 1;
03417       angle_ptr->angle_type = ptr->index;
03418     }
03419     else if (comp_val < 0)
03420     {
03421       /*  Go left          */
03422       ptr=ptr->left;
03423     }
03424     else
03425     {
03426       /*  Go right          */
03427       ptr=ptr->right;
03428     }
03429   }
03430 
03431   /*  Make sure we found a match          */
03432   if (!found)
03433   {
03434     char err_msg[128];
03435 
03436     sprintf(err_msg, "UNABLE TO FIND ANGLE PARAMETERS FOR %s %s %s",
03437        atom1, atom2, atom3);
03438     NAMD_die(err_msg);
03439   }
03440 
03441   return;
03442 }

void Parameters::assign_bond_index char *  ,
char *  ,
Bond
 

Definition at line 3280 of file Parameters.C.

References bond_params::atom1name, bond_params::atom2name, Bond, bond::bond_type, bond_params::index, bond_params::left, NAMD_die(), and bond_params::right.

Referenced by getBondData().

03282 {
03283   struct bond_params *ptr;  //  Current location in tree
03284   int found=0;      //  Flag 1-> found a match
03285   int cmp_code;      //  return code from strcasecmp
03286   char tmp_name[15];    //  Temporary atom name
03287 
03288   /*  Check to make sure the files have all been read    */
03289   if (!AllFilesRead)
03290   {
03291     NAMD_die("Tried to assign bond index before all parameter files were read");
03292   }
03293 
03294   /*  We need atom1 < atom2, so if that's not the way they        */
03295   /*  were passed, flip them          */
03296   if (strcasecmp(atom1, atom2) > 0)
03297   {
03298     strcpy(tmp_name, atom1);
03299     strcpy(atom1, atom2);
03300     strcpy(atom2, tmp_name);
03301   }
03302 
03303   /*  Start at the top            */
03304   ptr=bondp;
03305 
03306   /*  While we haven't found a match and we're not at the end  */
03307   /*  of the tree, compare the bond passed in with the tree  */
03308   while (!found && (ptr!=NULL))
03309   {
03310     cmp_code=strcasecmp(atom1, ptr->atom1name);
03311 
03312     if (cmp_code == 0)
03313     {
03314       cmp_code=strcasecmp(atom2, ptr->atom2name);
03315     }
03316 
03317     if (cmp_code == 0)
03318     {
03319       /*  Found a match        */
03320       found=1;
03321       bond_ptr->bond_type = ptr->index;
03322     }
03323     else if (cmp_code < 0)
03324     {
03325       /*  Go left          */
03326       ptr=ptr->left;
03327     }
03328     else
03329     {
03330       /*  Go right          */
03331       ptr=ptr->right;
03332     }
03333   }
03334 
03335   /*  Check to see if we found anything        */
03336   if (!found)
03337   {
03338     char err_msg[128];
03339 
03340     sprintf(err_msg, "CAN'T FIND BOND PARAMETERS FOR BOND %s - %s IN PARAMETER FILES", atom1, atom2);
03341     NAMD_die(err_msg);
03342   }
03343 
03344   return;
03345 }

void Parameters::assign_crossterm_index char *  ,
char *  ,
char *  ,
char *  ,
char *  ,
char *  ,
char *  ,
char *  ,
Crossterm
 

Definition at line 3664 of file Parameters.C.

References crossterm_params::atom1name, crossterm_params::atom2name, crossterm_params::atom3name, crossterm_params::atom4name, crossterm_params::atom5name, crossterm_params::atom6name, crossterm_params::atom7name, crossterm_params::atom8name, Crossterm, crossterm::crossterm_type, crossterm_params::index, NAMD_die(), and crossterm_params::next.

Referenced by getCrosstermData().

03667 {
03668   struct crossterm_params *ptr;  //  Current position in list
03669   int found=0;      //  Flag 1->found a match
03670 
03671   /*  Start at the head of the list        */
03672   ptr=crosstermp;
03673 
03674   /*  While we haven't fuond a match and haven't reached the end  */
03675   /*  of the list, keep looking          */
03676   while (!found && (ptr!=NULL))
03677   {
03678     /*  Do a linear search through the linked list of   */
03679     /*  crossterm parameters.  Since the list is arranged    */
03680     /*  with wildcard paramters at the end of the list, we  */
03681     /*  can simply do a linear search and be guaranteed that*/
03682     /*  we will find exact matches before wildcard matches. */
03683     /*  Also, we must check for an exact match, and a match */
03684     /*  in reverse, since they are really the same          */
03685     /*  physically.            */
03686     if ( ( (strcasecmp(ptr->atom1name, atom1)==0) || 
03687            (strcasecmp(ptr->atom1name, "X")==0) ) &&
03688        ( (strcasecmp(ptr->atom2name, atom2)==0) || 
03689            (strcasecmp(ptr->atom2name, "X")==0) ) &&
03690        ( (strcasecmp(ptr->atom3name, atom3)==0) || 
03691            (strcasecmp(ptr->atom3name, "X")==0) ) &&
03692        ( (strcasecmp(ptr->atom4name, atom4)==0) || 
03693            (strcasecmp(ptr->atom4name, "X")==0) ) )
03694     {
03695       /*  Found an exact match      */
03696       found=1;
03697     }
03698     else if ( ( (strcasecmp(ptr->atom4name, atom1)==0) || 
03699            (strcasecmp(ptr->atom4name, "X")==0) ) &&
03700        ( (strcasecmp(ptr->atom3name, atom2)==0) || 
03701            (strcasecmp(ptr->atom3name, "X")==0) ) &&
03702        ( (strcasecmp(ptr->atom2name, atom3)==0) || 
03703            (strcasecmp(ptr->atom2name, "X")==0) ) &&
03704        ( (strcasecmp(ptr->atom1name, atom4)==0) || 
03705            (strcasecmp(ptr->atom1name, "X")==0) ) )
03706     {
03707       /*  Found a reverse match      */
03708       found=1;
03709     }
03710     if ( ! found ) {
03711       /*  Didn't find a match, go to the next node  */
03712       ptr=ptr->next;
03713       continue;
03714     }
03715     found = 0;
03716     if ( ( (strcasecmp(ptr->atom5name, atom5)==0) || 
03717            (strcasecmp(ptr->atom5name, "X")==0) ) &&
03718        ( (strcasecmp(ptr->atom6name, atom6)==0) || 
03719            (strcasecmp(ptr->atom6name, "X")==0) ) &&
03720        ( (strcasecmp(ptr->atom7name, atom7)==0) || 
03721            (strcasecmp(ptr->atom7name, "X")==0) ) &&
03722        ( (strcasecmp(ptr->atom8name, atom8)==0) || 
03723            (strcasecmp(ptr->atom8name, "X")==0) ) )
03724     {
03725       /*  Found an exact match      */
03726       found=1;
03727     }
03728     else if ( ( (strcasecmp(ptr->atom8name, atom5)==0) || 
03729            (strcasecmp(ptr->atom8name, "X")==0) ) &&
03730        ( (strcasecmp(ptr->atom7name, atom6)==0) || 
03731            (strcasecmp(ptr->atom7name, "X")==0) ) &&
03732        ( (strcasecmp(ptr->atom6name, atom7)==0) || 
03733            (strcasecmp(ptr->atom6name, "X")==0) ) &&
03734        ( (strcasecmp(ptr->atom5name, atom8)==0) || 
03735            (strcasecmp(ptr->atom5name, "X")==0) ) )
03736     {
03737       /*  Found a reverse match      */
03738       found=1;
03739     }
03740     if ( ! found ) {
03741       /*  Didn't find a match, go to the next node  */
03742       ptr=ptr->next;
03743     }
03744   }
03745 
03746   /*  Make sure we found a match          */
03747   if (!found)
03748   {
03749     char err_msg[128];
03750 
03751     sprintf(err_msg, "CAN'T FIND CROSSTERM PARAMETERS FOR %s  %s  %s  %s  %s  %s  %s  %s",
03752        atom1, atom2, atom3, atom4, atom5, atom6, atom7, atom8);
03753     
03754     NAMD_die(err_msg);
03755   }
03756 
03757   /*  Assign the constants          */
03758   crossterm_ptr->crossterm_type = ptr->index;
03759 
03760   return;
03761 }

void Parameters::assign_dihedral_index char *  ,
char *  ,
char *  ,
char *  ,
Dihedral ,
int 
 

Definition at line 3466 of file Parameters.C.

References dihedral_params::atom1name, dihedral_params::atom1wild, dihedral_params::atom2name, dihedral_params::atom2wild, dihedral_params::atom3name, dihedral_params::atom3wild, dihedral_params::atom4name, dihedral_params::atom4wild, Dihedral, dihedral_array, dihedral::dihedral_type, dihedral_params::index, DihedralValue::multiplicity, NAMD_die(), and dihedral_params::next.

Referenced by getDihedralData().

03470 {
03471   struct dihedral_params *ptr;  //  Current position in list
03472   int found=0;      //  Flag 1->found a match
03473 
03474   /*  Start at the begining of the list        */
03475   ptr=dihedralp;
03476 
03477   /*  While we haven't found a match and we haven't reached       */
03478   /*  the end of the list, keep looking        */
03479   while (!found && (ptr!=NULL))
03480   {
03481     /*  Do a linear search through the linked list of   */
03482     /*  dihedral parameters.  Since the list is arranged    */
03483     /*  with wildcard paramters at the end of the list, we  */
03484     /*  can simply do a linear search and be guaranteed that*/
03485     /*  we will find exact matches before wildcard matches. */
03486     /*  Also, we must check for an exact match, and a match */
03487     /*  in reverse, since they are really the same          */
03488     /*  physically.            */
03489     if ( ( ptr->atom1wild || (strcasecmp(ptr->atom1name, atom1)==0) ) && 
03490          ( ptr->atom2wild || (strcasecmp(ptr->atom2name, atom2)==0) ) &&
03491          ( ptr->atom3wild || (strcasecmp(ptr->atom3name, atom3)==0) ) &&
03492          ( ptr->atom4wild || (strcasecmp(ptr->atom4name, atom4)==0) ) ) 
03493     {
03494       /*  Found an exact match      */
03495       found=1;
03496     }
03497     else if ( ( ptr->atom4wild || (strcasecmp(ptr->atom4name, atom1)==0) ) &&
03498               ( ptr->atom3wild || (strcasecmp(ptr->atom3name, atom2)==0) ) &&
03499               ( ptr->atom2wild || (strcasecmp(ptr->atom2name, atom3)==0) ) &&
03500               ( ptr->atom1wild || (strcasecmp(ptr->atom1name, atom4)==0) ) )
03501     {
03502       /*  Found a reverse match      */
03503       found=1;
03504     }
03505     else
03506     {
03507       /*  Didn't find a match, go to the next node  */
03508       ptr=ptr->next;
03509     }
03510   }
03511 
03512   /*  Make sure we found a match          */
03513   if (!found)
03514   {
03515     char err_msg[128];
03516 
03517     sprintf(err_msg, "CAN'T FIND DIHEDRAL PARAMETERS FOR %s  %s  %s  %s",
03518        atom1, atom2, atom3, atom4);
03519     
03520     NAMD_die(err_msg);
03521   }
03522 
03523   //  Check to make sure the number of multiples specified in the psf
03524   //  file doesn't exceed the number of parameters in the parameter
03525   //  files
03526   if (multiplicity > maxDihedralMults[ptr->index])
03527   {
03528     char err_msg[257];
03529 
03530     sprintf(err_msg, "Multiplicity of Paramters for diehedral bond %s %s %s %s of %d exceeded", atom1, atom2, atom3, atom4, maxDihedralMults[ptr->index]);
03531     NAMD_die(err_msg);
03532   }
03533 
03534   //  If the multiplicity from the current bond is larger than that
03535   //  seen in the past, increase the multiplicity for this bond
03536   if (multiplicity > dihedral_array[ptr->index].multiplicity)
03537   {
03538     dihedral_array[ptr->index].multiplicity = multiplicity;
03539   }
03540 
03541   dihedral_ptr->dihedral_type = ptr->index;
03542 
03543   return;
03544 }

void Parameters::assign_improper_index char *  ,
char *  ,
char *  ,
char *  ,
Improper ,
int 
 

Definition at line 3568 of file Parameters.C.

References improper_params::atom1name, improper_params::atom2name, improper_params::atom3name, improper_params::atom4name, Improper, improper_array, improper::improper_type, improper_params::index, ImproperValue::multiplicity, NAMD_die(), and improper_params::next.

Referenced by getImproperData().

03572 {
03573   struct improper_params *ptr;  //  Current position in list
03574   int found=0;      //  Flag 1->found a match
03575 
03576   /*  Start at the head of the list        */
03577   ptr=improperp;
03578 
03579   /*  While we haven't fuond a match and haven't reached the end  */
03580   /*  of the list, keep looking          */
03581   while (!found && (ptr!=NULL))
03582   {
03583     /*  Do a linear search through the linked list of   */
03584     /*  improper parameters.  Since the list is arranged    */
03585     /*  with wildcard paramters at the end of the list, we  */
03586     /*  can simply do a linear search and be guaranteed that*/
03587     /*  we will find exact matches before wildcard matches. */
03588     /*  Also, we must check for an exact match, and a match */
03589     /*  in reverse, since they are really the same          */
03590     /*  physically.            */
03591     if ( ( (strcasecmp(ptr->atom1name, atom1)==0) || 
03592            (strcasecmp(ptr->atom1name, "X")==0) ) &&
03593        ( (strcasecmp(ptr->atom2name, atom2)==0) || 
03594            (strcasecmp(ptr->atom2name, "X")==0) ) &&
03595        ( (strcasecmp(ptr->atom3name, atom3)==0) || 
03596            (strcasecmp(ptr->atom3name, "X")==0) ) &&
03597        ( (strcasecmp(ptr->atom4name, atom4)==0) || 
03598            (strcasecmp(ptr->atom4name, "X")==0) ) )
03599     {
03600       /*  Found an exact match      */
03601       found=1;
03602     }
03603     else if ( ( (strcasecmp(ptr->atom4name, atom1)==0) || 
03604            (strcasecmp(ptr->atom4name, "X")==0) ) &&
03605        ( (strcasecmp(ptr->atom3name, atom2)==0) || 
03606            (strcasecmp(ptr->atom3name, "X")==0) ) &&
03607        ( (strcasecmp(ptr->atom2name, atom3)==0) || 
03608            (strcasecmp(ptr->atom2name, "X")==0) ) &&
03609        ( (strcasecmp(ptr->atom1name, atom4)==0) || 
03610            (strcasecmp(ptr->atom1name, "X")==0) ) )
03611     {
03612       /*  Found a reverse match      */
03613       found=1;
03614     }
03615     else
03616     {
03617       /*  Didn't find a match, go to the next node  */
03618       ptr=ptr->next;
03619     }
03620   }
03621 
03622   /*  Make sure we found a match          */
03623   if (!found)
03624   {
03625     char err_msg[128];
03626 
03627     sprintf(err_msg, "CAN'T FIND IMPROPER PARAMETERS FOR %s  %s  %s  %s",
03628        atom1, atom2, atom3, atom4);
03629     
03630     NAMD_die(err_msg);
03631   }
03632 
03633   //  Check to make sure the number of multiples specified in the psf
03634   //  file doesn't exceed the number of parameters in the parameter
03635   //  files
03636   if (multiplicity > maxImproperMults[ptr->index])
03637   {
03638     char err_msg[257];
03639 
03640     sprintf(err_msg, "Multiplicity of Paramters for improper bond %s %s %s %s of %d exceeded", atom1, atom2, atom3, atom4, maxImproperMults[ptr->index]);
03641     NAMD_die(err_msg);
03642   }
03643 
03644   //  If the multiplicity from the current bond is larger than that
03645   //  seen in the past, increase the multiplicity for this bond
03646   if (multiplicity > improper_array[ptr->index].multiplicity)
03647   {
03648     improper_array[ptr->index].multiplicity = multiplicity;
03649   }
03650 
03651   /*  Assign the constants          */
03652   improper_ptr->improper_type = ptr->index;
03653 
03654   return;
03655 }

void Parameters::assign_vdw_index char *  ,
Atom
 

Definition at line 3061 of file Parameters.C.

References Atom, vdw_params::atomname, vdw_params::index, iout, iWARN(), vdw_params::left, NAMD_die(), and vdw_params::right.

03063 {
03064   struct vdw_params *ptr;    //  Current position in trees
03065   int found=0;      //  Flag 1->found match
03066   int comp_code;      //  return code from strcasecmp
03067 
03068   /*  Check to make sure the files have all been read    */
03069   if (!AllFilesRead)
03070   {
03071     NAMD_die("Tried to assign vdw index before all parameter files were read");
03072   }
03073 
03074   /*  Start at the top            */
03075   ptr=vdwp;
03076 
03077   /*  While we haven't found a match, and we haven't reached      */
03078   /*  the bottom of the tree, compare the atom passed in with     */
03079   /*  the current value and decide if we have a match, or if not, */
03080   /*  which way to go            */
03081   while (!found && (ptr!=NULL))
03082   {
03083     comp_code = strcasecmp(atomtype, ptr->atomname);
03084 
03085     if (comp_code == 0)
03086     {
03087       /*  Found a match!        */
03088       atom_ptr->vdw_type=ptr->index;
03089       found=1;
03090     }
03091     else if (comp_code < 0)
03092     {
03093       /*  Go to the left        */
03094       ptr=ptr->left;
03095     }
03096     else
03097     {
03098       /*  Go to the right        */
03099       ptr=ptr->right;
03100     }
03101   }
03102 
03103   //****** BEGIN CHARMM/XPLOR type changes
03104   if (!found)
03105   {
03106     // since CHARMM allows wildcards "*" in vdw typenames
03107     // we have to look again if necessary, this way, if
03108     // we already had an exact match, this is never executed
03109     size_t windx;                      //  wildcard index
03110 
03111     /*  Start again at the top                                */
03112     ptr=vdwp;
03113   
03114      while (!found && (ptr!=NULL))
03115      {
03116   
03117        // get index of wildcard wildcard, get index
03118        windx= strcspn(ptr->atomname,"*"); 
03119        if (windx == strlen(ptr->atomname))
03120        {
03121          // there is no wildcard here
03122          comp_code = strcasecmp(atomtype, ptr->atomname);   
03123        }
03124        else
03125        {
03126          comp_code = strncasecmp(atomtype, ptr->atomname, windx); 
03127        }  
03128 
03129        if (comp_code == 0)
03130        {
03131          /*  Found a match!                                */
03132          atom_ptr->vdw_type=ptr->index;
03133          found=1;
03134          char errbuf[100];
03135          sprintf(errbuf,"VDW TYPE NAME %s MATCHES PARAMETER TYPE NAME %s",
03136                         atomtype, ptr->atomname);
03137          int i;
03138          for(i=0; i<error_msgs.size(); i++) {
03139            if ( strcmp(errbuf,error_msgs[i]) == 0 ) break;
03140          }
03141          if ( i == error_msgs.size() ) {
03142            char *newbuf = new char[strlen(errbuf)+1];
03143            strcpy(newbuf,errbuf);
03144            error_msgs.add(newbuf);
03145            iout << iWARN << newbuf << "\n" << endi;
03146          }
03147        }
03148        else if (comp_code < 0)
03149        {
03150           /*  Go to the left                                */
03151                 ptr=ptr->left;
03152        }
03153        else
03154        {
03155          /*  Go to the right                                */
03156                 ptr=ptr->right;
03157        }
03158      
03159      }
03160                 
03161   }
03162   //****** END CHARMM/XPLOR type changes
03163 
03164   /*  Make sure we found it          */
03165   if (!found)
03166   {
03167     char err_msg[100];
03168 
03169     sprintf(err_msg, "DIDN'T FIND vdW PARAMETER FOR ATOM TYPE %s",
03170        atomtype);
03171     NAMD_die(err_msg);
03172   }
03173 
03174   return;
03175 }

char* Parameters::atom_type_name Index  a  )  [inline]
 

Definition at line 295 of file Parameters.h.

References MAX_ATOMTYPE_CHARS.

00295                                       {
00296           return (atomTypeNames + (a * (MAX_ATOMTYPE_CHARS + 1)));
00297         }

void Parameters::done_reading_files  ) 
 

Definition at line 2599 of file Parameters.C.

References angle_array, bond_array, crossterm_array, dihedral_array, improper_array, MAX_ATOMTYPE_CHARS, NAMD_die(), NumCrosstermParams, NumDihedralParams, NumImproperParams, vdw_array, and VdwValue.

Referenced by Parameters().

02601 {
02602   AllFilesRead = TRUE;
02603 
02604   //  Allocate space for all of the arrays
02605   if (NumBondParams)
02606   {
02607     bond_array = new BondValue[NumBondParams];
02608 
02609     if (bond_array == NULL)
02610     {
02611       NAMD_die("memory allocation of bond_array failed!");
02612     }
02613   }
02614 
02615   if (NumAngleParams)
02616   {
02617     angle_array = new AngleValue[NumAngleParams];
02618 
02619     if (angle_array == NULL)
02620     {
02621       NAMD_die("memory allocation of angle_array failed!");
02622     }
02623   }
02624 
02625   if (NumDihedralParams)
02626   {
02627     dihedral_array = new DihedralValue[NumDihedralParams];
02628 
02629     if (dihedral_array == NULL)
02630     {
02631       NAMD_die("memory allocation of dihedral_array failed!");
02632     }
02633     memset(dihedral_array, 0, NumDihedralParams*sizeof(DihedralValue));
02634   }
02635 
02636   if (NumImproperParams)
02637   {
02638     improper_array = new ImproperValue[NumImproperParams];
02639 
02640     if (improper_array == NULL)
02641     {
02642       NAMD_die("memory allocation of improper_array failed!");
02643     }
02644     memset(improper_array, 0, NumImproperParams*sizeof(ImproperValue));
02645   }
02646 
02647   if (NumCrosstermParams)
02648   {
02649     crossterm_array = new CrosstermValue[NumCrosstermParams];
02650     memset(crossterm_array, 0, NumCrosstermParams*sizeof(CrosstermValue));
02651   }
02652 
02653   if (NumVdwParams)
02654   {
02655           atomTypeNames = new char[NumVdwParams*(MAX_ATOMTYPE_CHARS+1)];
02656     vdw_array = new VdwValue[NumVdwParams];
02657     
02658     if (vdw_array == NULL)
02659     {
02660       NAMD_die("memory allocation of vdw_array failed!");
02661     }
02662   }
02663 
02664   //  Assign indexes to each of the parameters and populate the
02665   //  arrays using the binary trees and linked lists that we have
02666   //  already read in
02667   index_bonds(bondp, 0);
02668   index_angles(anglep, 0);
02669   NumVdwParamsAssigned = index_vdw(vdwp, 0);
02670   index_dihedrals();
02671   index_impropers();
02672   index_crossterms();
02673   
02674   //  Convert the vdw pairs
02675   convert_vdw_pairs();
02676 }

void Parameters::done_reading_structure  ) 
 

Definition at line 4366 of file Parameters.C.

04368 {
04369   if (bondp != NULL)
04370     free_bond_tree(bondp);
04371 
04372   if (anglep != NULL)
04373     free_angle_tree(anglep);
04374 
04375   if (dihedralp != NULL)
04376     free_dihedral_list(dihedralp);
04377 
04378   if (improperp != NULL)
04379     free_improper_list(improperp);
04380 
04381   if (crosstermp != NULL)
04382     free_crossterm_list(crosstermp);
04383 
04384   if (vdwp != NULL)
04385     free_vdw_tree(vdwp);
04386 
04387   //  Free the arrays used to track multiplicity for dihedrals
04388   //  and impropers
04389   if (maxDihedralMults != NULL)
04390     delete [] maxDihedralMults;
04391 
04392   if (maxImproperMults != NULL)
04393     delete [] maxImproperMults;
04394 
04395   bondp=NULL;
04396   anglep=NULL;
04397   dihedralp=NULL;
04398   improperp=NULL;
04399   crosstermp=NULL;
04400   vdwp=NULL;
04401   maxImproperMults=NULL;
04402   maxDihedralMults=NULL;
04403 }

void Parameters::get_angle_params Real k,
Real theta0,
Real k_ub,
Real r_ub,
Index  index
[inline]
 

Definition at line 355 of file Parameters.h.

References AngleValue::k, AngleValue::k_ub, AngleValue::r_ub, and AngleValue::theta0.

Referenced by getAngleData().

00357         {
00358                 *k = angle_array[index].k;
00359                 *theta0 = angle_array[index].theta0;
00360                 *k_ub = angle_array[index].k_ub;
00361                 *r_ub = angle_array[index].r_ub;
00362         }

void Parameters::get_bond_params Real k,
Real x0,
Index  index
[inline]
 

Definition at line 349 of file Parameters.h.

References BondValue::k, and BondValue::x0.

Referenced by getBondData(), Molecule::print_bonds(), and Molecule::read_parm().

00350         {
00351                 *k = bond_array[index].k;
00352                 *x0 = bond_array[index].x0;
00353         }

int Parameters::get_dihedral_multiplicity Index  index  )  [inline]
 

Definition at line 369 of file Parameters.h.

References DihedralValue::multiplicity.

00370         {
00371                 return(dihedral_array[index].multiplicity);
00372         }

void Parameters::get_dihedral_params Real k,
int *  n,
Real delta,
Index  index,
int  mult
[inline]
 

Definition at line 387 of file Parameters.h.

References four_body_consts::delta, four_body_consts::k, four_body_consts::n, NAMD_die(), and DihedralValue::values.

00389         {
00390                 if ( (mult<0) || (mult>MAX_MULTIPLICITY) )
00391                 {
00392                         NAMD_die("Bad mult index in Parameters::get_dihedral_params");
00393                 }
00394 
00395                 *k = dihedral_array[index].values[mult].k;
00396                 *n = dihedral_array[index].values[mult].n;
00397                 *delta = dihedral_array[index].values[mult].delta;
00398         }

int Parameters::get_improper_multiplicity Index  index  )  [inline]
 

Definition at line 364 of file Parameters.h.

References ImproperValue::multiplicity.

00365         {
00366                 return(improper_array[index].multiplicity);
00367         }

void Parameters::get_improper_params Real k,
int *  n,
Real delta,
Index  index,
int  mult
[inline]
 

Definition at line 374 of file Parameters.h.

References four_body_consts::delta, four_body_consts::k, four_body_consts::n, NAMD_die(), and ImproperValue::values.

00376         {
00377                 if ( (mult<0) || (mult>MAX_MULTIPLICITY) )
00378                 {
00379                         NAMD_die("Bad mult index in Parameters::get_improper_params");
00380                 }
00381 
00382                 *k = improper_array[index].values[mult].k;
00383                 *n = improper_array[index].values[mult].n;
00384                 *delta = improper_array[index].values[mult].delta;
00385         }

int Parameters::get_num_vdw_params void   )  [inline]
 

Definition at line 419 of file Parameters.h.

Referenced by LJTable::LJTable().

00419 { return NumVdwParamsAssigned; }

int Parameters::get_vdw_pair_params Index  ind1,
Index  ind2,
Real ,
Real ,
Real ,
Real
 

Definition at line 3202 of file Parameters.C.

References indexed_vdw_pair::A, indexed_vdw_pair::A14, indexed_vdw_pair::B, indexed_vdw_pair::B14, indexed_vdw_pair::ind1, indexed_vdw_pair::ind2, Index, IndexedVdwPair, indexed_vdw_pair::left, and indexed_vdw_pair::right.

03205 {
03206   IndexedVdwPair *ptr;    //  Current location in tree
03207   Index temp;      //  Temporary value for swithcing
03208           // values
03209   int found=FALSE;    //  Flag 1-> found a match
03210 
03211   ptr=vdw_pair_tree;
03212 
03213   //  We need the smaller type in ind1, so if it isn't already that 
03214   //  way, switch them        */
03215   if (ind1 > ind2)
03216   {
03217     temp = ind1;
03218     ind1 = ind2;
03219     ind2 = temp;
03220   }
03221 
03222   /*  While we haven't found a match and we're not at the end  */
03223   /*  of the tree, compare the bond passed in with the tree  */
03224   while (!found && (ptr!=NULL))
03225   {
03226     if ( (ind1 == ptr->ind1) && (ind2 == ptr->ind2) )
03227     {
03228        found = TRUE;
03229     }
03230     else if ( (ind1 < ptr->ind1) || 
03231         ( (ind1==ptr->ind1) && (ind2 < ptr->ind2) ) )
03232     {
03233       /*  Go left          */
03234       ptr=ptr->left;
03235     }
03236     else
03237     {
03238       /*  Go right          */
03239       ptr=ptr->right;
03240     }
03241   }
03242 
03243   /*  If we found a match, assign the values      */
03244   if (found)
03245   {
03246     *A = ptr->A;
03247     *B = ptr->B;
03248     *A14 = ptr->A14;
03249     *B14 = ptr->B14;
03250 
03251     return(TRUE);
03252   }
03253   else
03254   {
03255     return(FALSE);
03256   }
03257 }

void Parameters::get_vdw_params Real sigma,
Real epsilon,
Real sigma14,
Real epsilon14,
Index  index
[inline]
 

Definition at line 400 of file Parameters.h.

References vdw_val::epsilon, vdw_val::epsilon14, vdw_val::sigma, and vdw_val::sigma14.

Referenced by Molecule::print_atoms().

00402         {
00403             if ( vdw_array ) {
00404                 *sigma = vdw_array[index].sigma;
00405                 *epsilon = vdw_array[index].epsilon;
00406                 *sigma14 = vdw_array[index].sigma14;
00407                 *epsilon14 = vdw_array[index].epsilon14;
00408             } else {
00409                 *sigma = 0.;
00410                 *epsilon = 0.;
00411                 *sigma14 = 0.;
00412                 *epsilon14 = 0.;
00413             }
00414         }

void Parameters::print_angle_params  ) 
 

Definition at line 4254 of file Parameters.C.

References DebugM, and NumAngleParams.

04255 {
04256   DebugM(3,NumAngleParams << " ANGLE PARAMETERS\n"
04257       << "*****************************************" );
04258   traverse_angle_params(anglep);
04259 }

void Parameters::print_bond_params  ) 
 

Definition at line 4236 of file Parameters.C.

References DebugM, and NumBondParams.

04237 {
04238   DebugM(3,NumBondParams << " BOND PARAMETERS\n" \
04239       << "*****************************************"  \
04240       );
04241 
04242   traverse_bond_params(bondp);
04243 }

void Parameters::print_crossterm_params  ) 
 

void Parameters::print_dihedral_params  ) 
 

Definition at line 4270 of file Parameters.C.

References DebugM, and NumDihedralParams.

04271 {
04272   DebugM(3,NumDihedralParams << " DIHEDRAL PARAMETERS\n" \
04273       << "*****************************************" );
04274 
04275   traverse_dihedral_params(dihedralp);
04276 }

void Parameters::print_improper_params  ) 
 

Definition at line 4287 of file Parameters.C.

References DebugM, and NumImproperParams.

04288 {
04289   DebugM(3,NumImproperParams << " IMPROPER PARAMETERS\n" \
04290       << "*****************************************" );
04291 
04292   traverse_improper_params(improperp);
04293 }

void Parameters::print_param_summary  ) 
 

Definition at line 4338 of file Parameters.C.

References iINFO(), iout, NumAngleParams, NumBondParams, NumCrosstermParams, NumDihedralParams, and NumImproperParams.

Referenced by NamdState::configListInit().

04339 {
04340   iout << iINFO << "SUMMARY OF PARAMETERS:\n" 
04341        << iINFO << NumBondParams << " BONDS\n" 
04342        << iINFO << NumAngleParams << " ANGLES\n"
04343        << iINFO << NumDihedralParams << " DIHEDRAL\n"
04344        << iINFO << NumImproperParams << " IMPROPER\n"
04345        << iINFO << NumCrosstermParams << " CROSSTERM\n"
04346        << iINFO << NumVdwParams << " VDW\n"
04347        << iINFO << NumVdwPairParams << " VDW_PAIRS\n" << endi;
04348 }

void Parameters::print_vdw_pair_params  ) 
 

Definition at line 4321 of file Parameters.C.

References DebugM.

04322 {
04323   DebugM(3,NumVdwPairParams << " vdW PAIR PARAMETERS\n" \
04324       << "*****************************************" );
04325 
04326   traverse_vdw_pair_params(vdw_pairp);
04327 }

void Parameters::print_vdw_params  ) 
 

Definition at line 4304 of file Parameters.C.

References DebugM.

04305 {
04306   DebugM(3,NumVdwParams << " vdW PARAMETERS\n" \
04307       << "*****************************************" );
04308 
04309   traverse_vdw_params(vdwp);
04310 }

void Parameters::read_charmm_parameter_file char *   ) 
 

Definition at line 464 of file Parameters.C.

References iout, iWARN(), NAMD_blank_string(), NAMD_die(), NAMD_find_first_word(), NAMD_read_line(), NumAngleParams, NumBondParams, NumCrosstermParams, NumDihedralParams, and NumImproperParams.

Referenced by Parameters().

00466 {
00467   int  par_type=0;         //  What type of parameter are we currently
00468                            //  dealing with? (vide infra)
00469   int  skipline;           //  skip this line?
00470   int  skipall = 0;        //  skip rest of file;
00471   char buffer[512];           //  Buffer to store each line of the file
00472   char first_word[512];           //  First word of the current line
00473   FILE *pfile;                   //  File descriptor