#include <Parameters.h>
|
|
Definition at line 186 of file Parameters.C. 00186 {
00187 initialize();
00188 }
|
|
||||||||||||
|
Definition at line 243 of file Parameters.C. References SimParameters::cosAngles, StringList::data, done_reading_files(), StringList::next, SimParameters::paraTypeCharmmOn, SimParameters::paraTypeXplorOn, read_charmm_parameter_file(), read_ener_table(), read_parameter_file(), simParams, and SimParameters::tabulatedEnergies. 00244 {
00245 initialize();
00246
00248 if (simParams->paraTypeXplorOn)
00249 {
00250 paramType = paraXplor;
00251 }
00252 else if (simParams->paraTypeCharmmOn)
00253 {
00254 paramType = paraCharmm;
00255 }
00256 //****** END CHARMM/XPLOR type changes
00257 //Test for cos-based angles
00258 if (simParams->cosAngles) {
00259 cosAngles = true;
00260 } else {
00261 cosAngles = false;
00262 }
00263
00264 if (simParams->tabulatedEnergies) {
00265 CkPrintf("Working on tables\n");
00266 read_ener_table(simParams);
00267 }
00268
00269 //****** BEGIN CHARMM/XPLOR type changes
00270 /* Set up AllFilesRead flag to FALSE. Once all of the files */
00271 /* have been read in, then this will be set to true and the */
00272 /* arrays of parameters will be set up */
00273 AllFilesRead = FALSE;
00274
00275 if (NULL != f)
00276 {
00277 do
00278 {
00279 //****** BEGIN CHARMM/XPLOR type changes
00280 if (paramType == paraXplor)
00281 {
00282 read_parameter_file(f->data);
00283 }
00284 else if (paramType == paraCharmm)
00285 {
00286 read_charmm_parameter_file(f->data);
00287 }
00288 //****** END CHARMM/XPLOR type changes
00289 f = f->next;
00290 } while ( f != NULL );
00291
00292 done_reading_files();
00293 }
00294
00295 }
|
|
||||||||||||
|
Definition at line 6251 of file Parameters.C. References Ambertoppar, and read_parm(). 06252 {
06253 initialize();
06254
06255 // Read in parm parameters
06256 read_parm(amber_data,vdw14);
06257 }
|
|
||||||||||||
|
Definition at line 6393 of file Parameters.C. References read_parm(). 06394 {
06395 initialize();
06396
06397 // Read in parm parameters
06398 read_parm(gf,min);
06399 }
|
|
|
Definition at line 307 of file Parameters.C. References angle_array, bond_array, crossterm_array, dihedral_array, improper_array, nbthole_pair_tree, ResizeArray< Elem >::resize(), ResizeArray< Elem >::size(), tab_pair_tree, vdw_array, and vdw_pair_tree. 00309 {
00310 if (atomTypeNames)
00311 delete [] atomTypeNames;
00312
00313 if (bondp != NULL)
00314 free_bond_tree(bondp);
00315
00316 if (anglep != NULL)
00317 free_angle_tree(anglep);
00318
00319 if (dihedralp != NULL)
00320 free_dihedral_list(dihedralp);
00321
00322 if (improperp != NULL)
00323 free_improper_list(improperp);
00324
00325 if (crosstermp != NULL)
00326 free_crossterm_list(crosstermp);
00327
00328 if (vdwp != NULL)
00329 free_vdw_tree(vdwp);
00330
00331 if (vdw_pairp != NULL)
00332 free_vdw_pair_list();
00333
00334 if (nbthole_pairp != NULL)
00335 free_nbthole_pair_list();
00336
00337 if (bond_array != NULL)
00338 delete [] bond_array;
00339
00340 if (angle_array != NULL)
00341 delete [] angle_array;
00342
00343 if (dihedral_array != NULL)
00344 delete [] dihedral_array;
00345
00346 if (improper_array != NULL)
00347 delete [] improper_array;
00348
00349 if (crossterm_array != NULL)
00350 delete [] crossterm_array;
00351
00352 if (vdw_array != NULL)
00353 delete [] vdw_array;
00354
00355 if (tab_pair_tree != NULL)
00356 free_table_pair_tree(tab_pair_tree);
00357
00358 if (vdw_pair_tree != NULL)
00359 free_vdw_pair_tree(vdw_pair_tree);
00360
00361 if (nbthole_pair_tree != NULL)
00362 free_nbthole_pair_tree(nbthole_pair_tree);
00363
00364 if (maxDihedralMults != NULL)
00365 delete [] maxDihedralMults;
00366
00367 if (maxImproperMults != NULL)
00368 delete [] maxImproperMults;
00369
00370 for( int i = 0; i < error_msgs.size(); ++i ) {
00371 delete [] error_msgs[i];
00372 }
00373 error_msgs.resize(0);
00374 }
|
|
||||||||||||||||||||||||
|
Definition at line 3818 of file Parameters.C. References Angle, angle::angle_type, angle::atom1, angle_params::atom1name, angle::atom2, angle_params::atom2name, angle::atom3, angle_params::atom3name, angle_params::index, iout, iWARN(), angle_params::left, NAMD_die(), and angle_params::right. 03821 {
03822 struct angle_params *ptr; // Current position in tree
03823 int comp_val; // value from strcasecmp
03824 int found=0; // flag 1->found a match
03825 char tmp_name[15]; // Temporary atom name
03826
03827 /* Check to make sure the files have all been read */
03828 if (!AllFilesRead)
03829 {
03830 NAMD_die("Tried to assign angle index before all parameter files were read");
03831 }
03832
03833 /* We need atom1 < atom3. If that was not what we were */
03834 /* passed, switch them */
03835 if (strcasecmp(atom1, atom3) > 0)
03836 {
03837 strcpy(tmp_name, atom1);
03838 strcpy(atom1, atom3);
03839 strcpy(atom3, tmp_name);
03840 }
03841
03842 /* Start at the top */
03843 ptr=anglep;
03844
03845 /* While we don't have a match and we haven't reached the */
03846 /* bottom of the tree, compare values */
03847 while (!found && (ptr != NULL))
03848 {
03849 comp_val = strcasecmp(atom1, ptr->atom1name);
03850
03851 if (comp_val == 0)
03852 {
03853 /* Atom 1 matches, so compare atom 2 */
03854 comp_val = strcasecmp(atom2, ptr->atom2name);
03855
03856 if (comp_val == 0)
03857 {
03858 /* Atoms 1&2 match, try atom 3 */
03859 comp_val = strcasecmp(atom3, ptr->atom3name);
03860 }
03861 }
03862
03863 if (comp_val == 0)
03864 {
03865 /* Found a match */
03866 found = 1;
03867 angle_ptr->angle_type = ptr->index;
03868 }
03869 else if (comp_val < 0)
03870 {
03871 /* Go left */
03872 ptr=ptr->left;
03873 }
03874 else
03875 {
03876 /* Go right */
03877 ptr=ptr->right;
03878 }
03879 }
03880
03881 /* Make sure we found a match */
03882 if (!found)
03883 {
03884 char err_msg[128];
03885
03886 sprintf(err_msg, "UNABLE TO FIND ANGLE PARAMETERS FOR %s %s %s (ATOMS %i %i %i)",
03887 atom1, atom2, atom3, angle_ptr->atom1+1, angle_ptr->atom2+1, angle_ptr->atom3+1);
03888
03889 if ( notFoundIndex ) {
03890 angle_ptr->angle_type = notFoundIndex;
03891 iout << iWARN << err_msg << "\n" << endi;
03892 return;
03893 } else NAMD_die(err_msg);
03894 }
03895
03896 return;
03897 }
|
|
||||||||||||||||
|
Definition at line 3721 of file Parameters.C. References bond::atom1, bond_params::atom1name, bond::atom2, bond_params::atom2name, Bond, bond::bond_type, bond_params::index, bond_params::left, NAMD_die(), and bond_params::right. 03723 {
03724 struct bond_params *ptr; // Current location in tree
03725 int found=0; // Flag 1-> found a match
03726 int cmp_code; // return code from strcasecmp
03727 char tmp_name[15]; // Temporary atom name
03728
03729 /* Check to make sure the files have all been read */
03730 if (!AllFilesRead)
03731 {
03732 NAMD_die("Tried to assign bond index before all parameter files were read");
03733 }
03734
03735 /* We need atom1 < atom2, so if that's not the way they */
03736 /* were passed, flip them */
03737 if (strcasecmp(atom1, atom2) > 0)
03738 {
03739 strcpy(tmp_name, atom1);
03740 strcpy(atom1, atom2);
03741 strcpy(atom2, tmp_name);
03742 }
03743
03744 /* Start at the top */
03745 ptr=bondp;
03746
03747 /* While we haven't found a match and we're not at the end */
03748 /* of the tree, compare the bond passed in with the tree */
03749 while (!found && (ptr!=NULL))
03750 {
03751 cmp_code=strcasecmp(atom1, ptr->atom1name);
03752
03753 if (cmp_code == 0)
03754 {
03755 cmp_code=strcasecmp(atom2, ptr->atom2name);
03756 }
03757
03758 if (cmp_code == 0)
03759 {
03760 /* Found a match */
03761 found=1;
03762 bond_ptr->bond_type = ptr->index;
03763 }
03764 else if (cmp_code < 0)
03765 {
03766 /* Go left */
03767 ptr=ptr->left;
03768 }
03769 else
03770 {
03771 /* Go right */
03772 ptr=ptr->right;
03773 }
03774 }
03775
03776 /* Check to see if we found anything */
03777 if (!found)
03778 {
03779 if ((strcmp(atom1, "DRUD")==0 || strcmp(atom2, "DRUD")==0)
03780 && (strcmp(atom1, "X")!=0 && strcmp(atom2, "X")!=0)) {
03781 /* try a wildcard DRUD X match for this Drude bond */
03782 char a1[8] = "DRUD", a2[8] = "X";
03783 return assign_bond_index(a1, a2, bond_ptr); /* recursive call */
03784 }
03785 else {
03786 char err_msg[128];
03787
03788 sprintf(err_msg, "UNABLE TO FIND BOND PARAMETERS FOR %s %s (ATOMS %i %i)",
03789 atom1, atom2, bond_ptr->atom1+1, bond_ptr->atom2+1);
03790 NAMD_die(err_msg);
03791 }
03792 }
03793
03794 return;
03795 }
|
|
||||||||||||||||||||||||||||||||||||||||
|
Definition at line 4125 of file Parameters.C. References crossterm::atom1, crossterm_params::atom1name, crossterm_params::atom2name, crossterm_params::atom3name, crossterm::atom4, crossterm_params::atom4name, crossterm_params::atom5name, crossterm_params::atom6name, crossterm_params::atom7name, crossterm::atom8, crossterm_params::atom8name, Crossterm, crossterm::crossterm_type, crossterm_params::index, NAMD_die(), and crossterm_params::next. 04128 {
04129 struct crossterm_params *ptr; // Current position in list
04130 int found=0; // Flag 1->found a match
04131
04132 /* Start at the head of the list */
04133 ptr=crosstermp;
04134
04135 /* While we haven't fuond a match and haven't reached the end */
04136 /* of the list, keep looking */
04137 while (!found && (ptr!=NULL))
04138 {
04139 /* Do a linear search through the linked list of */
04140 /* crossterm parameters. Since the list is arranged */
04141 /* with wildcard paramters at the end of the list, we */
04142 /* can simply do a linear search and be guaranteed that*/
04143 /* we will find exact matches before wildcard matches. */
04144 /* Also, we must check for an exact match, and a match */
04145 /* in reverse, since they are really the same */
04146 /* physically. */
04147 if ( ( (strcasecmp(ptr->atom1name, atom1)==0) ||
04148 (strcasecmp(ptr->atom1name, "X")==0) ) &&
04149 ( (strcasecmp(ptr->atom2name, atom2)==0) ||
04150 (strcasecmp(ptr->atom2name, "X")==0) ) &&
04151 ( (strcasecmp(ptr->atom3name, atom3)==0) ||
04152 (strcasecmp(ptr->atom3name, "X")==0) ) &&
04153 ( (strcasecmp(ptr->atom4name, atom4)==0) ||
04154 (strcasecmp(ptr->atom4name, "X")==0) ) )
04155 {
04156 /* Found an exact match */
04157 found=1;
04158 }
04159 else if ( ( (strcasecmp(ptr->atom4name, atom1)==0) ||
04160 (strcasecmp(ptr->atom4name, "X")==0) ) &&
04161 ( (strcasecmp(ptr->atom3name, atom2)==0) ||
04162 (strcasecmp(ptr->atom3name, "X")==0) ) &&
04163 ( (strcasecmp(ptr->atom2name, atom3)==0) ||
04164 (strcasecmp(ptr->atom2name, "X")==0) ) &&
04165 ( (strcasecmp(ptr->atom1name, atom4)==0) ||
04166 (strcasecmp(ptr->atom1name, "X")==0) ) )
04167 {
04168 /* Found a reverse match */
04169 found=1;
04170 }
04171 if ( ! found ) {
04172 /* Didn't find a match, go to the next node */
04173 ptr=ptr->next;
04174 continue;
04175 }
04176 found = 0;
04177 if ( ( (strcasecmp(ptr->atom5name, atom5)==0) ||
04178 (strcasecmp(ptr->atom5name, "X")==0) ) &&
04179 ( (strcasecmp(ptr->atom6name, atom6)==0) ||
04180 (strcasecmp(ptr->atom6name, "X")==0) ) &&
04181 ( (strcasecmp(ptr->atom7name, atom7)==0) ||
04182 (strcasecmp(ptr->atom7name, "X")==0) ) &&
04183 ( (strcasecmp(ptr->atom8name, atom8)==0) ||
04184 (strcasecmp(ptr->atom8name, "X")==0) ) )
04185 {
04186 /* Found an exact match */
04187 found=1;
04188 }
04189 else if ( ( (strcasecmp(ptr->atom8name, atom5)==0) ||
04190 (strcasecmp(ptr->atom8name, "X")==0) ) &&
04191 ( (strcasecmp(ptr->atom7name, atom6)==0) ||
04192 (strcasecmp(ptr->atom7name, "X")==0) ) &&
04193 ( (strcasecmp(ptr->atom6name, atom7)==0) ||
04194 (strcasecmp(ptr->atom6name, "X")==0) ) &&
04195 ( (strcasecmp(ptr->atom5name, atom8)==0) ||
04196 (strcasecmp(ptr->atom5name, "X")==0) ) )
04197 {
04198 /* Found a reverse match */
04199 found=1;
04200 }
04201 if ( ! found ) {
04202 /* Didn't find a match, go to the next node */
04203 ptr=ptr->next;
04204 }
04205 }
04206
04207 /* Make sure we found a match */
04208 if (!found)
04209 {
04210 char err_msg[128];
04211
04212 sprintf(err_msg, "UNABLE TO FIND CROSSTERM PARAMETERS FOR %s %s %s %s %s %s %s %s\n"
04213 "(ATOMS %i %i %i %i %i %i %i %i)",
04214 atom1, atom2, atom3, atom4, atom5, atom6, atom7, atom8,
04215 crossterm_ptr->atom1+1, crossterm_ptr->atom1+2, crossterm_ptr->atom1+3, crossterm_ptr->atom4+1,
04216 crossterm_ptr->atom1+5, crossterm_ptr->atom1+6, crossterm_ptr->atom1+7, crossterm_ptr->atom8+1);
04217
04218 NAMD_die(err_msg);
04219 }
04220
04221 /* Assign the constants */
04222 crossterm_ptr->crossterm_type = ptr->index;
04223
04224 return;
04225 }
|
|
||||||||||||||||||||||||||||||||
|
Definition at line 3921 of file Parameters.C. References dihedral::atom1, dihedral_params::atom1name, dihedral_params::atom1wild, dihedral::atom2, dihedral_params::atom2name, dihedral_params::atom2wild, dihedral::atom3, dihedral_params::atom3name, dihedral_params::atom3wild, dihedral::atom4, dihedral_params::atom4name, dihedral_params::atom4wild, Dihedral, dihedral_array, dihedral::dihedral_type, dihedral_params::index, iout, iWARN(), DihedralValue::multiplicity, NAMD_die(), and dihedral_params::next. 03925 {
03926 struct dihedral_params *ptr; // Current position in list
03927 int found=0; // Flag 1->found a match
03928
03929 /* Start at the begining of the list */
03930 ptr=dihedralp;
03931
03932 /* While we haven't found a match and we haven't reached */
03933 /* the end of the list, keep looking */
03934 while (!found && (ptr!=NULL))
03935 {
03936 /* Do a linear search through the linked list of */
03937 /* dihedral parameters. Since the list is arranged */
03938 /* with wildcard paramters at the end of the list, we */
03939 /* can simply do a linear search and be guaranteed that*/
03940 /* we will find exact matches before wildcard matches. */
03941 /* Also, we must check for an exact match, and a match */
03942 /* in reverse, since they are really the same */
03943 /* physically. */
03944 if ( ( ptr->atom1wild || (strcasecmp(ptr->atom1name, atom1)==0) ) &&
03945 ( ptr->atom2wild || (strcasecmp(ptr->atom2name, atom2)==0) ) &&
03946 ( ptr->atom3wild || (strcasecmp(ptr->atom3name, atom3)==0) ) &&
03947 ( ptr->atom4wild || (strcasecmp(ptr->atom4name, atom4)==0) ) )
03948 {
03949 /* Found an exact match */
03950 found=1;
03951 }
03952 else if ( ( ptr->atom4wild || (strcasecmp(ptr->atom4name, atom1)==0) ) &&
03953 ( ptr->atom3wild || (strcasecmp(ptr->atom3name, atom2)==0) ) &&
03954 ( ptr->atom2wild || (strcasecmp(ptr->atom2name, atom3)==0) ) &&
03955 ( ptr->atom1wild || (strcasecmp(ptr->atom1name, atom4)==0) ) )
03956 {
03957 /* Found a reverse match */
03958 found=1;
03959 }
03960 else
03961 {
03962 /* Didn't find a match, go to the next node */
03963 ptr=ptr->next;
03964 }
03965 }
03966
03967 /* Make sure we found a match */
03968 if (!found)
03969 {
03970 char err_msg[128];
03971
03972 sprintf(err_msg, "UNABLE TO FIND DIHEDRAL PARAMETERS FOR %s %s %s %s (ATOMS %i %i %i %i)",
03973 atom1, atom2, atom3, atom4, dihedral_ptr->atom1+1, dihedral_ptr->atom2+1,
03974 dihedral_ptr->atom3+1, dihedral_ptr->atom4+1);
03975
03976 if ( notFoundIndex ) {
03977 dihedral_ptr->dihedral_type = notFoundIndex;
03978 iout << iWARN << err_msg << "\n" << endi;
03979 return;
03980 } else NAMD_die(err_msg);
03981 }
03982
03983 // Check to make sure the number of multiples specified in the psf
03984 // file doesn't exceed the number of parameters in the parameter
03985 // files
03986 if (multiplicity > maxDihedralMults[ptr->index])
03987 {
03988 char err_msg[257];
03989
03990 sprintf(err_msg, "Multiplicity of Paramters for diehedral bond %s %s %s %s of %d exceeded", atom1, atom2, atom3, atom4, maxDihedralMults[ptr->index]);
03991 NAMD_die(err_msg);
03992 }
03993
03994 // If the multiplicity from the current bond is larger than that
03995 // seen in the past, increase the multiplicity for this bond
03996 if (multiplicity > dihedral_array[ptr->index].multiplicity)
03997 {
03998 dihedral_array[ptr->index].multiplicity = multiplicity;
03999 }
04000
04001 dihedral_ptr->dihedral_type = ptr->index;
04002
04003 return;
04004 }
|
|
||||||||||||||||||||||||||||
|
Definition at line 4028 of file Parameters.C. References improper::atom1, improper_params::atom1name, improper::atom2, improper_params::atom2name, improper::atom3, improper_params::atom3name, improper::atom4, improper_params::atom4name, Improper, improper_array, improper::improper_type, improper_params::index, ImproperValue::multiplicity, NAMD_die(), and improper_params::next. 04032 {
04033 struct improper_params *ptr; // Current position in list
04034 int found=0; // Flag 1->found a match
04035
04036 /* Start at the head of the list */
04037 ptr=improperp;
04038
04039 /* While we haven't fuond a match and haven't reached the end */
04040 /* of the list, keep looking */
04041 while (!found && (ptr!=NULL))
04042 {
04043 /* Do a linear search through the linked list of */
04044 /* improper parameters. Since the list is arranged */
04045 /* with wildcard paramters at the end of the list, we */
04046 /* can simply do a linear search and be guaranteed that*/
04047 /* we will find exact matches before wildcard matches. */
04048 /* Also, we must check for an exact match, and a match */
04049 /* in reverse, since they are really the same */
04050 /* physically. */
04051 if ( ( (strcasecmp(ptr->atom1name, atom1)==0) ||
04052 (strcasecmp(ptr->atom1name, "X")==0) ) &&
04053 ( (strcasecmp(ptr->atom2name, atom2)==0) ||
04054 (strcasecmp(ptr->atom2name, "X")==0) ) &&
04055 ( (strcasecmp(ptr->atom3name, atom3)==0) ||
04056 (strcasecmp(ptr->atom3name, "X")==0) ) &&
04057 ( (strcasecmp(ptr->atom4name, atom4)==0) ||
04058 (strcasecmp(ptr->atom4name, "X")==0) ) )
04059 {
04060 /* Found an exact match */
04061 found=1;
04062 }
04063 else if ( ( (strcasecmp(ptr->atom4name, atom1)==0) ||
04064 (strcasecmp(ptr->atom4name, "X")==0) ) &&
04065 ( (strcasecmp(ptr->atom3name, atom2)==0) ||
04066 (strcasecmp(ptr->atom3name, "X")==0) ) &&
04067 ( (strcasecmp(ptr->atom2name, atom3)==0) ||
04068 (strcasecmp(ptr->atom2name, "X")==0) ) &&
04069 ( (strcasecmp(ptr->atom1name, atom4)==0) ||
04070 (strcasecmp(ptr->atom1name, "X")==0) ) )
04071 {
04072 /* Found a reverse match */
04073 found=1;
04074 }
04075 else
04076 {
04077 /* Didn't find a match, go to the next node */
04078 ptr=ptr->next;
04079 }
04080 }
04081
04082 /* Make sure we found a match */
04083 if (!found)
04084 {
04085 char err_msg[128];
04086
04087 sprintf(err_msg, "UNABLE TO FIND IMPROPER PARAMETERS FOR %s %s %s %s (ATOMS %i %i %i %i)",
04088 atom1, atom2, atom3, atom4, improper_ptr->atom1+1, improper_ptr->atom2+1,
04089 improper_ptr->atom3+1, improper_ptr->atom4+1);
04090
04091 NAMD_die(err_msg);
04092 }
04093
04094 // Check to make sure the number of multiples specified in the psf
04095 // file doesn't exceed the number of parameters in the parameter
04096 // files
04097 if (multiplicity > maxImproperMults[ptr->index])
04098 {
04099 char err_msg[257];
04100
04101 sprintf(err_msg, "Multiplicity of Paramters for improper bond %s %s %s %s of %d exceeded", atom1, atom2, atom3, atom4, maxImproperMults[ptr->index]);
04102 NAMD_die(err_msg);
04103 }
04104
04105 // If the multiplicity from the current bond is larger than that
04106 // seen in the past, increase the multiplicity for this bond
04107 if (multiplicity > improper_array[ptr->index].multiplicity)
04108 {
04109 improper_array[ptr->index].multiplicity = multiplicity;
04110 }
04111
04112 /* Assign the constants */
04113 improper_ptr->improper_type = ptr->index;
04114
04115 return;
04116 }
|
|
||||||||||||
|
Definition at line 3433 of file Parameters.C. References Atom, vdw_params::atomname, vdw_params::index, iout, iWARN(), vdw_params::left, NAMD_die(), and vdw_params::right. 03435 {
03436 struct vdw_params *ptr; // Current position in trees
03437 int found=0; // Flag 1->found match
03438 int comp_code; // return code from strcasecmp
03439
03440 /* Check to make sure the files have all been read */
03441 if (!AllFilesRead)
03442 {
03443 NAMD_die("Tried to assign vdw index before all parameter files were read");
03444 }
03445
03446 /* Start at the top */
03447 ptr=vdwp;
03448
03449 /* While we haven't found a match, and we haven't reached */
03450 /* the bottom of the tree, compare the atom passed in with */
03451 /* the current value and decide if we have a match, or if not, */
03452 /* which way to go */
03453 while (!found && (ptr!=NULL))
03454 {
03455 comp_code = strcasecmp(atomtype, ptr->atomname);
03456
03457 if (comp_code == 0)
03458 {
03459 /* Found a match! */
03460 atom_ptr->vdw_type=ptr->index;
03461 found=1;
03462 }
03463 else if (comp_code < 0)
03464 {
03465 /* Go to the left */
03466 ptr=ptr->left;
03467 }
03468 else
03469 {
03470 /* Go to the right */
03471 ptr=ptr->right;
03472 }
03473 }
03474
03475 //****** BEGIN CHARMM/XPLOR type changes
03476 if (!found)
03477 {
03478 // since CHARMM allows wildcards "*" in vdw typenames
03479 // we have to look again if necessary, this way, if
03480 // we already had an exact match, this is never executed
03481 size_t windx; // wildcard index
03482
03483 /* Start again at the top */
03484 ptr=vdwp;
03485
03486 while (!found && (ptr!=NULL))
03487 {
03488
03489 // get index of wildcard wildcard, get index
03490 windx= strcspn(ptr->atomname,"*");
03491 if (windx == strlen(ptr->atomname))
03492 {
03493 // there is no wildcard here
03494 comp_code = strcasecmp(atomtype, ptr->atomname);
03495 }
03496 else
03497 {
03498 comp_code = strncasecmp(atomtype, ptr->atomname, windx);
03499 }
03500
03501 if (comp_code == 0)
03502 {
03503 /* Found a match! */
03504 atom_ptr->vdw_type=ptr->index;
03505 found=1;
03506 char errbuf[100];
03507 sprintf(errbuf,"VDW TYPE NAME %s MATCHES PARAMETER TYPE NAME %s",
03508 atomtype, ptr->atomname);
03509 int i;
03510 for(i=0; i<error_msgs.size(); i++) {
03511 if ( strcmp(errbuf,error_msgs[i]) == 0 ) break;
03512 }
03513 if ( i == error_msgs.size() ) {
03514 char *newbuf = new char[strlen(errbuf)+1];
03515 strcpy(newbuf,errbuf);
03516 error_msgs.add(newbuf);
03517 iout << iWARN << newbuf << "\n" << endi;
03518 }
03519 }
03520 else if (comp_code < 0)
03521 {
03522 /* Go to the left */
03523 ptr=ptr->left;
03524 }
03525 else
03526 {
03527 /* Go to the right */
03528 ptr=ptr->right;
03529 }
03530
03531 }
03532
03533 }
03534 //****** END CHARMM/XPLOR type changes
03535
03536 /* Make sure we found it */
03537 if (!found)
03538 {
03539 char err_msg[100];
03540
03541 sprintf(err_msg, "DIDN'T FIND vdW PARAMETER FOR ATOM TYPE %s",
03542 atomtype);
03543 NAMD_die(err_msg);
03544 }
03545
03546 return;
03547 }
|
|
|
Definition at line 369 of file Parameters.h. References MAX_ATOMTYPE_CHARS. 00369 {
00370 return (atomTypeNames + (a * (MAX_ATOMTYPE_CHARS + 1)));
00371 }
|
|
|
Definition at line 2961 of file Parameters.C. References angle_array, bond_array, crossterm_array, dihedral_array, improper_array, MAX_ATOMTYPE_CHARS, NAMD_die(), nbthole_array, NbtholePairValue, NumCrosstermParams, NumDihedralParams, NumImproperParams, NumVdwParams, NumVdwParamsAssigned, vdw_array, and VdwValue. Referenced by Parameters(). 02963 {
02964 AllFilesRead = TRUE;
02965
02966 // Allocate space for all of the arrays
02967 if (NumBondParams)
02968 {
02969 bond_array = new BondValue[NumBondParams];
02970
02971 if (bond_array == NULL)
02972 {
02973 NAMD_die("memory allocation of bond_array failed!");
02974 }
02975 }
02976
02977 if (NumAngleParams)
02978 {
02979 angle_array = new AngleValue[NumAngleParams];
02980
02981 if (angle_array == NULL)
02982 {
02983 NAMD_die("memory allocation of angle_array failed!");
02984 }
02985 }
02986
02987 if (NumDihedralParams)
02988 {
02989 dihedral_array = new DihedralValue[NumDihedralParams];
02990
02991 if (dihedral_array == NULL)
02992 {
02993 NAMD_die("memory allocation of dihedral_array failed!");
02994 }
02995 memset(dihedral_array, 0, NumDihedralParams*sizeof(DihedralValue));
02996 }
02997
02998 if (NumImproperParams)
02999 {
03000 improper_array = new ImproperValue[NumImproperParams];
03001
03002 if (improper_array == NULL)
03003 {
03004 NAMD_die("memory allocation of improper_array failed!");
03005 }
03006 memset(improper_array, 0, NumImproperParams*sizeof(ImproperValue));
03007 }
03008
03009 if (NumCrosstermParams)
03010 {
03011 crossterm_array = new CrosstermValue[NumCrosstermParams];
03012 memset(crossterm_array, 0, NumCrosstermParams*sizeof(CrosstermValue));
03013 }
03014
03015 if (NumVdwParams)
03016 {
03017 atomTypeNames = new char[NumVdwParams*(MAX_ATOMTYPE_CHARS+1)];
03018 vdw_array = new VdwValue[NumVdwParams];
03019
03020 if (vdw_array == NULL)
03021 {
03022 NAMD_die("memory allocation of vdw_array failed!");
03023 }
03024 }
03025 if (NumNbtholePairParams)
03026 {
03027 nbthole_array = new NbtholePairValue[NumNbtholePairParams];
03028
03029 if(nbthole_array == NULL)
03030 {
03031 NAMD_die("memory allocation of nbthole_array failed!");
03032 }
03033 }
03034 // Assign indexes to each of the parameters and populate the
03035 // arrays using the binary trees and linked lists that we have
03036 // already read in
03037 index_bonds(bondp, 0);
03038 index_angles(anglep, 0);
03039 NumVdwParamsAssigned = index_vdw(vdwp, 0);
03040 index_dihedrals();
03041 index_impropers();
03042 index_crossterms();
03043 convert_nbthole_pairs();
03044 // Convert the vdw pairs
03045 convert_vdw_pairs();
03046 convert_table_pairs();
03047 }
|
|
|
Definition at line 4960 of file Parameters.C. 04962 {
04963 if (bondp != NULL)
04964 free_bond_tree(bondp);
04965
04966 if (anglep != NULL)
04967 free_angle_tree(anglep);
04968
04969 if (dihedralp != NULL)
04970 free_dihedral_list(dihedralp);
04971
04972 if (improperp != NULL)
04973 free_improper_list(improperp);
04974
04975 if (crosstermp != NULL)
04976 free_crossterm_list(crosstermp);
04977
04978 if (vdwp != NULL)
04979 free_vdw_tree(vdwp);
04980
04981 // Free the arrays used to track multiplicity for dihedrals
04982 // and impropers
04983 if (maxDihedralMults != NULL)
04984 delete [] maxDihedralMults;
04985
04986 if (maxImproperMults != NULL)
04987 delete [] maxImproperMults;
04988
04989 bondp=NULL;
04990 anglep=NULL;
04991 dihedralp=NULL;
04992 improperp=NULL;
04993 crosstermp=NULL;
04994 vdwp=NULL;
04995 maxImproperMults=NULL;
04996 maxDihedralMults=NULL;
04997 }
|
|
||||||||||||||||||||||||
|
Definition at line 429 of file Parameters.h. References AngleValue::k, AngleValue::k_ub, AngleValue::r_ub, and AngleValue::theta0. 00431 {
00432 *k = angle_array[index].k;
00433 *theta0 = angle_array[index].theta0;
00434 *k_ub = angle_array[index].k_ub;
00435 *r_ub = angle_array[index].r_ub;
00436 }
|
|
||||||||||||||||
|
Definition at line 423 of file Parameters.h. References BondValue::k, and BondValue::x0. Referenced by Molecule::print_bonds(). 00424 {
00425 *k = bond_array[index].k;
00426 *x0 = bond_array[index].x0;
00427 }
|
|
|
Definition at line 443 of file Parameters.h. References DihedralValue::multiplicity. 00444 {
00445 return(dihedral_array[index].multiplicity);
00446 }
|
|
||||||||||||||||||||||||
|
Definition at line 461 of file Parameters.h. References four_body_consts::delta, four_body_consts::k, four_body_consts::n, NAMD_die(), and DihedralValue::values. 00463 {
00464 if ( (mult<0) || (mult>MAX_MULTIPLICITY) )
00465 {
00466 NAMD_die("Bad mult index in Parameters::get_dihedral_params");
00467 }
00468
00469 *k = dihedral_array[index].values[mult].k;
00470 *n = dihedral_array[index].values[mult].n;
00471 *delta = dihedral_array[index].values[mult].delta;
00472 }
|
|
|
Definition at line 438 of file Parameters.h. References ImproperValue::multiplicity. 00439 {
00440 return(improper_array[index].multiplicity);
00441 }
|
|
||||||||||||||||||||||||
|
Definition at line 448 of file Parameters.h. References four_body_consts::delta, four_body_consts::k, four_body_consts::n, NAMD_die(), and ImproperValue::values. 00450 {
00451 if ( (mult<0) || (mult>MAX_MULTIPLICITY) )
00452 {
00453 NAMD_die("Bad mult index in Parameters::get_improper_params");
00454 }
00455
00456 *k = improper_array[index].values[mult].k;
00457 *n = improper_array[index].values[mult].n;
00458 *delta = improper_array[index].values[mult].delta;
00459 }
|
|
|
Definition at line 7441 of file Parameters.C. References table_types. 07441 {
07442 for (int i=0; i<tablenumtypes; i++) {
07443 if (!strncmp(tabletype, table_types[i], 5)) {
07444 return i;
07445 }
07446 }
07447
07448 return -1;
07449 }
|
|
|
Definition at line 508 of file Parameters.h. Referenced by LJTable::LJTable(). 00508 { return NumVdwParamsAssigned; }
|
|
||||||||||||||||
|
Definition at line 3568 of file Parameters.C. References indexed_table_pair::ind1, indexed_table_pair::ind2, Index, IndexedTablePair, indexed_table_pair::K, indexed_table_pair::left, and indexed_table_pair::right. 03568 {
03569 IndexedTablePair *ptr;
03570 Index temp;
03571 int found=FALSE;
03572
03573 ptr=tab_pair_tree;
03574 //
03575 // We need the smaller type in ind1, so if it isn't already that
03576 // way, switch them */
03577 if (ind1 > ind2)
03578 {
03579 temp = ind1;
03580 ind1 = ind2;
03581 ind2 = temp;
03582 }
03583
03584 /* While we haven't found a match and we're not at the end */
03585 /* of the tree, compare the bond passed in with the tree */
03586 while (!found && (ptr!=NULL))
03587 {
03588 // printf("Comparing %i with %i and %i with %i\n", ind1, ptr->ind1, ind2, ptr->ind2);
03589 if ( (ind1 == ptr->ind1) && (ind2 == ptr->ind2) )
03590 {
03591 found = TRUE;
03592 }
03593 else if ( (ind1 < ptr->ind1) ||
03594 ( (ind1==ptr->ind1) && (ind2 < ptr->ind2) ) )
03595 {
03596 /* Go left */
03597 ptr=ptr->left;
03598 }
03599 else
03600 {
03601 /* Go right */
03602 ptr=ptr->right;
03603 }
03604 }
03605
03606 /* If we found a match, assign the values */
03607 if (found)
03608 {
03609 *K = ptr->K;
03610 return(TRUE);
03611 }
03612 else
03613 {
03614 return(FALSE);
03615 }
03616 }
|
|
||||||||||||||||||||||||||||
|
Definition at line 3643 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. 03646 {
03647 IndexedVdwPair *ptr; // Current location in tree
03648 Index temp; // Temporary value for swithcing
03649 // values
03650 int found=FALSE; // Flag 1-> found a match
03651
03652 ptr=vdw_pair_tree;
03653
03654 // We need the smaller type in ind1, so if it isn't already that
03655 // way, switch them */
03656 if (ind1 > ind2)
03657 {
03658 temp = ind1;
03659 ind1 = ind2;
03660 ind2 = temp;
03661 }
03662
03663 /* While we haven't found a match and we're not at the end */
03664 /* of the tree, compare the bond passed in with the tree */
03665 while (!found && (ptr!=NULL))
03666 {
03667 if ( (ind1 == ptr->ind1) && (ind2 == ptr->ind2) )
03668 {
03669 found = TRUE;
03670 }
03671 else if ( (ind1 < ptr->ind1) ||
03672 ( (ind1==ptr->ind1) && (ind2 < ptr->ind2) ) )
03673 {
03674 /* Go left */
03675 ptr=ptr->left;
03676 }
03677 else
03678 {
03679 /* Go right */
03680 ptr=ptr->right;
03681 }
03682 }
03683
03684 /* If we found a match, assign the values */
03685 if (found)
03686 {
03687 *A = ptr->A;
03688 *B = ptr->B;
03689 *A14 = ptr->A14;
03690 *B14 = ptr->B14;
03691
03692 return(TRUE);
03693 }
03694 else
03695 {
03696 return(FALSE);
03697 }
03698 }
|
|
||||||||||||||||||||||||
|
Definition at line 474 of file Parameters.h. References cbrt, vdw_val::epsilon, vdw_val::epsilon14, NAMD_die(), Real, vdw_val::sigma, and vdw_val::sigma14. Referenced by Molecule::print_atoms(). 00476 {
00477 if ( vdw_array ) {
00478 *sigma = vdw_array[index].sigma;
00479 *epsilon = vdw_array[index].epsilon;
00480 *sigma14 = vdw_array[index].sigma14;
00481 *epsilon14 = vdw_array[index].epsilon14;
00482 } else {
00483 // sigma and epsilon from A and B for each vdw type's interaction with itself
00484 Real A; Real B; Real A14; Real B14;
00485 if (get_vdw_pair_params(index, index, &A, &B, &A14, &B14) ) {
00486 if (A && B) {
00487 *sigma = sqrt(cbrt(A)) / sqrt(cbrt(B));
00488 *epsilon = B*B / (4*A);
00489 }
00490 else {
00491 *sigma = 0; *epsilon = 0;
00492 }
00493 if (A14 && B14) {
00494 *sigma14 = sqrt(cbrt(A14)) / sqrt(cbrt(B14));
00495 *epsilon14 = B14*B14 / (4*A14);
00496 }
00497 else {
00498 *sigma14 = 0; *epsilon14 = 0;
00499 }
00500 }
00501 else {NAMD_die ("Function get_vdw_params failed to derive Lennard-Jones sigma and epsilon from A and B values\n");}
00502 }
00503 }
|
|
|
Definition at line 4826 of file Parameters.C. References DebugM, and NumAngleParams. 04827 {
04828 DebugM(3,NumAngleParams << " ANGLE PARAMETERS\n"
04829 << "*****************************************" );
04830 traverse_angle_params(anglep);
04831 }
|
|
|
Definition at line 4808 of file Parameters.C. References DebugM, and NumBondParams. 04809 {
04810 DebugM(3,NumBondParams << " BOND PARAMETERS\n" \
04811 << "*****************************************" \
04812 );
04813
04814 traverse_bond_params(bondp);
04815 }
|
|
|
|
|
|
Definition at line 4842 of file Parameters.C. References DebugM, and NumDihedralParams. 04843 {
04844 DebugM(3,NumDihedralParams << " DIHEDRAL PARAMETERS\n" \
04845 << "*****************************************" );
04846
04847 traverse_dihedral_params(dihedralp);
04848 }
|
|
|
Definition at line 4859 of file Parameters.C. References DebugM, and NumImproperParams. 04860 {
04861 DebugM(3,NumImproperParams << " IMPROPER PARAMETERS\n" \
04862 << "*****************************************" );
04863
04864 traverse_improper_params(improperp);
04865 }
|
|
|
Definition at line 4910 of file Parameters.C. References DebugM, and NumNbtholePairParams. 04911 {
04912 DebugM(3,NumNbtholePairParams << " NBTHOLE PAIR PARAMETERS\n" \
04913 << "*****************************************" );
04914
04915 traverse_nbthole_pair_params(nbthole_pairp);
04916 }
|
|
|
Definition at line 4927 of file Parameters.C. References iINFO(), iout, NumAngleParams, NumBondParams, NumCosAngles, NumCrosstermParams, NumDihedralParams, NumImproperParams, NumNbtholePairParams, NumVdwPairParams, and NumVdwParams. Referenced by NamdState::configListInit(). 04928 {
04929 iout << iINFO << "SUMMARY OF PARAMETERS:\n"
04930 << iINFO << NumBondParams << " BONDS\n"
04931 << iINFO << NumAngleParams << " ANGLES\n" << endi;
04932 if (cosAngles) {
04933 iout << iINFO << " " << (NumAngleParams - NumCosAngles) << " HARMONIC\n"
04934 << iINFO << " " << NumCosAngles << " COSINE-BASED\n" << endi;
04935 }
04936 iout << iINFO << NumDihedralParams << " DIHEDRAL\n"
04937 << iINFO << NumImproperParams << " IMPROPER\n"
04938 << iINFO << NumCrosstermParams << " CROSSTERM\n"
04939 << iINFO << NumVdwParams << " VDW\n"
04940 << iINFO << NumVdwPairParams << " VDW_PAIRS\n"
04941 << iINFO << NumNbtholePairParams << " NBTHOLE_PAIRS\n" << endi;
04942 }
|
|
|
Definition at line 4893 of file Parameters.C. References DebugM, and NumVdwPairParams. 04894 {
04895 DebugM(3,NumVdwPairParams << " vdW PAIR PARAMETERS\n" \
04896 << "*****************************************" );
04897
04898 traverse_vdw_pair_params(vdw_pairp);
04899 }
|
|
|
Definition at line 4876 of file Parameters.C. References DebugM, and NumVdwParams. 04877 {
04878 DebugM(3,NumVdwParams << " vdW PARAMETERS\n" \
04879 << "*****************************************" );
04880
04881 traverse_vdw_params(vdwp);
04882 }
|
|
|
Definition at line 528 of file Parameters.C. References iout, iWARN(), NAMD_blank_string(), NAMD_die(), NAMD_find_first_word(), NAMD_read_line(), NumAngleParams, NumBondParams, NumCrosstermParams, NumDihedralParams, NumImproperParams, NumNbtholePairParams, NumTablePairParams, NumVdwPairParams, NumVdwParams, and table_ener. Referenced by Parameters(). 00530 {
00531 int par_type=0; // What type of parameter are we currently
00532 // dealing with? (vide infra)
00533 int skipline; // skip this line?
00534 int skipall = 0; // skip rest of file;
00535 char buffer[512]; // Buffer to store each line of the file
00536 char first_word[512]; // First word of the current line
00537 FILE *pfile; // File descriptor for the parameter file
00538
00539 /* Check to make sure that we haven't previously been told */
00540 /* that all the files were read */
00541 if (AllFilesRead)
00542 {
00543 NAMD_die("Tried to read another parameter file after being told that all files were read!");
00544 }
00545
00546 /* Try and open the file */
00547 if ( (pfile = fopen(fname, "r")) == NULL)
00548 {
00549 char err_msg[256];
00550
00551 sprintf(err_msg, "UNABLE TO OPEN CHARMM PARAMETER FILE %s\n", fname);
00552 NAMD_die(err_msg);
00553 }
00554
00555 /* Keep reading in lines until we hit the EOF */
00556 while (NAMD_read_line(pfile, buffer) != -1)
00557 {
00558 /* Get the first word of the line */
00559 NAMD_find_first_word(buffer, first_word);
00560 skipline=0;
00561
00562 /* First, screen out things that we ignore. */
00563 /* blank lines, lines that start with '!' or '*', lines that */
00564 /* start with "END". */
00565 if (!NAMD_blank_string(buffer) &&
00566 (strncmp(first_word, "!", 1) != 0) &&
00567 (strncmp(first_word, "*", 1) != 0) &&
00568 (strncasecmp(first_word, "END", 3) != 0))
00569 {
00570 if ( skipall ) {
00571 iout << iWARN << "SKIPPING PART OF PARAMETER FILE AFTER RETURN STATEMENT\n" << endi;
00572 break;
00573 }
00574 /* Now, determine the apropriate parameter type. */
00575 if (strncasecmp(first_word, "bond", 4)==0)
00576 {
00577 par_type=1; skipline=1;
00578 }
00579 else if (strncasecmp(first_word, "angl", 4)==0)
00580 {
00581 par_type=2; skipline=1;
00582 }
00583 else if (strncasecmp(first_word, "thet", 4)==0)
00584 {
00585 par_type=2; skipline=1;
00586 }
00587 else if (strncasecmp(first_word, "dihe", 4)==0)
00588 {
00589 par_type=3; skipline=1;
00590 }
00591 else if (strncasecmp(first_word, "phi", 3)==0)
00592 {
00593 par_type=3; skipline=1;
00594 }
00595 else if (strncasecmp(first_word, "impr", 4)==0)
00596 {
00597 par_type=4; skipline=1;
00598 }
00599 else if (strncasecmp(first_word, "imph", 4)==0)
00600 {
00601 par_type=4; skipline=1;
00602 }
00603 else if (strncasecmp(first_word, "nbon", 4)==0)
00604 {
00605 par_type=5; skipline=1;
00606 }
00607 else if (strncasecmp(first_word, "nonb", 4)==0)
00608 {
00609 par_type=5; skipline=1;
00610 }
00611 else if (strncasecmp(first_word, "nbfi", 4)==0)
00612 {
00613 par_type=6; skipline=1;
00614 }
00615 else if (strncasecmp(first_word, "hbon", 4)==0)
00616 {
00617 par_type=7; skipline=1;
00618 }
00619 else if (strncasecmp(first_word, "cmap", 4)==0)
00620 {
00621 par_type=8; skipline=1;
00622 }
00623 else if (strncasecmp(first_word, "nbta", 4)==0)
00624 {
00625 par_type=9; skipline=1;
00626 }
00627 else if (strncasecmp(first_word, "thol", 4)==0)
00628 {
00629 par_type=10; skipline=1;
00630 }
00631 else if (strncasecmp(first_word, "atom", 4)==0)
00632 {
00633 par_type=11; skipline=1;
00634 }
00635 else if (strncasecmp(first_word, "read", 4)==0)
00636 {
00637 skip_stream_read(buffer, pfile); skipline=1;
00638 }
00639 else if (strncasecmp(first_word, "return", 4)==0)
00640 {
00641 skipall=1; skipline=1;
00642 }
00643 else if ((strncasecmp(first_word, "nbxm", 4) == 0) ||
00644 (strncasecmp(first_word, "grou", 4) == 0) ||
00645 (strncasecmp(first_word, "cdie", 4) == 0) ||
00646 (strncasecmp(first_word, "shif", 4) == 0) ||
00647 (strncasecmp(first_word, "vgro", 4) == 0) ||
00648 (strncasecmp(first_word, "vdis", 4) == 0) ||
00649 (strncasecmp(first_word, "vswi", 4) == 0) ||
00650 (strncasecmp(first_word, "cutn", 4) == 0) ||
00651 (strncasecmp(first_word, "ctof", 4) == 0) ||
00652 (strncasecmp(first_word, "cton", 4) == 0) ||
00653 (strncasecmp(first_word, "eps", 3) == 0) ||
00654 (strncasecmp(first_word, "e14f", 4) == 0) ||
00655 (strncasecmp(first_word, "wmin", 4) == 0) ||
00656 (strncasecmp(first_word, "aexp", 4) == 0) ||
00657 (strncasecmp(first_word, "rexp", 4) == 0) ||
00658 (strncasecmp(first_word, "haex", 4) == 0) ||
00659 (strncasecmp(first_word, "aaex", 4) == 0) ||
00660 (strncasecmp(first_word, "noac", 4) == 0) ||
00661 (strncasecmp(first_word, "hbno", 4) == 0) ||
00662 (strncasecmp(first_word, "cuth", 4) == 0) ||
00663 (strncasecmp(first_word, "ctof", 4) == 0) ||
00664 (strncasecmp(first_word, "cton", 4) == 0) ||
00665 (strncasecmp(first_word, "cuth", 4) == 0) ||
00666 (strncasecmp(first_word, "ctof", 4) == 0) ||
00667 (strncasecmp(first_word, "cton", 4) == 0) )
00668 {
00669 if ((par_type != 5) && (par_type != 6) && (par_type != 7) && (par_type != 9))
00670 {
00671 char err_msg[512];
00672
00673 sprintf(err_msg, "ERROR IN CHARMM PARAMETER FILE %s\nLINE=*%s*",fname, buffer);
00674 NAMD_die(err_msg);
00675 }
00676 else
00677 {
00678 skipline = 1;
00679 }
00680 }
00681 else if (par_type == 0)
00682 {
00683 /* This is an unknown paramter. */
00684 /* This is BAD */
00685 char err_msg[512];
00686
00687 sprintf(err_msg, "UNKNOWN PARAMETER IN CHARMM PARAMETER FILE %s\nLINE=*%s*",fname, buffer);
00688 NAMD_die(err_msg);
00689 }
00690 }
00691 else
00692 {
00693 skipline=1;
00694 }
00695
00696 if ( (par_type != 0) && (!skipline) )
00697 {
00698 /* Now, call the appropriate function based */
00699 /* on the type of parameter we have */
00700 /* I know, this should really be a switch ... */
00701 if (par_type == 1)
00702 {
00703 add_bond_param(buffer);
00704 NumBondParams++;
00705 }
00706 else if (par_type == 2)
00707 {
00708 add_angle_param(buffer);
00709 NumAngleParams++;
00710 }
00711 else if (par_type == 3)
00712 {
00713 add_dihedral_param(buffer, pfile);
00714 NumDihedralParams++;
00715 }
00716 else if (par_type == 4)
00717 {
00718 add_improper_param(buffer, pfile);
00719 NumImproperParams++;
00720 }
00721 else if (par_type == 5)
00722 {
00723 add_vdw_param(buffer);
00724 NumVdwParams++;
00725 }
00726 else if (par_type == 6)
00727 {
00728 add_vdw_pair_param(buffer);
00729 NumVdwPairParams++;
00730 }
00731 else if (par_type == 7)
00732 {
00733 add_hb_pair_param(buffer);
00734 }
00735 else if (par_type == 8)
00736 {
00737 add_crossterm_param(buffer, pfile);
00738 NumCrosstermParams++;
00739 }
00740 else if (par_type == 9)
00741 {
00742
00743 if (table_ener == NULL) {
00744 continue;
00745 }
00746
00747 add_table_pair_param(buffer);
00748 NumTablePairParams++;
00749 }
00750 else if (par_type == 10)
00751 {
00752 add_nbthole_pair_param(buffer);
00753 NumNbtholePairParams++;
00754 }
00755 else if (par_type == 11)
00756 {
00757 if ( strncasecmp(first_word, "mass", 4) != 0 ) {
00758 char err_msg[512];
00759 sprintf(err_msg, "UNKNOWN PARAMETER IN CHARMM PARAMETER FILE %s\nLINE=*%s*",fname, buffer);
00760 NAMD_die(err_msg);
00761 }
00762 }
00763 else
00764 {
00765 /* This really should not occour! */
00766 /* This is an internal error. */
00767 /* This is VERY BAD */
00768 char err_msg[512];
00769
00770 sprintf(err_msg, "INTERNAL ERROR IN CHARMM PARAMETER FILE %s\nLINE=*%s*",fname, buffer);
00771 NAMD_die(err_msg);
00772 }
00773 }
00774 }
00775
00776 /* Close the file */
00777 fclose(pfile);
00778
00779 return;
00780 }
|
|
|
Definition at line 6605 of file Parameters.C. References BigReal, SimParameters::cutoff, iout, mynearbyint, NAMD_die(), numenerentries, read_energy_type(), read_energy_type_bothcubspline(), Real, simParams, table_ener, table_spacing, table_types, SimParameters::tableInterpType, SimParameters::tableMaxDist, tablenumtypes, SimParameters::tableNumTypes, SimParameters::tableSpacing, and SimParameters::tabulatedEnergiesFile. Referenced by Parameters(). 06605 {
06606 char* table_file = simParams->tabulatedEnergiesFile;
06607 char* interp_type = simParams->tableInterpType;
06608 FILE* enertable;
06609 enertable = fopen(table_file, "r");
06610
06611 if (enertable == NULL) {
06612 NAMD_die("ERROR: Could not open energy table file!\n");
06613 }
06614
06615 char tableline[121];
06616 char* newtypename;
06617 int numtypes;
06618 int atom1;
06619 int atom2;
06620 int distbin;
06621 int readcount;
06622 Real dist;
06623 Real energy;
06624 Real force;
06625 Real table_spacing;
06626 Real maxdist;
06627
06628 /* First find the header line and set the variables we need */
06629 iout << "Beginning table read\n" << endi;
06630 while(fgets(tableline,120,enertable)) {
06631 if (strncmp(tableline,"#",1)==0) {
06632 continue;
06633 }
06634 readcount = sscanf(tableline, "%i %f %f", &numtypes, &table_spacing, &maxdist);
06635 if (readcount != 3) {
06636 NAMD_die("ERROR: Couldn't parse table header line\n");
06637 }
06638 break;
06639 }
06640
06641 if (maxdist < simParams->cutoff) {
06642 NAMD_die("Tabulated energies must at least extend to the cutoff distance\n");
06643 }
06644
06645 if (maxdist > simParams->cutoff) {
06646 iout << "Info: Reducing max table size to match nonbond cutoff\n";
06647 maxdist = ceil(simParams->cutoff);
06648 }
06649
06650 /* Now allocate memory for the table; we know what we should be getting */
06651 numenerentries = 2 * numtypes * int (mynearbyint(maxdist/table_spacing) + 1);
06652 //Set up a full energy lookup table from a file
06653 //Allocate the table; layout is atom1 x atom2 x distance energy force
06654 fprintf(stdout, "Table has %i entries\n",numenerentries);
06655 //iout << "Allocating original energy table\n" << endi;
06656 if ( table_ener ) delete [] table_ener;
06657 table_ener = new BigReal[numenerentries];
06658 if ( table_types ) delete [] table_types;
06659 table_types = new char*[numtypes];
06660
06661 /* Finally, start reading the table */
06662 int numtypesread = 0; //Number of types read so far
06663
06664 while(fgets(tableline,120,enertable)) {
06665 if (strncmp(tableline,"#",1)==0) {
06666 continue;
06667 }
06668 if (strncmp(tableline,"TYPE",4)==0) {
06669 // Read a new type
06670 newtypename = new char[5];
06671 int readcount = sscanf(tableline, "%*s %s", newtypename);
06672 if (readcount != 1) {
06673 NAMD_die("Couldn't read interaction type from TYPE line\n");
06674 }
06675 // printf("Setting table_types[%i] to %s\n", numtypesread, newtypename);
06676 table_types[numtypesread] = newtypename;
06677
06678 if (numtypesread == numtypes) {
06679 NAMD_die("Error: Number of types in table doesn't match table header\n");
06680 }
06681
06682 // Read the current energy type with the proper interpolation
06683 if (!strncasecmp(interp_type, "linear", 6)) {
06684 if (read_energy_type(enertable, numtypesread, table_ener, table_spacing, maxdist) != 0) {
06685 char err_msg[512];
06686 sprintf(err_msg, "Failed to read table energy (linear) type %s\n", newtypename);
06687 NAMD_die(err_msg);
06688 }
06689 } else if (!strncasecmp(interp_type, "cubic", 5)) {
06690 if (read_energy_type_bothcubspline(enertable, numtypesread, table_ener, table_spacing, maxdist) != 0) {
06691 char err_msg[512];
06692 sprintf(err_msg, "Failed to read table energy (cubic) type %s\n", newtypename);
06693 NAMD_die(err_msg);
06694 }
06695 } else {
06696 NAMD_die("Table interpolation type must be linear or cubic\n");
06697 }
06698
06699 numtypesread++;
06700 continue;
06701 }
06702 //char err_msg[512];
06703 //sprintf(err_msg, "Unrecognized line in energy table file: %s\n", tableline);
06704 //NAMD_die(err_msg);
06705 }
06706
06707 // See if we got what we expected
06708 if (numtypesread != numtypes) {
06709 char err_msg[512];
06710 sprintf(err_msg, "ERROR: Expected %i tabulated energy types but got %i\n", numtypes, numtypesread);
06711 NAMD_die(err_msg);
06712 }
06713
06714 // Move the necessary information into simParams
06715 simParams->tableNumTypes = numtypes;
06716 simParams->tableSpacing = table_spacing;
06717 simParams->tableMaxDist = maxdist;
06718 tablenumtypes = numtypes;
06719
06720 /*
06721 xxxxxx
06722 int numtypes = simParams->tableNumTypes;
06723
06724 //This parameter controls the table spacing
06725 BigReal table_spacing = 0.01;
06726 BigReal maxdist = 20.0;
06727 if (maxdist > simParams->cutoff) {
06728 iout << "Info: Reducing max table size to match nonbond cutoff\n";
06729 maxdist = ceil(simParams->cutoff);
06730 }
06731
06732 numenerentries = (numtypes + 1) * numtypes * int (ceil(maxdist/table_spacing));
06733 // fprintf(stdout, "Table arithmetic: maxdist %f, table_spacing %f, numtypes %i, numentries %i\n", maxdist, table_spacing, numtypes, numenerentries);
06734 columnsize = 2 * mynearbyint(maxdist/table_spacing);
06735 rowsize = numtypes * columnsize;
06736 //Set up a full energy lookup table from a file
06737 //Allocate the table; layout is atom1 x atom2 x distance energy force
06738 fprintf(stdout, "Table has %i entries\n",numenerentries);
06739 //iout << "Allocating original energy table\n" << endi;
06740 if ( table_ener ) delete [] table_ener;
06741 table_ener = new Real[numenerentries];
06742 //
06743 //Set sentinel values for uninitialized table energies
06744 for (int i=0 ; i<numenerentries ; i++) {
06745 table_ener[i] = 1337.0;
06746 }
06747 Real compval = 1337.0;
06748
06749 // iout << "Entering table reading\n" << endi;
06750 //iout << "Finished allocating table\n" << endi;
06751
06752 //Counter to make sure we read the right number of energy entries
06753 int numentries = 0;
06754
06755 //Now, start reading from the file
06756 char* table_file = simParams->tabulatedEnergiesFile;
06757 FILE* enertable;
06758 enertable = fopen(table_file, "r");
06759
06760 if (enertable == NULL) {
06761 NAMD_die("ERROR: Could not open energy table file!\n");
06762 }
06763
06764 char tableline[121];
06765 int atom1;
06766 int atom2;
06767 int distbin;
06768 Real dist;
06769 Real energy;
06770 Real force;
06771
06772 iout << "Beginning table read\n" << endi;
06773 //Read the table entries
06774 while(fgets(tableline,120,enertable)) {
06775 // IOut << "Processing line " << tableline << "\n" << endi;
06776 if (strncmp(tableline,"#",1)==0) {
06777 continue;
06778 }
06779
06780
06781 sscanf(tableline, "%i %i %f %f %f\n", &atom1, &atom2, &dist, &energy, &force);
06782 distbin = int(mynearbyint(dist/table_spacing));
06783 // fprintf(stdout, "Working on atoms %i and %i at distance %f\n",atom1,atom2,dist);
06784 if ((atom2 > atom1) || (distbin > int(mynearbyint(maxdist/table_spacing)))) {
06785 // fprintf(stdout,"Rejected\n");
06786 // fprintf(stdout, "Error: Throwing out energy line beyond bounds\n");
06787 // fprintf(stdout, "Bad line: Atom 1: %i Atom 2: %i Distance Bin: %i Max Distance Bin: %i \n", atom1, atom2, distbin, int(mynearbyint(maxdist/table_spacing)));
06788 } else {
06789 //The magic formula for the number of columns from previous rows
06790 //in the triangular matrix is (2ni+i-i**2)/2
06791 //Here n is the number of types, and i is atom2
06792 // fprintf(stdout, "Input: atom1 %f atom2 %f columnsize %f \n", float(atom1), float(atom2), float(columnsize));
06793 // fprintf(stdout, "Testing arithmetic: Part1: %i Part2: %i Part3: %i Total: %i\n", columnsize*((2*numtypes*atom2 + atom2 - atom2*atom2)/2), columnsize*(atom1-atom2), 2*distbin, columnsize*((2*numtypes*atom2 + atom2 - atom2*atom2)/2) + columnsize*(atom1-atom2) + 2*distbin - 2);
06794 int eneraddress = columnsize*((2*numtypes*atom2 + atom2 - atom2*atom2)/2) + columnsize*(atom1-atom2) + 2*distbin - 2;
06795 int forceaddress = eneraddress + 1;
06796 // fprintf(stdout, "Tableloc: %i Atom 1: %i Atom 2: %i Distance Bin: %i Energy: %f Force: %f\n", eneraddress, atom1, atom2, distbin, table_ener[eneraddress], table_ener[forceaddress]);
06797 fflush(stdout);
06798 // fprintf(stdout, "Checking for dupes: Looking at: %f %f \n", table_ener[eneraddress], table_ener[forceaddress]);
06799 if ((table_ener[eneraddress] == compval && table_ener[forceaddress] == compval)) {
06800 numentries++;
06801 table_ener[eneraddress] = energy;
06802 table_ener[forceaddress] = force;
06803 // fprintf(stdout, "Tableloc: %i Atom 1: %i Atom 2: %i Distance Bin: %i Energy: %f Force: %f\n", eneraddress, atom1, atom2, distbin, table_ener[eneraddress], table_ener[forceaddress]);
06804 //table_ener[rowsize*atom2 + columnsize*atom1 + 2*distbin] = energy;
06805 //table_ener[rowsize*atom2 + columnsize*atom1 + 2*distbin + 1] = force;
06806 // fflush(stdout);
06807 } else {
06808 // fprintf(stdout,"Rejecting duplicate entry\n");
06809 }
06810 }
06811 // iout << "Done with line\n"<< endi;
06812 }
06813
06814 // int should = numtypes * numtypes * (maxdist/table_spacing);
06815 // cout << "Entries: " << numentries << " should be " << should << "\n" << endi;
06816 // int exptypes = ceil((numtypes+1) * numtypes * (maxdist/table_spacing));
06817 //fprintf(stdout,"numtypes: %i maxdist: %f table_spacing: %f exptypes: %i\n",numtypes,maxdist,table_spacing);
06818 if (numentries != int(numenerentries/2)) {
06819 fprintf(stdout,"ERROR: Expected %i entries but got %i\n",numenerentries/2, numentries);
06820 NAMD_die("Number of energy table entries did not match expected value\n");
06821 }
06822 // iout << "Done with table\n"<< endi;
06823 fprintf(stdout, "Numenerentries: %i\n",numenerentries/2);
06824 */
06825 } /* END of function read_ener_table */
|
|
||||||||||||||||||||||||
|
Definition at line 7323 of file Parameters.C. References BigReal, mynearbyint, NAMD_die(), and table_spacing. Referenced by read_ener_table(). 07323 {
07324
07325 char tableline[120];
07326
07327 /* Last values read from table */
07328 BigReal readdist;
07329 BigReal readener;
07330 BigReal readforce;
07331 BigReal lastdist;
07332 BigReal lastener;
07333 BigReal lastforce;
07334 readdist = -1.0;
07335 readener = 0.0;
07336 readforce = 0.0;
07337
07338 /* Keep track of where in the table we are */
07339 float currdist;
07340 int distbin;
07341 currdist = -1.0;
07342 distbin = -1;
07343
07344 while(fgets(tableline,120,enertable) && distbin <= (int) (mynearbyint(maxdist / table_spacing) + 1)) {
07345 printf("At distance %f + %f vs. %f\n", currdist, table_spacing, maxdist);
07346 if (strncmp(tableline,"#",1)==0) {
07347 continue;
07348 }
07349 if (strncmp(tableline,"TYPE",4)==0) {
07350 break;
07351 }
07352
07353 // Read an energy line from the table
07354 lastdist = readdist;
07355 lastener = readener;
07356 lastforce = readforce;
07357 int readcount = sscanf(tableline, "%lf %lf %lf", &readdist, &readener, &readforce);
07358 if (distbin == -1) {
07359 if (readdist != 0.0) {
07360 NAMD_die("ERROR: Energy/force tables must start at d=0.0\n");
07361 } else {
07362 distbin = 0;
07363 continue;
07364 }
07365 }
07366 // printf("Read an energy line: %f %f %f\n", readdist, readener, readforce);
07367 if (readcount != 3) {
07368 char err_msg[512];
07369 sprintf(err_msg, "ERROR: Failed to parse table line %s!\n", tableline);
07370 NAMD_die(err_msg);
07371 }
07372
07373 //Sanity check the current entry
07374 if (readdist < lastdist) {
07375 NAMD_die("ERROR: Encountered badly ordered entries in energy table!\n");
07376 }
07377
07378 currdist = lastdist;
07379
07380 while (currdist <= readdist && distbin <= (int) (mynearbyint(maxdist / table_spacing))) {
07381 distbin = (int) (mynearbyint(currdist / table_spacing));
07382 int table_loc = 2 * (distbin + (typeindex * (1 + (int) mynearbyint(maxdist / table_spacing))));
07383 printf("Doing interpolation for energy between %f %f and %f %f: Dist %f\n", readener, readdist, lastener, lastdist, currdist);
07384 table_ener[table_loc] = interp_lin(readener, lastener, readdist, lastdist, currdist);
07385 table_ener[table_loc + 1] = interp_lin(readforce, lastforce, readdist, lastdist, currdist);
07386 printf("Adding energy/force entry: %f %f in distbin %i (distance %f) to address %i/%i\n", table_ener[table_loc], table_ener[table_loc + 1], distbin, currdist, table_loc, table_loc + 1);
07387 currdist += table_spacing;
07388 distbin++;
07389 }
07390 }
07391
07392 // Go back one line, since we should now be into the next TYPE block
07393 fseek(enertable, -1 * (long) strlen(tableline), SEEK_CUR);
07394
07395 // Clean up and make sure everything worked ok
07396 distbin--;
07397 printf("Testing: %i vs %i (from %f / %f)\n", distbin, (int) (mynearbyint(maxdist / table_spacing)), maxdist, table_spacing);
07398 if (distbin != (int) (mynearbyint(maxdist / table_spacing))) return 1;
07399 return 0;
07400 }
|
|
||||||||||||||||||||||||
|
Definition at line 6848 of file Parameters.C. References BigReal, INDEX, j, mynearbyint, NAMD_die(), and table_spacing. Referenced by read_ener_table(). 06848 {
06849
06850 char tableline[120];
06851 int i,j;
06852
06853 /* Last values read from table */
06854 BigReal readdist;
06855 BigReal readener;
06856 BigReal readforce;
06857 BigReal spacing;
06858 // BigReal readforce;
06859 BigReal lastdist;
06860 // BigReal lastener;
06861 // BigReal lastforce;
06862 // readdist = -1.0;
06863 // readener = 0.0;
06864 // readforce = 0.0;
06865
06866 /* Create arrays for holding the input values */
06867 std::vector<BigReal> dists;
06868 std::vector<BigReal> enervalues;
06869 std::vector<BigReal> forcevalues;
06870 int numentries = 0;
06871
06872
06873 /* Keep track of where in the table we are */
06874 BigReal currdist;
06875 int distbin;
06876 currdist = 0.0;
06877 lastdist = -1.0;
06878 distbin = 0;
06879
06880 // Read all of the values first -- we'll interpolate later
06881 while(fgets(tableline,120,enertable) && distbin <= (int) (mynearbyint(maxdist / table_spacing) + 1)) {
06882 if (strncmp(tableline,"#",1)==0) {
06883 continue;
06884 }
06885 if (strncmp(tableline,"TYPE",4)==0) {
06886 fseek(enertable, -1 * (long) strlen(tableline), SEEK_CUR);
06887 break;
06888 }
06889
06890 // Read an energy line from the table
06891 int readcount = sscanf(tableline, "%lf %lf %lf", &readdist, &readener, &readforce);
06892
06893 //printf("Read an energy line: %g %g %g\n", readdist, readener, readforce);
06894 if (readcount != 3) {
06895 char err_msg[512];
06896 sprintf(err_msg, "ERROR: Failed to parse table line %s!\n", tableline);
06897 NAMD_die(err_msg);
06898 }
06899
06900 //Sanity check the current entry
06901 if (readdist < lastdist) {
06902 NAMD_die("ERROR: Encountered badly ordered entries in energy table!\n");
06903 }
06904
06905 lastdist = readdist;
06906 dists.push_back(readdist);
06907 enervalues.push_back(readener);
06908 forcevalues.push_back(readforce);
06909 numentries++;
06910 }
06911
06912 // Check the spacing and make sure it is uniform
06913 if (dists[0] != 0.0) {
06914 NAMD_die("ERROR: First data point for energy table must be at r=0\n");
06915 }
06916 spacing = dists[1] - dists[0];
06917 for (i=2; i<(numentries - 1); i++) {
06918 BigReal myspacing;
06919 myspacing = dists[i] - dists[i-1];
06920 if (fabs(myspacing - spacing) > 0.00001) {
06921 printf("Bad spacing in table: %f should be %f (between distances %f and %f)\n", myspacing, spacing, dists[i-1], dists[i]);
06922 NAMD_die("ERROR: Nonuniform table encountered on cubic interpolation. Use a uniformly spaced table or switch to linear interpolation.\n");
06923 }
06924 }
06925
06926 // Perform cubic spline interpolation to get the energies and forces
06927
06928 /* allocate spline coefficient matrix */
06929 // xe and xf / be and bf for energies and forces, respectively
06930 double* m = new double[numentries*numentries];
06931 double* xe = new double[numentries];
06932 double* xf = new double[numentries];
06933 double* be = new double[numentries];
06934 double* bf = new double[numentries];
06935
06936 be[0] = 3 * (enervalues[1] - enervalues[0]);
06937 for (i=1; i < (numentries - 1); i++) {
06938 // printf("Control point %i at %f\n", i, enervalues[i]);
06939 be[i] = 3 * (enervalues[i+1] - enervalues[i-1]);
06940 // printf("be is %f\n", be[i]);
06941 }
06942 be[numentries - 1] = 3 * (enervalues[numentries - 1] - enervalues[numentries - 2]);
06943
06944 bf[0] = 3 * (forcevalues[1] - forcevalues[0]);
06945 for (i=1; i < (numentries - 1); i++) {
06946 // printf("Control point %i at %f\n", i, forcevalues[i]);
06947 bf[i] = 3 * (forcevalues[i+1] - forcevalues[i-1]);
06948 // printf("bf is %f\n", bf[i]);
06949 }
06950 bf[numentries - 1] = 3 * (forcevalues[numentries - 1] - forcevalues[numentries - 2]);
06951
06952 memset(m,0,numentries*numentries*sizeof(double));
06953
06954 /* initialize spline coefficient matrix */
06955 m[0] = 2;
06956 for (i = 1; i < numentries; i++) {
06957 m[INDEX(numentries,i-1,i)] = 1;
06958 m[INDEX(numentries,i,i-1)] = 1;
06959 m[INDEX(numentries,i,i)] = 4;
06960 }
06961 m[INDEX(numentries,numentries-1,numentries-1)] = 2;
06962
06963 /* Now we need to solve the equation M X = b for X */
06964 // Do this simultaneously for energy and force -- ONLY because we use the same matrix
06965
06966 //Put m in upper triangular form and apply corresponding operations to b
06967 for (i=0; i<numentries; i++) {
06968 // zero the ith column in all rows below i
06969 const BigReal baseval = m[INDEX(numentries,i,i)];
06970 for (j=i+1; j<numentries; j++) {
06971 const BigReal myval = m[INDEX(numentries,j,i)];
06972 const BigReal factor = myval / baseval;
06973
06974 for (int k=i; k<numentries; k++) {
06975 const BigReal subval = m[INDEX(numentries,i,k)];
06976 m[INDEX(numentries,j,k)] -= (factor * subval);
06977 }
06978
06979 be[j] -= (factor * be[i]);
06980 bf[j] -= (factor * bf[i]);
06981
06982 }
06983 }
06984
06985 //Now work our way diagonally up from the bottom right to assign values to X
06986 for (i=numentries-1; i>=0; i--) {
06987
06988 //Subtract the effects of previous columns
06989 for (j=i+1; j<numentries; j++) {
06990 be[i] -= ( m[INDEX(numentries,i,j)] * xe[j] );
06991 bf[i] -= ( m[INDEX(numentries,i,j)] * xf[j] );
06992 }
06993
06994 xe[i] = be[i] / m[INDEX(numentries,i,i)];
06995 xf[i] = bf[i] / m[INDEX(numentries,i,i)];
06996
06997 }
06998
06999 // We now have the coefficient information we need to make the table
07000 // Now interpolate on each interval we want
07001
07002 distbin = 0;
07003 int entriesperseg = (int) ceil(spacing / table_spacing);
07004 int table_prefix = 2 * typeindex * (int) (mynearbyint(maxdist / table_spacing) + 1);
07005
07006 for (i=0; i<numentries-1; i++) {
07007 BigReal Ae,Be,Ce,De;
07008 BigReal Af,Bf,Cf,Df;
07009 currdist = dists[i];
07010
07011 // printf("Interpolating on interval %i\n", i);
07012
07013 // Set up the coefficients for this section
07014 Ae = enervalues[i];
07015 Be = xe[i];
07016 Ce = 3 * (enervalues[i+1] - enervalues[i]) - (2 * xe[i]) - xe[i+1];
07017 De = 2 * (enervalues[i] - enervalues[i+1]) + xe[i] + xe[i+1];
07018
07019 Af = forcevalues[i];
07020 Bf = xf[i];
07021 Cf = 3 * (forcevalues[i+1] - forcevalues[i]) - (2 * xf[i]) - xf[i+1];
07022 Df = 2 * (forcevalues[i] - forcevalues[i+1]) + xf[i] + xf[i+1];
07023
07024 // Go over the region of interest and fill in the table
07025 for (j=0; j<entriesperseg; j++) {
07026 const BigReal mydist = currdist + (j * table_spacing);
07027 const BigReal mydistfrac = (float) j / (entriesperseg - 1);
07028 distbin = (int) mynearbyint(mydist / table_spacing);
07029 if (distbin >= (int) mynearbyint(maxdist / table_spacing)) break;
07030 BigReal energy;
07031 BigReal force;
07032
07033 energy = Ae + (Be * mydistfrac) + (Ce * mydistfrac * mydistfrac) + (De * mydistfrac * mydistfrac * mydistfrac);
07034 force = Af + (Bf * mydistfrac) + (Cf * mydistfrac * mydistfrac) + (Df * mydistfrac * mydistfrac * mydistfrac);
07035
07036 // printf("Adding energy/force entry %f / %f in bins %i / %i for distance %f (%f)\n", energy, force, (table_prefix + 2 * distbin), (table_prefix + 2 * distbin + 1), mydist, mydistfrac);
07037 table_ener[table_prefix + 2 * distbin] = energy;
07038 table_ener[table_prefix + 2 * distbin + 1] = force;
07039 distbin++;
07040 }
07041 if (currdist >= maxdist) break;
07042 }
07043
07044 //The procedure above leaves out the last entry -- add it explicitly
07045 distbin = (int) mynearbyint(maxdist / table_spacing);
07046 // printf("Adding energy/force entry %f / %f in bins %i / %i\n", enervalues[numentries - 1], 0.0, (table_prefix + 2 * distbin), (table_prefix + 2 * distbin + 1));
07047 table_ener[table_prefix + 2 * distbin] = enervalues[numentries - 1];
07048 table_ener[table_prefix + 2 * distbin + 1] = 0.0;
07049 distbin++;
07050
07051
07052 // Clean up and make sure everything worked ok
07053 delete m;
07054 delete xe;
07055 delete xf;
07056 delete be;
07057 delete bf;
07058 distbin--;
07059 printf("Testing: %i vs %i (from %f / %f)\n", distbin, (int) (mynearbyint(maxdist / table_spacing)), maxdist, table_spacing);
07060 if (distbin != (int) (mynearbyint(maxdist / table_spacing))) return 1;
07061 return 0;
07062 } /* end read_energy_type_bothcubspline */
|
|
||||||||||||||||||||||||
|
Definition at line 7084 of file Parameters.C. References BigReal, INDEX, j, mynearbyint, NAMD_die(), and table_spacing. 07084 {
07085
07086 char tableline[120];
07087 int i,j;
07088
07089 /* Last values read from table */
07090 BigReal readdist;
07091 BigReal readener;
07092 BigReal spacing;
07093 // BigReal readforce;
07094 BigReal lastdist;
07095 // BigReal lastener;
07096 // BigReal lastforce;
07097 // readdist = -1.0;
07098 // readener = 0.0;
07099 // readforce = 0.0;
07100
07101 /* Create arrays for holding the input values */
07102 std::vector<BigReal> dists;
07103 std::vector<BigReal> enervalues;
07104 int numentries = 0;
07105
07106
07107 /* Keep track of where in the table we are */
07108 BigReal currdist;
07109 int distbin;
07110 currdist = 0.0;
07111 lastdist = -1.0;
07112 distbin = 0;
07113
07114 // Read all of the values first -- we'll interpolate later
07115 while(fgets(tableline,120,enertable) && distbin <= (int) (mynearbyint(maxdist / table_spacing) + 1)) {
07116 if (strncmp(tableline,"#",1)==0) {
07117 continue;
07118 }
07119 if (strncmp(tableline,"TYPE",4)==0) {
07120 fseek(enertable, -1 * (long) strlen(tableline), SEEK_CUR);
07121 break;
07122 }
07123
07124 // Read an energy line from the table
07125 int readcount = sscanf(tableline, "%lf %lf", &readdist, &readener);
07126
07127 // printf("Read an energy line: %f %f %f\n", readdist, readener, readforce);
07128 if (readcount != 2) {
07129 char err_msg[512];
07130 sprintf(err_msg, "ERROR: Failed to parse table line %s!\n", tableline);
07131 NAMD_die(err_msg);
07132 }
07133
07134 //Sanity check the current entry
07135 if (readdist < lastdist) {
07136 NAMD_die("ERROR: Encountered badly ordered entries in energy table!\n");
07137 }
07138
07139 lastdist = readdist;
07140 dists.push_back(readdist);
07141 enervalues.push_back(readener);
07142 numentries++;
07143 }
07144
07145 // Check the spacing and make sure it is uniform
07146 if (dists[0] != 0.0) {
07147 NAMD_die("ERROR: First data point for energy table must be at r=0\n");
07148 }
07149 spacing = dists[1] - dists[0];
07150 for (i=2; i<(numentries - 1); i++) {
07151 BigReal myspacing;
07152 myspacing = dists[i] - dists[i-1];
07153 if (fabs(myspacing - spacing) > 0.00001) {
07154 printf("Bad spacing in table: %f should be %f (between distances %f and %f)\n", myspacing, spacing, dists[i-1], dists[i]);
07155 NAMD_die("ERROR: Nonuniform table encountered on cubic interpolation. Use a uniformly spaced table or switch to linear interpolation.\n");
07156 }
07157 }
07158
07159 // Perform cubic spline interpolation to get the energies and forces
07160
07161 /* allocate spline coefficient matrix */
07162 double* m = new double[numentries*numentries];
07163 double* x = new double[numentries];
07164 double* b = new double[numentries];
07165
07166 b[0] = 3 * (enervalues[1] - enervalues[0]);
07167 for (i=1; i < (numentries - 1); i++) {
07168 printf("Control point %i at %f\n", i, enervalues[i]);
07169 b[i] = 3 * (enervalues[i+1] - enervalues[i-1]);
07170 printf("b is %f\n", b[i]);
07171 }
07172 b[numentries - 1] = 3 * (enervalues[numentries - 1] - enervalues[numentries - 2]);
07173
07174 memset(m,0,numentries*numentries*sizeof(double));
07175
07176 /* initialize spline coefficient matrix */
07177 m[0] = 2;
07178 for (i = 1; i < numentries; i++) {
07179 m[INDEX(numentries,i-1,i)] = 1;
07180 m[INDEX(numentries,i,i-1)] = 1;
07181 m[INDEX(numentries,i,i)] = 4;
07182 }
07183 m[INDEX(numentries,numentries-1,numentries-1)] = 2;
07184
07185 /* Now we need to solve the equation M X = b for X */
07186
07187 printf("Solving the matrix equation: \n");
07188
07189 for (i=0; i<numentries; i++) {
07190 printf(" ( ");
07191 for (j=0; j<numentries; j++) {
07192 printf(" %6.3f,", m[INDEX(numentries, i, j)]);
07193 }
07194 printf(" ) ( D%-3i ) = ( %6.3f )\n", i, b[i]);
07195 }
07196
07197 //Put m in upper triangular form and apply corresponding operations to b
07198 for (i=0; i<numentries; i++) {
07199 // zero the ith column in all rows below i
07200 const BigReal baseval = m[INDEX(numentries,i,i)];
07201 for (j=i+1; j<numentries; j++) {
07202 const BigReal myval = m[INDEX(numentries,j,i)];
07203 const BigReal factor = myval / baseval;
07204
07205 for (int k=i; k<numentries; k++) {
07206 const BigReal subval = m[INDEX(numentries,i,k)];
07207 m[INDEX(numentries,j,k)] -= (factor * subval);
07208 }
07209
07210 b[j] -= (factor * b[i]);
07211
07212 }
07213 }
07214
07215 printf(" In upper diagonal form, equation is:\n");
07216 for (i=0; i<numentries; i++) {
07217 printf(" ( ");
07218 for (j=0; j<numentries; j++) {
07219 printf(" %6.3f,", m[INDEX(numentries, i, j)]);
07220 }
07221 printf(" ) ( D%-3i ) = ( %6.3f )\n", i, b[i]);
07222 }
07223
07224 //Now work our way diagonally up from the bottom right to assign values to X
07225 for (i=numentries-1; i>=0; i--) {
07226
07227 //Subtract the effects of previous columns
07228 for (j=i+1; j<numentries; j++) {
07229 b[i] -= ( m[INDEX(numentries,i,j)] * x[j] );
07230 }
07231
07232 x[i] = b[i] / m[INDEX(numentries,i,i)];
07233
07234 }
07235
07236 printf(" Solution vector is:\n\t(");
07237 for (i=0; i<numentries; i++) {
07238 printf(" %6.3f ", x[i]);
07239 }
07240 printf(" ) \n");
07241
07242 // We now have the coefficient information we need to make the table
07243 // Now interpolate on each interval we want
07244
07245 distbin = 0;
07246 int entriesperseg = (int) ceil(spacing / table_spacing);
07247 int table_prefix = 2 * typeindex * (int) (mynearbyint(maxdist / table_spacing) + 1);
07248
07249 for (i=0; i<numentries-1; i++) {
07250 BigReal A,B,C,D;
07251 currdist = dists[i];
07252
07253 printf("Interpolating on interval %i\n", i);
07254
07255 // Set up the coefficients for this section
07256 A = enervalues[i];
07257 B = x[i];
07258 C = 3 * (enervalues[i+1] - enervalues[i]) - (2 * x[i]) - x[i+1];
07259 D = 2 * (enervalues[i] - enervalues[i+1]) + x[i] + x[i+1];
07260
07261 printf("Coefficients for this interval: %f %f %f %f\n", A, B, C, D);
07262
07263 // Go over the region of interest and fill in the table
07264 for (j=0; j<entriesperseg; j++) {
07265 const BigReal mydist = currdist + (j * table_spacing);
07266 const BigReal mydistfrac = (float) j / (entriesperseg - 1);
07267 distbin = (int) mynearbyint(mydist / table_spacing);
07268 if (distbin >= (int) mynearbyint(maxdist / table_spacing)) break;
07269 BigReal energy;
07270 BigReal force;
07271
07272 energy = A + (B * mydistfrac) + (C * mydistfrac * mydistfrac) + (D * mydistfrac * mydistfrac * mydistfrac);
07273 force = B + (2 * C * mydistfrac) + (3 * D * mydistfrac * mydistfrac);
07274 // Multiply force by 1 / (interval length)
07275 force *= (1.0 / spacing);
07276
07277 printf("Adding energy/force entry %f / %f in bins %i / %i for distance %f (%f)\n", energy, force, (table_prefix + 2 * distbin), (table_prefix + 2 * distbin + 1), mydist, mydistfrac);
07278 table_ener[table_prefix + 2 * distbin] = energy;
07279 table_ener[table_prefix + 2 * distbin + 1] = force;
07280 distbin++;
07281 }
07282 if (currdist >= maxdist) break;
07283 }
07284
07285 //The procedure above leaves out the last entry -- add it explicitly
07286 distbin = (int) mynearbyint(maxdist / table_spacing);
07287 printf("Adding energy/force entry %f / %f in bins %i / %i\n", enervalues[numentries - 1], 0.0, (table_prefix + 2 * distbin), (table_prefix + 2 * distbin + 1));
07288 table_ener[table_prefix + 2 * distbin] = enervalues[numentries - 1];
07289 table_ener[table_prefix + 2 * distbin + 1] = 0.0;
07290 distbin++;
07291
07292
07293 // Clean up and make sure everything worked ok
07294 delete m;
07295 delete x;
07296 delete b;
07297 distbin--;
07298 printf("Testing: %i vs %i (from %f / %f)\n", distbin, (int) (mynearbyint(maxdist / table_spacing)), maxdist, table_spacing);
07299 if (distbin != (int) (mynearbyint(maxdist / table_spacing))) return 1;
07300 return 0;
07301 } /* end read_energy_type_cubspline */
|
|
|
Definition at line 393 of file Parameters.C. References Fclose(), Fopen(), NAMD_blank_string(), NAMD_die(), NAMD_find_first_word(), NAMD_read_line(), NumAngleParams, NumBondParams, NumDihedralParams, NumImproperParams, NumTablePairParams, NumVdwPairParams, NumVdwParams, and table_ener. Referenced by Parameters(). 00395 {
00396 char buffer[512]; // Buffer to store each line of the file
00397 char first_word[512]; // First word of the current line
00398 FILE *pfile; // File descriptor for the parameter file
00399
00400 /* Check to make sure that we haven't previously been told */
00401 /* that all the files were read */
00402 if (AllFilesRead)
00403 {
00404 NAMD_die("Tried to read another parameter file after being told that all files were read!");
00405 }
00406
00407 /* Try and open the file */
00408 if ( (pfile = Fopen(fname, "r")) == NULL)
00409 {
00410 char err_msg[256];
00411
00412 sprintf(err_msg, "UNABLE TO OPEN XPLOR PARAMETER FILE %s\n", fname);
00413 NAMD_die(err_msg);
00414 }
00415
00416 /* Keep reading in lines until we hit the EOF */
00417 while (NAMD_read_line(pfile, buffer) != -1)
00418 {
00419 /* Get the first word of the line */
00420 NAMD_find_first_word(buffer, first_word);
00421
00422 /* First, screen out things that we ignore, such as */
00423 /* blank lines, lines that start with '!', lines that */
00424 /* start with "REMARK", lines that start with set", */
00425 /* and most of the HBOND parameters which include */
00426 /* AEXP, REXP, HAEX, AAEX, but not the HBOND statement */
00427 /* which is parsed. */
00428 if ((buffer[0] != '!') &&
00429 !NAMD_blank_string(buffer) &&
00430 (strncasecmp(first_word, "REMARK", 6) != 0) &&
00431 (strcasecmp(first_word, "set")!=0) &&
00432 (strncasecmp(first_word, "AEXP", 4) != 0) &&
00433 (strncasecmp(first_word, "REXP", 4) != 0) &&
00434 (strncasecmp(first_word, "HAEX", 4) != 0) &&
00435 (strncasecmp(first_word, "AAEX", 4) != 0) &&
00436 (strncasecmp(first_word, "NBOND", 5) != 0) &&
00437 (strncasecmp(first_word, "CUTNB", 5) != 0) &&
00438 (strncasecmp(first_word, "END", 3) != 0) &&
00439 (strncasecmp(first_word, "CTONN", 5) != 0) &&
00440 (strncasecmp(first_word, "EPS", 3) != 0) &&
00441 (strncasecmp(first_word, "VSWI", 4) != 0) &&
00442 (strncasecmp(first_word, "NBXM", 4) != 0) &&
00443 (strncasecmp(first_word, "INHI", 4) != 0) )
00444 {
00445 /* Now, call the appropriate function based */
00446 /* on the type of parameter we have */
00447 if (strncasecmp(first_word, "bond", 4)==0)
00448 {
00449 add_bond_param(buffer);
00450 NumBondParams++;
00451 }
00452 else if (strncasecmp(first_word, "angl", 4)==0)
00453 {
00454 add_angle_param(buffer);
00455 NumAngleParams++;
00456 }
00457 else if (strncasecmp(first_word, "dihe", 4)==0)
00458 {
00459 add_dihedral_param(buffer, pfile);
00460 NumDihedralParams++;
00461 }
00462 else if (strncasecmp(first_word, "impr", 4)==0)
00463 {
00464 add_improper_param(buffer, pfile);
00465 NumImproperParams++;
00466 }
00467 else if (strncasecmp(first_word, "nonb", 4)==0)
00468 {
00469 add_vdw_param(buffer);
00470 NumVdwParams++;
00471 }
00472 else if (strncasecmp(first_word, "nbfi", 4)==0)
00473 {
00474 add_vdw_pair_param(buffer);
00475 NumVdwPairParams++;
00476 }
00477 else if (strncasecmp(first_word, "nbta", 4)==0)
00478 {
00479
00480 if (table_ener == NULL) {
00481 continue;
00482 }
00483
00484 add_table_pair_param(buffer);
00485 NumTablePairParams++;
00486 }
00487 else if (strncasecmp(first_word, "hbon", 4)==0)
00488 {
00489 add_hb_pair_param(buffer);
00490 }
00491 else
00492 {
00493 /* This is an unknown paramter. */
00494 /* This is BAD */
00495 char err_msg[512];
00496
00497 sprintf(err_msg, "UNKNOWN PARAMETER IN XPLOR PARAMETER FILE %s\nLINE=*%s*",
00498 fname, buffer);
00499 NAMD_die(err_msg);
00500 }
00501 }
00502 }
00503
00504 /* Close the file */
00505 Fclose(pfile);
00506
00507 return;
00508 }
|
|
||||||||||||
|
Definition at line 6273 of file Parameters.C. References Ambertoppar, angle_array, bond_array, parm::data_read, dihedral_array, IndexedVdwPair, four_body_consts::k, AngleValue::k, BondValue::k, AngleValue::k_ub, MAX_MULTIPLICITY, DihedralValue::multiplicity, four_body_consts::n, NAMD_die(), AngleValue::normal, parm::Nptra, parm::Numang, NumAngleParams, parm::Numbnd, NumBondParams, NumDihedralParams, parm::Phase, parm::Pk, parm::Pn, AngleValue::r_ub, parm::Req, parm::Rk, parm::Teq, AngleValue::theta0, parm::Tk, DihedralValue::values, and BondValue::x0. Referenced by Parameters(). 06274 {
06275 int i,j,ico,numtype,mul;
06276 IndexedVdwPair *new_node;
06277
06278 if (!amber_data->data_read)
06279 NAMD_die("No data read from parm file yet!");
06280
06281 // Copy bond parameters
06282 NumBondParams = amber_data->Numbnd;
06283 if (NumBondParams)
06284 { bond_array = new BondValue[NumBondParams];
06285 if (bond_array == NULL)
06286 NAMD_die("memory allocation of bond_array failed!");
06287 }
06288 for (i=0; i<NumBondParams; ++i)
06289 { bond_array[i].k = amber_data->Rk[i];
06290 bond_array[i].x0 = amber_data->Req[i];
06291 }
06292
06293 // Copy angle parameters
06294 NumAngleParams = amber_data->Numang;
06295 if (NumAngleParams)
06296 { angle_array = new AngleValue[NumAngleParams];
06297 if (angle_array == NULL)
06298 NAMD_die("memory allocation of angle_array failed!");
06299 }
06300 for (i=0; i<NumAngleParams; ++i)
06301 { angle_array[i].k = amber_data->Tk[i];
06302 angle_array[i].theta0 = amber_data->Teq[i];
06303 // Amber has no k_ub and r_ub for angle parameters, so they're set to 0
06304 angle_array[i].k_ub = angle_array[i].r_ub = 0;
06305 // All angles are harmonic
06306 angle_array[i].normal = 1;
06307 }
06308
06309 // Copy dihedral parameters
06310 // Note: If the periodicity is negative, it means the following
06311 // entry is another term in a multitermed dihedral, and the
06312 // absolute value is the true periodicity; in this case the
06313 // following entry in "dihedral_array" should be left empty,
06314 // NOT be skipped, in order to keep the next dihedral's index
06315 // unchanged.
06316 NumDihedralParams = amber_data->Nptra;
06317 if (NumDihedralParams)
06318 { dihedral_array = new DihedralValue[amber_data->Nptra];
06319 if (dihedral_array == NULL)
06320 NAMD_die("memory allocation of dihedral_array failed!");
06321 }
06322 mul = 0;
06323 for (i=0; i<NumDihedralParams; ++i)
06324 { dihedral_array[i-mul].values[mul].k = amber_data->Pk[i];
06325 dihedral_array[i-mul].values[mul].n = int(fabs(amber_data->Pn[i])+0.5);
06326 if (dihedral_array[i-mul].values[mul].n == 0)
06327 { char err_msg[128];
06328 sprintf(err_msg, "The periodicity of dihedral # %d is zero!", i+1);
06329 NAMD_die(err_msg);
06330 }
06331 dihedral_array[i-mul].values[mul].delta = amber_data->Phase[i];
06332 // If the periodicity is positive, it means the following
06333 // entry is a new dihedral term.
06334 if (amber_data->Pn[i] > 0)
06335 { dihedral_array[i-mul].multiplicity = mul+1;
06336 mul = 0;
06337 }
06338 else if (++mul >= MAX_MULTIPLICITY)
06339 { char err_msg[181];
06340 sprintf(err_msg, "Multiple dihedral with multiplicity of %d greater than max of %d",
06341 mul+1, MAX_MULTIPLICITY);
06342 NAMD_die(err_msg);
06343 }
06344 }
06345 if (mul > 0)
06346 NAMD_die("Negative periodicity in the last dihedral entry!");
06347
06348 // Copy VDW parameters: AMBER explicitly gives VDW parameters between every
06349 // 2 atom types, so the data are copied to vdw_pair_tree
06350 // In AMBER, all 1-4 VDW interactions are divided by factor vdw14
06351 NumVdwParamsAssigned = numtype = amber_data->Ntypes; // Number of atom types
06352 NumVdwPairParams = numtype * (numtype+1) / 2;
06353 for (i=0; i<numtype; ++i)
06354 for (j=i; j<numtype; ++j)
06355 { new_node = new IndexedVdwPair;
06356 if (new_node == NULL)
06357 NAMD_die("memory allocation of vdw_pair_tree failed!");
06358 new_node->ind1 = i;
06359 new_node->ind2 = j;
06360 new_node->left = new_node->right = NULL;
06361 // ico is the index of interaction between atom type i and j into
06362 // the parameter arrays. If it's positive, the interaction is
06363 // 6-12 VDW; otherwise it's 10-12 H-bond interaction. NAMD doesn't
06364 // have 10-12 term, so if ico is negative, then the 10-12
06365 // coefficients must be 0, otherwise die.
06366 ico = amber_data->Cno[numtype*i+j];
06367 if (ico>0)
06368 { new_node->A = amber_data->Cn1[ico-1];
06369 new_node->A14 = new_node->A / vdw14;
06370 new_node->B = amber_data->Cn2[ico-1];
06371 new_node->B14 = new_node->B / vdw14;
06372 }
06373 else if (amber_data->HB12[abs(ico)-1]==0.0 && amber_data->HB6[abs(ico)-1]==0.0)
06374 { new_node->A = new_node->A14 = new_node->B = new_node->B14 = 0.0;
06375 iout << iWARN << "Encounter 10-12 H-bond term\n";
06376 }
06377 else
06378 NAMD_die("Encounter non-zero 10-12 H-bond term!");
06379 // Add the node to the binary tree
06380 vdw_pair_tree = add_to_indexed_vdw_pairs(new_node, vdw_pair_tree);
06381 }
06382 }
|
|
|
Definition at line 5359 of file Parameters.C. References indexed_vdw_pair::A, indexed_vdw_pair::A14, nbthole_pair_value::alphai, nbthole_pair_value::alphaj, angle_array, indexed_vdw_pair::B, indexed_vdw_pair::B14, BigReal, bond_array, crossterm_array, four_body_consts::delta, dihedral_array, vdw_val::epsilon, vdw_val::epsilon14, MIStream::get(), improper_array, indexed_table_pair::ind1, nbthole_pair_value::ind1, indexed_vdw_pair::ind1, indexed_table_pair::ind2, nbthole_pair_value::ind2, indexed_vdw_pair::ind2, IndexedTablePair, IndexedVdwPair, j, indexed_table_pair::K, four_body_consts::k, AngleValue::k, BondValue::k, AngleValue::k_ub, indexed_table_pair::left, indexed_vdw_pair::left, MAX_ATOMTYPE_CHARS, ImproperValue::multiplicity, DihedralValue::multiplicity, four_body_consts::n, NAMD_die(), nbthole_array, NbtholePairValue, AngleValue::normal, NumAngleParams, NumBondParams, NumCrosstermParams, NumDihedralParams, numenerentries, NumImproperParams, NumNbtholePairParams, NumTablePairParams, NumVdwPairParams, NumVdwParams, NumVdwParamsAssigned, AngleValue::r_ub, Real, indexed_table_pair::right, indexed_vdw_pair::right, vdw_val::sigma, vdw_val::sigma14, tab_pair_tree, table_ener, AngleValue::theta0, nbthole_pair_value::tholeij, ImproperValue::values, DihedralValue::values, vdw_array, vdw_pair_tree, VdwValue, and BondValue::x0. 05361 {
05362 int i, j; // Loop counters
05363 Real *a1, *a2, *a3, *a4; // Temporary arrays to get data from message in
05364 int *i1, *i2, *i3; // Temporary int array to get data from message in
05365 IndexedVdwPair *new_node; // New node for vdw pair param tree
05366 IndexedTablePair *new_tab_node;
05367 Real **kvals; // Force constant values for dihedrals and impropers
05368 int **nvals; // Periodicity values for dihedrals and impropers
05369 Real **deltavals; // Phase shift values for dihedrals and impropers
05370
05371 // Get the bonded parameters
05372 msg->get(NumBondParams);
05373
05374 if (NumBondParams)
05375 {
05376 bond_array = new BondValue[NumBondParams];
05377 a1 = new Real[NumBondParams];
05378 a2 = new Real[NumBondParams];
05379
05380 if ( (bond_array == NULL) || (a1 == NULL) || (a2 == NULL) )
05381 {
05382 NAMD_die("memory allocation failed in Parameters::receive_Parameters");
05383 }
05384
05385 msg->get(NumBondParams, a1);
05386 msg->get(NumBondParams, a2);
05387
05388 for (i=0; i<NumBondParams; i++)
05389 {
05390 bond_array[i].k = a1[i];
05391 bond_array[i].x0 = a2[i];
05392 }
05393
05394 delete [] a1;
05395 delete [] a2;
05396 }
05397
05398 // Get the angle parameters
05399 msg->get(NumAngleParams);
05400
05401 if (NumAngleParams)
05402 {
05403 angle_array = new AngleValue[NumAngleParams];
05404 a1 = new Real[NumAngleParams];
05405 a2 = new Real[NumAngleParams];
05406 a3 = new Real[NumAngleParams];
05407 a4 = new Real[NumAngleParams];
05408 i1 = new int[NumAngleParams];
05409
05410 if ( (angle_array == NULL) || (a1 == NULL) || (a2 == NULL) ||
05411 (a3 == NULL) || (a4 == NULL) || (i1 == NULL))
05412 {
05413 NAMD_die("memory allocation failed in Parameters::receive_Parameters");
05414 }
05415
05416 msg->get(NumAngleParams, a1);
05417 msg->get(NumAngleParams, a2);
05418 msg->get(NumAngleParams, a3);
05419 msg->get(NumAngleParams, a4);
05420 msg->get(NumAngleParams, i1);
05421
05422 for (i=0; i<NumAngleParams; i++)
05423 {
05424 angle_array[i].k = a1[i];
05425 angle_array[i].theta0 = a2[i];
05426 angle_array[i].k_ub = a3[i];
05427 angle_array[i].r_ub = a4[i];
05428 angle_array[i].normal = i1[i];
05429 }
05430
05431 delete [] a1;
05432 delete [] a2;
05433 delete [] a3;
05434 delete [] a4;
05435 delete [] i1;
05436 }
05437
05438 // Get the dihedral parameters
05439 msg->get(NumDihedralParams);
05440
05441 if (NumDihedralParams)
05442 {
05443 dihedral_array = new DihedralValue[NumDihedralParams];
05444
05445 i1 = new int[NumDihedralParams];
05446 kvals = new Real *[MAX_MULTIPLICITY];
05447 nvals = new int *[MAX_MULTIPLICITY];
05448 deltavals = new Real *[MAX_MULTIPLICITY];
05449
05450 if ( (i1 == NULL) || (kvals == NULL) || (nvals == NULL) ||
05451 (deltavals == NULL) || (dihedral_array == NULL) )
05452 {
05453 NAMD_die("memory allocation failed in Parameters::send_Parameters");
05454 }
05455
05456 for (i=0; i<MAX_MULTIPLICITY; i++)
05457 {
05458 kvals[i] = new Real[NumDihedralParams];
05459 nvals[i] = new int[NumDihedralParams];
05460 deltavals[i] = new Real[NumDihedralParams];
05461
05462 if ( (kvals[i] == NULL) || (nvals[i] == NULL) || (deltavals[i] == NULL) )
05463 {
05464 NAMD_die("memory allocation failed in Parameters::send_Parameters");
05465 }
05466 }
05467
05468 msg->get(NumDihedralParams, i1);
05469
05470 for (i=0; i<MAX_MULTIPLICITY; i++)
05471 {
05472 msg->get(NumDihedralParams, kvals[i]);
05473 msg->get(NumDihedralParams, nvals[i]);
05474 msg->get(NumDihedralParams, deltavals[i]);
05475 }
05476
05477 for (i=0; i<NumDihedralParams; i++)
05478 {
05479 dihedral_array[i].multiplicity = i1[i];
05480
05481 for (j=0; j<MAX_MULTIPLICITY; j++)
05482 {
05483 dihedral_array[i].values[j].k = kvals[j][i];
05484 dihedral_array[i].values[j].n = nvals[j][i];
05485 dihedral_array[i].values[j].delta = deltavals[j][i];
05486 }
05487 }
05488
05489 for (i=0; i<MAX_MULTIPLICITY; i++)
05490 {
05491 delete [] kvals[i];
05492 delete [] nvals[i];
05493 delete [] deltavals[i];
05494 }
05495
05496 delete [] i1;
05497 delete [] kvals;
05498 delete [] nvals;
05499 delete [] deltavals;
05500 }
05501
05502 // Get the improper parameters
05503 msg->get(NumImproperParams);
05504
05505 if (NumImproperParams)
05506 {
05507 improper_array = new ImproperValue[NumImproperParams];
05508 i1 = new int[NumImproperParams];
05509 kvals = new Real *[MAX_MULTIPLICITY];
05510 nvals = new int *[MAX_MULTIPLICITY];
05511 deltavals = new Real *[MAX_MULTIPLICITY];
05512
05513 if ( (i1 == NULL) || (kvals == NULL) || (nvals == NULL) ||
05514 (deltavals == NULL) || (improper_array==NULL) )
05515 {
05516 NAMD_die("memory allocation failed in Parameters::send_Parameters");
05517 }
05518
05519 for (i=0; i<MAX_MULTIPLICITY; i++)
05520 {
05521 kvals[i] = new Real[NumImproperParams];
05522 nvals[i] = new int[NumImproperParams];
05523 deltavals[i] = new Real[NumImproperParams];
05524
05525 if ( (kvals[i] == NULL) || (nvals[i] == NULL) || (deltavals[i] == NULL) )
05526 {
05527 NAMD_die("memory allocation failed in Parameters::send_Parameters");
05528 }
05529 }
05530
05531 msg->get(NumImproperParams,i1);
05532
05533 for (i=0; i<MAX_MULTIPLICITY; i++)
05534 {
05535 msg->get(NumImproperParams,kvals[i]);
05536 msg->get(NumImproperParams,nvals[i]);
05537 msg->get(NumImproperParams,deltavals[i]);
05538 }
05539
05540 for (i=0; i<NumImproperParams; i++)
05541 {
05542 improper_array[i].multiplicity = i1[i];
05543
05544 for (j=0; j<MAX_MULTIPLICITY; j++)
05545 {
05546 improper_array[i].values[j].k = kvals[j][i];
05547 improper_array[i].values[j].n = nvals[j][i];
05548 improper_array[i].values[j].delta = deltavals[j][i];
05549 }
05550 }
05551
05552 for (i=0; i<MAX_MULTIPLICITY; i++)
05553 {
05554 delete [] kvals[i];
05555 delete [] nvals[i];
05556 delete [] deltavals[i];
05557 }
05558
05559 delete [] i1;
05560 delete [] kvals;
05561 delete [] nvals;
05562 delete [] deltavals;
05563 }
05564
05565 // Get the crossterm parameters
05566 msg->get(NumCrosstermParams);
05567
05568 if (NumCrosstermParams)
05569 {
05570 crossterm_array = new CrosstermValue[NumCrosstermParams];
05571
05572 for (i=0; i<NumCrosstermParams; ++i) {
05573 int nvals = CrosstermValue::dim * CrosstermValue::dim * 2 * 2;
05574 msg->get(nvals,&crossterm_array[i].c[0][0].d00);
05575 }
05576 }
05577
05578 //Get the energy table
05579 msg->get(numenerentries);
05580 if (numenerentries > 0) {
05581 //fprintf(stdout, "Getting tables\n");
05582 //fprintf(infofile, "Trying to allocate table\n");
05583 table_ener = new BigReal[numenerentries];
05584 //fprintf(infofile, "Finished table allocation\n");
05585 if (table_ener==NULL)
05586 {
05587 NAMD_die("memory allocation failed in Parameters::receive_Parameters");
05588 }
05589
05590 msg->get(numenerentries, table_ener);
05591 }
05592
05593 // Get the vdw parameters
05594 msg->get(NumVdwParams);
05595 msg->get(NumVdwParamsAssigned);
05596
05597 if (NumVdwParams)
05598 {
05599 atomTypeNames = new char[NumVdwParams*(MAX_ATOMTYPE_CHARS+1)];
05600 vdw_array = new VdwValue[NumVdwParams];
05601 a1 = new Real[NumVdwParams];
05602 a2 = new Real[NumVdwParams];
05603 a3 = new Real[NumVdwParams];
05604 a4 = new Real[NumVdwParams];
05605
05606 if ( (vdw_array==NULL) || (a1==NULL) || (a2==NULL) || (a3==NULL)
05607 || (a4==NULL) || (atomTypeNames==NULL))
05608 {
05609 NAMD_die("memory allocation failed in Parameters::receive_Parameters");
05610 }
05611
05612 msg->get(NumVdwParams * (MAX_ATOMTYPE_CHARS+1), atomTypeNames);
05613 msg->get(NumVdwParams, a1);
05614 msg->get(NumVdwParams, a2);
05615 msg->get(NumVdwParams, a3);
05616 msg->get(NumVdwParams, a4);
05617
05618 for (i=0; i<NumVdwParams; i++)
05619 {
05620 vdw_array[i].sigma = a1[i];
05621 vdw_array[i].epsilon = a2[i];
05622 vdw_array[i].sigma14 = a3[i];
05623 vdw_array[i].epsilon14 = a4[i];
05624 }
05625
05626 delete [] a1;
05627 delete [] a2;
05628 delete [] a3;
05629 delete [] a4;
05630 }
05631
05632 // Get the vdw_pair_parameters
05633 msg->get(NumVdwPairParams);
05634
05635 if (NumVdwPairParams)
05636 {
05637 a1 = new Real[NumVdwPairParams];
05638 a2 = new Real[NumVdwPairParams];
05639 a3 = new Real[NumVdwPairParams];
05640 a4 = new Real[NumVdwPairParams];
05641 i1 = new int[NumVdwPairParams];
05642 i2 = new int[NumVdwPairParams];
05643
05644 if ( (a1 == NULL) || (a2 == NULL) || (a3 == NULL) || (a4 == NULL) ||
05645 (i1 == NULL) || (i2 == NULL) )
05646 {
05647 NAMD_die("memory allocation failed in Parameters::send_Parameters");
05648 }
05649
05650 msg->get(NumVdwPairParams, i1);
05651 msg->get(NumVdwPairParams, i2);
05652 msg->get(NumVdwPairParams, a1);
05653 msg->get(NumVdwPairParams, a2);
05654 msg->get(NumVdwPairParams, a3);
05655 msg->get(NumVdwPairParams, a4);
05656
05657 for (i=0; i<NumVdwPairParams; i++)
05658 {
05659 new_node = (IndexedVdwPair *) malloc(sizeof(IndexedVdwPair));
05660
05661 if (new_node == NULL)
05662 {
05663 NAMD_die("memory allocation failed in Parameters::receive_Parameters");
05664 }
05665
05666 new_node->ind1 = i1[i];
05667 new_node->ind2 = i2[i];
05668 new_node->A = a1[i];
05669 new_node->A14 = a2[i];
05670 new_node->B = a3[i];
05671 new_node->B14 = a4[i];
05672 new_node->left = NULL;
05673 new_node->right = NULL;
05674
05675 vdw_pair_tree = add_to_indexed_vdw_pairs(new_node, vdw_pair_tree);
05676 }
05677
05678 delete [] i1;
05679 delete [] i2;
05680 delete [] a1;
05681 delete [] a2;
05682 delete [] a3;
05683 delete [] a4;
05684 }
05685
05686 // Get the nbthole_pair_parameters
05687 msg->get(NumNbtholePairParams);
05688
05689 if (NumNbtholePairParams)
05690 {
05691 nbthole_array = new NbtholePairValue[NumNbtholePairParams];
05692 a1 = new Real[NumNbtholePairParams];
05693 a2 = new Real[NumNbtholePairParams];
05694 a3 = new Real[NumNbtholePairParams];
05695 i1 = new int[NumNbtholePairParams];
05696 i2 = new int[NumNbtholePairParams];
05697
05698 if ( (nbthole_array == NULL) || (a1 == NULL) || (a2 == NULL) || (a3 == NULL)
05699 || (i1 == NULL) || (i2 == NULL) )
05700 {
05701 NAMD_die("memory allocation failed in Parameters::receive_Parameters");
05702 }
05703
05704 msg->get(NumNbtholePairParams, i1);
05705 msg->get(NumNbtholePairParams, i2);
05706 msg->get(NumNbtholePairParams, a1);
05707 msg->get(NumNbtholePairParams, a2);
05708 msg->get(NumNbtholePairParams, a3);
05709
05710 for (i=0; i<NumNbtholePairParams; i++)
05711 {
05712
05713 nbthole_array[i].ind1 = i1[i];
05714 nbthole_array[i].ind2 = i2[i];
05715 nbthole_array[i].alphai = a1[i];
05716 nbthole_array[i].alphaj = a2[i];
05717 nbthole_array[i].tholeij = a3[i];
05718
05719 }
05720
05721 delete [] i1;
05722 delete [] i2;
05723 delete [] a1;
05724 delete [] a2;
05725 delete [] a3;
05726 }
05727
05728 // Get the table_pair_parameters
05729 msg->get(NumTablePairParams);
05730
05731 if (NumTablePairParams)
05732 {
05733 i1 = new int[NumTablePairParams];
05734 i2 = new int[NumTablePairParams];
05735 i3 = new int[NumTablePairParams];
05736
05737 if ( (i3 == NULL) || (i1 == NULL) || (i2 == NULL) )
05738 {
05739 NAMD_die("memory allocation failed in Parameters::send_Parameters");
05740 }
05741
05742 msg->get(NumTablePairParams, i1);
05743 msg->get(NumTablePairParams, i2);
05744 msg->get(NumTablePairParams, i3);
05745
05746 for (i=0; i<NumTablePairParams; i++)
05747 {
05748 new_tab_node = (IndexedTablePair *) malloc(sizeof(IndexedTablePair));
05749
05750 if (new_tab_node == NULL)
05751 {
05752 NAMD_die("memory allocation failed in Parameters::receive_Parameters");
05753 }
05754
05755 // printf("Adding new table pair with ind1 %i ind2 %i k %i\n", i1[i], i2[i],i3[i]);
05756 new_tab_node->ind1 = i1[i];
05757 new_tab_node->ind2 = i2[i];
05758 new_tab_node->K = i3[i];
05759 new_tab_node->left = NULL;
05760 new_tab_node->right = NULL;
05761
05762 tab_pair_tree = add_to_indexed_table_pairs(new_tab_node, tab_pair_tree);
05763 }
05764
05765 delete [] i1;
05766 delete [] i2;
05767 delete [] i3;
05768 }
05769
05770 // receive the hydrogen bond parameters
05771 // hbondParams.receive_message(msg);
05772
05773 AllFilesRead = TRUE;
05774
05775 delete msg;
05776 }
|
|
|
Definition at line 5009 of file Parameters.C. References nbthole_pair_value::alphai, nbthole_pair_value::alphaj, angle_array, bond_array, crossterm_array, four_body_consts::delta, dihedral_array, MOStream::end(), vdw_val::epsilon, vdw_val::epsilon14, improper_array, nbthole_pair_value::ind1, nbthole_pair_value::ind2, j, four_body_consts::k, AngleValue::k, BondValue::k, AngleValue::k_ub, MAX_ATOMTYPE_CHARS, ImproperValue::multiplicity, DihedralValue::multiplicity, four_body_consts::n, NAMD_die(), nbthole_array, nbthole_pair_tree, AngleValue::normal, NumAngleParams, NumBondParams, NumCrosstermParams, NumDihedralParams, numenerentries, NumImproperParams, NumNbtholePairParams, NumTablePairParams, NumVdwPairParams, NumVdwParams, NumVdwParamsAssigned, MOStream::put(), AngleValue::r_ub, Real, vdw_val::sigma, vdw_val::sigma14, tab_pair_tree, table_ener, AngleValue::theta0, nbthole_pair_value::tholeij, ImproperValue::values, DihedralValue::values, vdw_array, vdw_pair_tree, and BondValue::x0. 05010 {
05011 Real *a1, *a2, *a3, *a4; // Temporary arrays for sending messages
05012 int *i1, *i2, *i3; // Temporary int array
05013 int i, j; // Loop counters
05014 Real **kvals; // Force constant values for dihedrals and impropers
05015 int **nvals; // Periodicity values for dihedrals and impropers
05016 Real **deltavals; // Phase shift values for dihedrals and impropers
05017 /*MOStream *msg=comm_obj->newOutputStream(ALLBUTME, STATICPARAMSTAG, BUFSIZE);
05018 if ( msg == NULL )
05019 {
05020 NAMD_die("memory allocation failed in Parameters::send_Parameters");
05021 }*/
05022
05023 // Send the bond parameters
05024 msg->put(NumBondParams);
05025
05026 if (NumBondParams)
05027 {
05028 a1 = new Real[NumBondParams];
05029 a2 = new Real[NumBondParams];
05030
05031 if ( (a1 == NULL) || (a2 == NULL) )
05032 {
05033 NAMD_die("memory allocation failed in Parameters::send_Parameters");
05034 }
05035
05036 for (i=0; i<NumBondParams; i++)
05037 {
05038 a1[i] = bond_array[i].k;
05039 a2[i] = bond_array[i].x0;
05040 }
05041
05042 msg->put(NumBondParams, a1)->put(NumBondParams, a2);
05043
05044 delete [] a1;
05045 delete [] a2;
05046 }
05047
05048 // Send the angle parameters
05049 msg->put(NumAngleParams);
05050
05051 if (NumAngleParams)
05052 {
05053 a1 = new Real[NumAngleParams];
05054 a2 = new Real[NumAngleParams];
05055 a3 = new Real[NumAngleParams];
05056 a4 = new Real[NumAngleParams];
05057 i1 = new int[NumAngleParams];
05058
05059 if ( (a1 == NULL) || (a2 == NULL) || (a3 == NULL) ||
05060 (a4 == NULL) || (i1 == NULL))
05061 {
05062 NAMD_die("memory allocation failed in Parameters::send_Parameters");
05063 }
05064
05065 for (i=0; i<NumAngleParams; i++)
05066 {
05067 a1[i] = angle_array[i].k;
05068 a2[i] = angle_array[i].theta0;
05069 a3[i] = angle_array[i].k_ub;
05070 a4[i] = angle_array[i].r_ub;
05071 i1[i] = angle_array[i].normal;
05072 }
05073
05074 msg->put(NumAngleParams, a1)->put(NumAngleParams, a2);
05075 msg->put(NumAngleParams, a3)->put(NumAngleParams, a4);
05076 msg->put(NumAngleParams, i1);
05077
05078 delete [] a1;
05079 delete [] a2;
05080 delete [] a3;
05081 delete [] a4;
05082 delete [] i1;
05083 }
05084
05085 // Send the dihedral parameters
05086 msg->put(NumDihedralParams);
05087
05088 if (NumDihedralParams)
05089 {
05090 i1 = new int[NumDihedralParams];
05091 kvals = new Real *[MAX_MULTIPLICITY];
05092 nvals = new int *[MAX_MULTIPLICITY];
05093 deltavals = new Real *[MAX_MULTIPLICITY];
05094
05095 if ( (i1 == NULL) || (kvals == NULL) || (nvals == NULL) ||
05096 (deltavals == NULL) )
05097 {
05098 NAMD_die("memory allocation failed in Parameters::send_Parameters");
05099 }
05100
05101 for (i=0; i<MAX_MULTIPLICITY; i++)
05102 {
05103 kvals[i] = new Real[NumDihedralParams];
05104 nvals[i] = new int[NumDihedralParams];
05105 deltavals[i] = new Real[NumDihedralParams];
05106
05107 if ( (kvals[i] == NULL) || (nvals[i] == NULL) || (deltavals[i] == NULL) )
05108 {
05109 NAMD_die("memory allocation failed in Parameters::send_Parameters");
05110 }
05111 }
05112
05113 for (i=0; i<NumDihedralParams; i++)
05114 {
05115 i1[i] = dihedral_array[i].multiplicity;
05116
05117 for (j=0; j<MAX_MULTIPLICITY; j++)
05118 {
05119 kvals[j][i] = dihedral_array[i].values[j].k;
05120 nvals[j][i] = dihedral_array[i].values[j].n;
05121 deltavals[j][i] = dihedral_array[i].values[j].delta;
05122 }
05123 }
05124
05125 msg->put(NumDihedralParams, i1);
05126
05127 for (i=0; i<MAX_MULTIPLICITY; i++)
05128 {
05129 msg->put(NumDihedralParams, kvals[i]);
05130 msg->put(NumDihedralParams, nvals[i]);
05131 msg->put(NumDihedralParams, deltavals[i]);
05132
05133 delete [] kvals[i];
05134 delete [] nvals[i];
05135 delete [] deltavals[i];
05136 }
05137
05138 delete [] i1;
05139 delete [] kvals;
05140 delete [] nvals;
05141 delete [] deltavals;
05142 }
05143
05144 // Send the improper parameters
05145 msg->put(NumImproperParams);
05146
05147 if (NumImproperParams)
05148 {
05149 i1 = new int[NumImproperParams];
05150 kvals = new Real *[MAX_MULTIPLICITY];
05151 nvals = new int *[MAX_MULTIPLICITY];
05152 deltavals = new Real *[MAX_MULTIPLICITY];
05153
05154 if ( (i1 == NULL) || (kvals == NULL) || (nvals == NULL) ||
05155 (deltavals == NULL) )
05156 {
05157 NAMD_die("memory allocation failed in Parameters::send_Parameters");
05158 }
05159
05160 for (i=0; i<MAX_MULTIPLICITY; i++)
05161 {
05162 kvals[i] = new Real[NumImproperParams];
05163 nvals[i] = new int[NumImproperParams];
05164 deltavals[i] = new Real[NumImproperParams];
05165
05166 if ( (kvals[i] == NULL) || (nvals[i] == NULL) || (deltavals[i] == NULL) )
05167 {
05168 NAMD_die("memory allocation failed in Parameters::send_Parameters");
05169 }
05170 }
05171
05172 for (i=0; i<NumImproperParams; i++)
05173 {
05174 i1[i] = improper_array[i].multiplicity;
05175
05176 for (j=0; j<MAX_MULTIPLICITY; j++)
05177 {
05178 kvals[j][i] = improper_array[i].values[j].k;
05179 nvals[j][i] = improper_array[i].values[j].n;
05180 deltavals[j][i] = improper_array[i].values[j].delta;
05181 }
05182 }
05183
05184 msg->put(NumImproperParams, i1);
05185
05186 for (i=0; i<MAX_MULTIPLICITY; i++)
05187 {
05188 msg->put(NumImproperParams, kvals[i]);
05189 msg->put(NumImproperParams, nvals[i]);
05190 msg->put(NumImproperParams, deltavals[i]);
05191
05192 delete [] kvals[i];
05193 delete [] nvals[i];
05194 delete [] deltavals[i];
05195 }
05196
05197 delete [] i1;
05198 delete [] kvals;
05199 delete [] nvals;
05200 delete [] deltavals;
05201 }
05202
05203 // Send the crossterm parameters
05204 msg->put(NumCrosstermParams);
05205
05206 if (NumCrosstermParams)
05207 {
05208 for (i=0; i<NumCrosstermParams; ++i) {
05209 int nvals = CrosstermValue::dim * CrosstermValue::dim * 2 * 2;
05210 msg->put(nvals,&crossterm_array[i].c[0][0].d00);
05211 }
05212 }
05213 //
05214 //Send the energy table parameters
05215 msg->put(numenerentries);
05216
05217 if (numenerentries) {
05218 /*
05219 b1 = new Real[numenerentries];
05220 if (b1 == NULL)
05221 {
05222 NAMD_die("memory allocation failed in Parameters::send_Parameters");
05223 }
05224 */
05225
05226 msg->put(numenerentries, table_ener);
05227 }
05228
05229 // Send the vdw parameters
05230 msg->put(NumVdwParams);
05231 msg->put(NumVdwParamsAssigned);
05232
05233 if (NumVdwParams)
05234 {
05235 a1 = new Real[NumVdwParams];
05236 a2 = new Real[NumVdwParams];
05237 a3 = new Real[NumVdwParams];
05238 a4 = new Real[NumVdwParams];
05239
05240 if ( (a1 == NULL) || (a2 == NULL) || (a3 == NULL) )
05241 {
05242 NAMD_die("memory allocation failed in Parameters::send_Parameters");
05243 }
05244
05245 for (i=0; i<NumVdwParams; i++)
05246 {
05247 a1[i] = vdw_array[i].sigma;
05248 a2[i] = vdw_array[i].epsilon;
05249 a3[i] = vdw_array[i].sigma14;
05250 a4[i] = vdw_array[i].epsilon14;
05251 }
05252
05253 msg->put(NumVdwParams * (MAX_ATOMTYPE_CHARS+1), atomTypeNames);
05254 msg->put(NumVdwParams, a1);
05255 msg->put(NumVdwParams, a2);
05256 msg->put(NumVdwParams, a3);
05257 msg->put(NumVdwParams, a4);
05258
05259 delete [] a1;
05260 delete [] a2;
05261 delete [] a3;
05262 delete [] a4;
05263 }
05264
05265 // Send the vdw pair parameters
05266 msg->put(NumVdwPairParams);
05267
05268 if (NumVdwPairParams)
05269 {
05270 a1 = new Real[NumVdwPairParams];
05271 a2 = new Real[NumVdwPairParams];
05272 a3 = new Real[NumVdwPairParams];
05273 a4 = new Real[NumVdwPairParams];
05274 i1 = new int[NumVdwPairParams];
05275 i2 = new int[NumVdwPairParams];
05276
05277 if ( (a1 == NULL) || (a2 == NULL) || (a3 == NULL) || (a4 == NULL) ||
05278 (i1 == NULL) || (i2 == NULL) )
05279 {
05280 NAMD_die("memory allocation failed in Parameters::send_Parameters");
05281 }
05282
05283 vdw_pair_to_arrays(i1, i2, a1, a2, a3, a4, 0, vdw_pair_tree);
05284
05285 msg->put(NumVdwPairParams, i1)->put(NumVdwPairParams, i2);
05286 msg->put(NumVdwPairParams, a1);
05287 msg->put(NumVdwPairParams, a2)->put(NumVdwPairParams, a3);
05288 msg->put(NumVdwPairParams, a4);
05289 }
05290
05291 // Send the nbthole pair parameters
05292 msg->put(NumNbtholePairParams);
05293
05294 if (NumNbtholePairParams)
05295 {
05296 a1 = new Real[NumNbtholePairParams];
05297 a2 = new Real[NumNbtholePairParams];
05298 a3 = new Real[NumNbtholePairParams];
05299 i1 = new int[NumNbtholePairParams];
05300 i2 = new int[NumNbtholePairParams];
05301
05302 if ( (a1 == NULL) || (a2 == NULL) || (a3 == NULL) || (i1 == NULL) || (i2 == NULL) )
05303 {
05304 NAMD_die("memory allocation failed in Parameters::send_Parameters");
05305 }
05306
05307 nbthole_pair_to_arrays(i1, i2, a1, a2, a3, 0, nbthole_pair_tree);
05308
05309 for (i=0; i<NumNbtholePairParams; i++)
05310 {
05311 nbthole_array[i].ind1 = i1[i];
05312 nbthole_array[i].ind2 = i2[i];
05313 nbthole_array[i].alphai = a1[i];
05314 nbthole_array[i].alphaj = a2[i];
05315 nbthole_array[i].tholeij = a3[i];
05316 }
05317
05318 msg->put(NumNbtholePairParams, i1)->put(NumNbtholePairParams, i2);
05319 msg->put(NumNbtholePairParams, a1);
05320 msg->put(NumNbtholePairParams, a2)->put(NumNbtholePairParams, a3);
05321 }
05322
05323 // Send the table pair parameters
05324 //printf("Pairs: %i\n", NumTablePairParams);
05325 msg->put(NumTablePairParams);
05326
05327 if (NumTablePairParams)
05328 {
05329 i1 = new int[NumTablePairParams];
05330 i2 = new int[NumTablePairParams];
05331 i3 = new int[NumTablePairParams];
05332
05333 if ( (i3 == NULL) || (i1 == NULL) || (i2 == NULL) )
05334 {
05335 NAMD_die("memory allocation failed in Parameters::send_Parameters");
05336 }
05337
05338 table_pair_to_arrays(i1, i2, i3, 0, tab_pair_tree);
05339
05340 msg->put(NumTablePairParams, i1)->put(NumTablePairParams, i2);
05341 msg->put(NumTablePairParams, i3);
05342 }
05343
05344 // send the hydrogen bond parameters
05345 // hbondParams.create_message(msg);
05346 msg->end();
05347 delete msg;
05348 }
|
|
|
Definition at line 225 of file Parameters.h. Referenced by done_reading_files(), AngleElem::getParameterPointers(), read_parm(), receive_Parameters(), send_Parameters(), and ~Parameters(). |
|
|
Definition at line 224 of file Parameters.h. Referenced by done_reading_files(), BondElem::getParameterPointers(), read_parm(), receive_Parameters(), send_Parameters(), and ~Parameters(). |
|
|
Definition at line 233 of file Parameters.h. Referenced by ComputeNonbondedUtil::select(). |
|
|
Definition at line 228 of file Parameters.h. Referenced by done_reading_files(), CrosstermElem::getParameterPointers(), receive_Parameters(), send_Parameters(), and ~Parameters(). |
|
|
Definition at line 226 of file Parameters.h. Referenced by assign_dihedral_index(), done_reading_files(), DihedralElem::getParameterPointers(), outputCompressedFile(), read_parm(), receive_Parameters(), send_Parameters(), and ~Parameters(). |
|
|
Definition at line 227 of file Parameters.h. Referenced by assign_improper_index(), done_reading_files(), ImproperElem::getParameterPointers(), outputCompressedFile(), receive_Parameters(), send_Parameters(), and ~Parameters(). |
|
|
Definition at line 230 of file Parameters.h. Referenced by done_reading_files(), receive_Parameters(), and send_Parameters(). |
|
|
Definition at line 236 of file Parameters.h. Referenced by send_Parameters(), and ~Parameters(). |
|
|
Definition at line 240 of file Parameters.h. Referenced by print_angle_params(), print_param_summary(), read_charmm_parameter_file(), read_parameter_file(), read_parm(), receive_Parameters(), and send_Parameters(). |
|
|
Definition at line 239 of file Parameters.h. Referenced by print_bond_params(), print_param_summary(), read_charmm_parameter_file(), read_parameter_file(), read_parm(), receive_Parameters(), and send_Parameters(). |
|
|
Definition at line 241 of file Parameters.h. Referenced by print_param_summary(). |
|
|
Definition at line 244 of file Parameters.h. Referenced by done_reading_files(), print_param_summary(), read_charmm_parameter_file(), receive_Parameters(), and send_Parameters(). |
|
|
Definition at line 242 of file Parameters.h. Referenced by done_reading_files(), outputCompressedFile(), print_dihedral_params(), print_param_summary(), read_charmm_parameter_file(), read_parameter_file(), read_parm(), receive_Parameters(), and send_Parameters(). |
|
|
Definition at line 231 of file Parameters.h. Referenced by read_ener_table(), receive_Parameters(), and send_Parameters(). |
|
|
Definition at line 243 of file Parameters.h. Referenced by done_reading_files(), outputCompressedFile(), print_improper_params(), print_param_summary(), read_charmm_parameter_file(), read_parameter_file(), receive_Parameters(), and send_Parameters(). |
|
|
Definition at line 249 of file Parameters.h. Referenced by print_nbthole_pair_params(), print_param_summary(), read_charmm_parameter_file(), receive_Parameters(), and send_Parameters(). |
|
|
Definition at line 250 of file Parameters.h. Referenced by read_charmm_parameter_file(), read_parameter_file(), receive_Parameters(), and send_Parameters(). |
|
|
Definition at line 246 of file Parameters.h. |
|
|
Definition at line 248 of file Parameters.h. Referenced by print_param_summary(), print_vdw_pair_params(), read_charmm_parameter_file(), read_parameter_file(), receive_Parameters(), and send_Parameters(). |
|
|
Definition at line 245 of file Parameters.h. Referenced by done_reading_files(), print_param_summary(), print_vdw_params(), read_charmm_parameter_file(), read_parameter_file(), receive_Parameters(), and send_Parameters(). |
|
|
Definition at line 247 of file Parameters.h. Referenced by done_reading_files(), receive_Parameters(), and send_Parameters(). |
|
|
Definition at line 232 of file Parameters.h. Referenced by ComputeNonbondedUtil::select(). |
|
|
Definition at line 237 of file Parameters.h. Referenced by receive_Parameters(), send_Parameters(), and ~Parameters(). |
|
|
Definition at line 234 of file Parameters.h. Referenced by read_charmm_parameter_file(), read_ener_table(), read_parameter_file(), receive_Parameters(), ComputeNonbondedUtil::select(), and send_Parameters(). |
|
|
Definition at line 238 of file Parameters.h. Referenced by read_ener_table(). |
|
|
Definition at line 229 of file Parameters.h. Referenced by done_reading_files(), receive_Parameters(), send_Parameters(), and ~Parameters(). |
|
|
Definition at line 235 of file Parameters.h. Referenced by receive_Parameters(), send_Parameters(), and ~Parameters(). |
1.3.9.1