ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/group/trunk/OOPSE/libmdtools/TraPPE_ExFF.cpp
(Generate patch)

Comparing trunk/OOPSE/libmdtools/TraPPE_ExFF.cpp (file contents):
Revision 420 by mmeineke, Thu Mar 27 17:32:03 2003 UTC vs.
Revision 463 by gezelter, Sat Apr 5 03:39:25 2003 UTC

# Line 12 | Line 12 | using namespace std;
12   #include "fortranWrappers.hpp"
13  
14   #ifdef IS_MPI
15 #include <mpi++.h>
15   #include "mpiForceField.h"
16   #endif // is_mpi
17  
# Line 99 | Line 98 | namespace TPE {  // restrict the access of the folowin
98        return NULL;
99      }
100      
101 +    void printMe( void ){
102 +      
103 +      std::cerr << "LinkedAtype " << name << ": ident = " << ident << "\n";
104 +      if( next != NULL ) next->printMe();
105 +
106 +    }
107 +
108      void add( atomStruct &info ){
109  
110        // check for duplicates
# Line 114 | Line 120 | namespace TPE {  // restrict the access of the folowin
120  
121        if( next != NULL ) next->add(info);
122        else{
123 <        next = new LinkedType();
123 >        next = new LinkedAtomType();
124          strcpy(next->name, info.name);
125          next->isDipole = info.isDipole;
126          next->isSSD    = info.isSSD;
# Line 140 | Line 146 | namespace TPE {  // restrict the access of the folowin
146        info.dipole   = dipole;
147        info.w0       = w0;
148        info.v0       = v0;
149 +      info.ident    = ident;
150        info.last     = 0;
151      }
152  
# Line 197 | Line 204 | namespace TPE {  // restrict the access of the folowin
204          
205        if( next != NULL ) next->add(info);
206        else{
207 <        next = new LinkedType();
207 >        next = new LinkedBondType();
208          strcpy(next->nameA, info.nameA);
209          strcpy(next->nameB, info.nameB);
210          strcpy(next->type,  info.type);
# Line 266 | Line 273 | namespace TPE {  // restrict the access of the folowin
273  
274        if( next != NULL ) next->add(info);
275        else{
276 <        next = new LinkedType();
276 >        next = new LinkedBendType();
277          strcpy(next->nameA, info.nameA);
278          strcpy(next->nameB, info.nameB);
279          strcpy(next->nameC, info.nameC);
# Line 350 | Line 357 | namespace TPE {  // restrict the access of the folowin
357  
358        if( next != NULL ) next->add(info);
359        else{
360 <        next = new LinkedType();
360 >        next = new LinkedTorsionType();
361          strcpy(next->nameA, info.nameA);
362          strcpy(next->nameB, info.nameB);
363          strcpy(next->nameC, info.nameC);
# Line 621 | Line 628 | void TraPPE_ExFF::readParams( void ){
628  
629   void TraPPE_ExFF::readParams( void ){
630  
631 <  int i;
631 >  int i, a, b, c, d;
632    int identNum;
633 +  char* atomA;
634 +  char* atomB;
635 +  char* atomC;
636 +  char* atomD;
637    
638    atomStruct atomInfo;
639    bondStruct bondInfo;
640    bendStruct bendInfo;
641    torsionStruct torsionInfo;
642    
643 <  
643 >  bigSigma = 0.0;
644 >
645    atomInfo.last = 1;
646    bondInfo.last = 1;
647    bendInfo.last = 1;
# Line 715 | Line 727 | void TraPPE_ExFF::readParams( void ){
727      
728      MPIcheckPoint();
729  
730 <    headAtomType = new LinkedType;
730 >    headAtomType = new LinkedAtomType;
731      recieveFrcStruct( &atomInfo, mpiAtomStructType );
732      
733      while( !atomInfo.last ){
# Line 729 | Line 741 | void TraPPE_ExFF::readParams( void ){
741        recieveFrcStruct( &atomInfo, mpiAtomStructType );
742      }
743    }
744 +
745   #endif // is_mpi
746  
747 +
748 +
749    // call new A_types in fortran
750    
751    int isError;
# Line 742 | Line 757 | void TraPPE_ExFF::readParams( void ){
757    double GB_dummy = 0.0;
758    
759    
760 <  currentAtomType = headAtomType;
760 >  currentAtomType = headAtomType->next;;
761    while( currentAtomType != NULL ){
762      
763      if(currentAtomType->isDipole) entry_plug->useDipole = 1;
764 <    if(currentAtomType->isSSD)    entry_plug->useSticky = 1;
764 >    if(currentAtomType->isSSD) {
765 >      entry_plug->useSticky = 1;
766 >      set_sticky_params( &(currentAtomType->w0), &(currentAtomType->v0));
767 >    }
768  
769      if( currentAtomType->name[0] != '\0' ){
770        isError = 0;
# Line 758 | Line 776 | void TraPPE_ExFF::readParams( void ){
776                   &(currentAtomType->epslon),
777                   &(currentAtomType->sigma),
778                   &(currentAtomType->dipole),
761                 &(currentAtomType->w0),
762                 &(currentAtomType->v0),
763                 &GB_dummy,
764                 &GB_dummy,
765                 &GB_dummy,
766                 &GB_dummy,
767                 &GB_dummy,
768                 &GB_dummy,
779                   &isError );
780        if( isError ){
781          sprintf( painCave.errMsg,
# Line 787 | Line 797 | void TraPPE_ExFF::readParams( void ){
797    
798  
799    // read in the bonds
790
800    
801 <  
802 <  
803 < }
801 > #ifdef IS_MPI
802 >  if( worldRank == 0 ){
803 > #endif
804 >    
805 >    // read in the bond types.
806 >    
807 >    headBondType = new LinkedBondType;
808 >    
809 >    fastForward( "BondTypes", "initializeBonds" );
810  
811 +    // we are now at the bondTypes section
812  
813 +    eof_test =  fgets( readLine, sizeof(readLine), frcFile );
814 +    lineNum++;
815 +    
816 +    
817 +    // read a line, and start parseing out the atom types
818  
819 < void TraPPE_ExFF::initializeAtoms( void ){
820 <  
819 >    if( eof_test == NULL ){
820 >      sprintf( painCave.errMsg,
821 >               "Error in reading bonds from force file at line %d.\n",
822 >               lineNum );
823 >      painCave.isFatal = 1;
824 >      simError();
825 >    }
826 >    
827 >    // stop reading at end of file, or at next section
828 >    while( readLine[0] != '#' && eof_test != NULL ){
829 >
830 >      // toss comment lines
831 >      if( readLine[0] != '!' ){
832 >        
833 >        // the parser returns 0 if the line was blank
834 >        if( parseBond( readLine, lineNum, bondInfo ) ){
835 >          headBondType->add( bondInfo );
836 >        }
837 >      }
838 >      eof_test = fgets( readLine, sizeof(readLine), frcFile );
839 >      lineNum++;
840 >    }
841 >        
842 > #ifdef IS_MPI
843 >    
844 >    // send out the linked list to all the other processes
845 >    
846 >    sprintf( checkPointMsg,
847 >             "TraPPE_Ex bond structures read successfully." );
848 >    MPIcheckPoint();
849 >    
850 >    currentBondType = headBondType->next;
851 >    while( currentBondType != NULL ){
852 >      currentBondType->duplicate( bondInfo );
853 >      sendFrcStruct( &bondInfo, mpiBondStructType );
854 >      currentBondType = currentBondType->next;
855 >    }
856 >    bondInfo.last = 1;
857 >    sendFrcStruct( &bondInfo, mpiBondStructType );
858 >    
859 >  }
860  
861 +  else{
862 +    
863 +    // listen for node 0 to send out the force params
864 +    
865 +    MPIcheckPoint();
866 +
867 +    headBondType = new LinkedBondType;
868 +    recieveFrcStruct( &bondInfo, mpiBondStructType );
869 +    while( !bondInfo.last ){
870 +
871 +      headBondType->add( bondInfo );
872 +      recieveFrcStruct( &bondInfo, mpiBondStructType );
873 +    }
874 +  }
875 + #endif // is_mpi
876    
877 +
878 +  // read in the bends
879 +
880 + #ifdef IS_MPI
881 +  if( worldRank == 0 ){
882 + #endif
883 +
884 +    // read in the bend types.
885 +
886 +    headBendType = new LinkedBendType;
887 +    
888 +    fastForward( "BendTypes", "initializeBends" );
889 +
890 +    // we are now at the bendTypes section
891 +
892 +    eof_test =  fgets( readLine, sizeof(readLine), frcFile );
893 +    lineNum++;
894 +        
895 +    // read a line, and start parseing out the bend types
896 +
897 +    if( eof_test == NULL ){
898 +      sprintf( painCave.errMsg,
899 +               "Error in reading bends from force file at line %d.\n",
900 +               lineNum );
901 +      painCave.isFatal = 1;
902 +      simError();
903 +    }
904 +    
905 +    // stop reading at end of file, or at next section
906 +    while( readLine[0] != '#' && eof_test != NULL ){
907 +      
908 +      // toss comment lines
909 +      if( readLine[0] != '!' ){
910 +        
911 +        // the parser returns 0 if the line was blank
912 +        if( parseBend( readLine, lineNum, bendInfo ) ){
913 +          headBendType->add( bendInfo );
914 +        }
915 +      }
916 +      eof_test = fgets( readLine, sizeof(readLine), frcFile );
917 +      lineNum++;
918 +    }
919 +    
920 + #ifdef IS_MPI
921 +    
922 +    // send out the linked list to all the other processes
923  
924 +    sprintf( checkPointMsg,
925 +             "TraPPE_Ex bend structures read successfully." );
926 +    MPIcheckPoint();
927  
928 +    currentBendType = headBendType->next;
929 +    while( currentBendType != NULL ){
930 +      currentBendType->duplicate( bendInfo );
931 +      sendFrcStruct( &bendInfo, mpiBendStructType );
932 +      currentBendType = currentBendType->next;
933 +    }
934 +    bendInfo.last = 1;
935 +    sendFrcStruct( &bendInfo, mpiBendStructType );
936 +    
937 +  }
938 +
939 +  else{
940 +    
941 +    // listen for node 0 to send out the force params
942 +    
943 +    MPIcheckPoint();
944 +
945 +    headBendType = new LinkedBendType;
946 +    recieveFrcStruct( &bendInfo, mpiBendStructType );
947 +    while( !bendInfo.last ){
948 +
949 +      headBendType->add( bendInfo );
950 +      recieveFrcStruct( &bendInfo, mpiBendStructType );
951 +    }
952 +  }
953 + #endif // is_mpi
954 +
955 +
956 +  // read in the torsions
957 +
958 + #ifdef IS_MPI
959 +  if( worldRank == 0 ){
960 + #endif
961 +
962 +    // read in the torsion types.
963 +
964 +    headTorsionType = new LinkedTorsionType;
965 +    
966 +    fastForward( "TorsionTypes", "initializeTorsions" );
967 +
968 +    // we are now at the torsionTypes section
969 +
970 +    eof_test =  fgets( readLine, sizeof(readLine), frcFile );
971 +    lineNum++;
972 +    
973 +    
974 +    // read a line, and start parseing out the atom types
975 +
976 +    if( eof_test == NULL ){
977 +      sprintf( painCave.errMsg,
978 +               "Error in reading torsions from force file at line %d.\n",
979 +               lineNum );
980 +      painCave.isFatal = 1;
981 +      simError();
982 +    }
983 +    
984 +    // stop reading at end of file, or at next section
985 +    while( readLine[0] != '#' && eof_test != NULL ){
986 +
987 +      // toss comment lines
988 +      if( readLine[0] != '!' ){
989 +        
990 +        // the parser returns 0 if the line was blank
991 +        if( parseTorsion( readLine, lineNum, torsionInfo ) ){
992 +          headTorsionType->add( torsionInfo );
993 +
994 +        }
995 +      }
996 +      eof_test = fgets( readLine, sizeof(readLine), frcFile );
997 +      lineNum++;
998 +    }
999 +
1000 + #ifdef IS_MPI
1001 +    
1002 +    // send out the linked list to all the other processes
1003 +    
1004 +    sprintf( checkPointMsg,
1005 +             "TraPPE_Ex torsion structures read successfully." );
1006 +    MPIcheckPoint();
1007 +    
1008 +    currentTorsionType = headTorsionType->next;
1009 +    while( currentTorsionType != NULL ){
1010 +      currentTorsionType->duplicate( torsionInfo );
1011 +      sendFrcStruct( &torsionInfo, mpiTorsionStructType );
1012 +      currentTorsionType = currentTorsionType->next;
1013 +    }
1014 +    torsionInfo.last = 1;
1015 +    sendFrcStruct( &torsionInfo, mpiTorsionStructType );
1016 +    
1017 +  }
1018 +
1019 +  else{
1020 +    
1021 +    // listen for node 0 to send out the force params
1022 +    
1023 +    MPIcheckPoint();
1024 +
1025 +    headTorsionType = new LinkedTorsionType;
1026 +    recieveFrcStruct( &torsionInfo, mpiTorsionStructType );
1027 +    while( !torsionInfo.last ){
1028 +
1029 +      headTorsionType->add( torsionInfo );
1030 +      recieveFrcStruct( &torsionInfo, mpiTorsionStructType );
1031 +    }
1032 +  }
1033 + #endif // is_mpi
1034 +
1035 +  entry_plug->useLJ = 1;
1036 + }
1037 +
1038 +
1039 +
1040 + void TraPPE_ExFF::initializeAtoms( int nAtoms, Atom** the_atoms ){
1041    
805  Atom** the_atoms;
806  int nAtoms;
807  the_atoms = entry_plug->atoms;
808  nAtoms = entry_plug->n_atoms;
1042    
1043    //////////////////////////////////////////////////
1044    // a quick water fix
# Line 837 | Line 1070 | void TraPPE_ExFF::initializeAtoms( void ){
1070    headI[2][1] = 0.0;
1071    headI[2][2] = 250;
1072  
840  
841
1073    //////////////////////////////////////////////////
1074  
844
845
1075    
1076    // initialize the atoms
1077    
849  double bigSigma = 0.0;
1078    DirectionalAtom* dAtom;
1079  
1080 <  for( i=0; i<nAtoms; i++ ){
1080 >  for(int i=0; i<nAtoms; i++ ){
1081  
854    
1082      currentAtomType = headAtomType->find( the_atoms[i]->getType() );
1083      if( currentAtomType == NULL ){
1084        sprintf( painCave.errMsg,
# Line 917 | Line 1144 | void TraPPE_ExFF::initializeAtoms( void ){
1144        }
1145      }
1146    }
920
921 #ifdef IS_MPI
922  double tempBig = bigSigma;
923  MPI::COMM_WORLD.Allreduce( &tempBig, &bigSigma, 1, MPI_DOUBLE, MPI_MAX );
924 #endif  //is_mpi
925
926  //calc rCut and rList
927
928  entry_plug->rCut = 2.5 * bigSigma;
929  
930  if(entry_plug->rCut > (entry_plug->box_x / 2.0))
931    entry_plug->rCut = entry_plug->box_x / 2.0;
932  
933  if(entry_plug->rCut > (entry_plug->box_y / 2.0))
934    entry_plug->rCut = entry_plug->box_y / 2.0;
935  
936  if(entry_plug->rCut > (entry_plug->box_z / 2.0))
937    entry_plug->rCut = entry_plug->box_z / 2.0;
938
939  entry_plug->rList = entry_plug->rCut + 1.0;
940
941  entry_plug->useLJ = 1; // use Lennard Jones is on by default
942
943  // clean up the memory
944  
945  delete headAtomType;
946
947 #ifdef IS_MPI
948  sprintf( checkPointMsg, "TraPPE_Ex atoms initialized succesfully" );
949  MPIcheckPoint();
950 #endif // is_mpi
951
1147   }
1148  
1149 < void TraPPE_ExFF::initializeBonds( bond_pair* the_bonds ){
1150 <  
1151 <
1152 <
1153 <
1149 > void TraPPE_ExFF::initializeBonds( int nBonds, Bond** bondArray,
1150 >                                   bond_pair* the_bonds ){
1151 >  int i,a,b;
1152 >  char* atomA;
1153 >  char* atomB;
1154    
960
961
962  info.last = 1; // initialize last to have the last set.
963                 // if things go well, last will be set to 0
964
965  SRI **the_sris;
1155    Atom** the_atoms;
967  int nBonds;
968  the_sris = entry_plug->sr_interactions;
1156    the_atoms = entry_plug->atoms;
970  nBonds = entry_plug->n_bonds;
971
972  int i, a, b;
973  char* atomA;
974  char* atomB;
1157    
976 #ifdef IS_MPI
977  if( worldRank == 0 ){
978 #endif
979    
980    // read in the bond types.
981    
982    headBondType = new LinkedType;
983    
984    fastForward( "BondTypes", "initializeBonds" );
1158  
986    // we are now at the bondTypes section
987
988    eof_test =  fgets( readLine, sizeof(readLine), frcFile );
989    lineNum++;
990    
991    
992    // read a line, and start parseing out the atom types
993
994    if( eof_test == NULL ){
995      sprintf( painCave.errMsg,
996               "Error in reading bonds from force file at line %d.\n",
997               lineNum );
998      painCave.isFatal = 1;
999      simError();
1000    }
1001    
1002    // stop reading at end of file, or at next section
1003    while( readLine[0] != '#' && eof_test != NULL ){
1004
1005      // toss comment lines
1006      if( readLine[0] != '!' ){
1007        
1008        // the parser returns 0 if the line was blank
1009        if( parseBond( readLine, lineNum, info ) ){
1010          headBondType->add( info );
1011        }
1012      }
1013      eof_test = fgets( readLine, sizeof(readLine), frcFile );
1014      lineNum++;
1015    }
1016        
1017 #ifdef IS_MPI
1018    
1019    // send out the linked list to all the other processes
1020    
1021    sprintf( checkPointMsg,
1022             "TraPPE_Ex bond structures read successfully." );
1023    MPIcheckPoint();
1024    
1025    currentBondType = headBondType;
1026    while( currentBondType != NULL ){
1027      currentBondType->duplicate( info );
1028      sendFrcStruct( &info, mpiBondStructType );
1029      currentBondType = currentBondType->next;
1030    }
1031    info.last = 1;
1032    sendFrcStruct( &info, mpiBondStructType );
1033    
1034  }
1035
1036  else{
1037    
1038    // listen for node 0 to send out the force params
1039    
1040    MPIcheckPoint();
1041
1042    headBondType = new LinkedType;
1043    recieveFrcStruct( &info, mpiBondStructType );
1044    while( !info.last ){
1045
1046      headBondType->add( info );
1047      recieveFrcStruct( &info, mpiBondStructType );
1048    }
1049  }
1050 #endif // is_mpi
1051  
1052  
1159    // initialize the Bonds
1160    
1055
1161    for( i=0; i<nBonds; i++ ){
1162      
1163      a = the_bonds[i].a;
# Line 1071 | Line 1176 | void TraPPE_ExFF::initializeBonds( bond_pair* the_bond
1176      
1177      if( !strcmp( currentBondType->type, "fixed" ) ){
1178        
1179 <      the_sris[i] = new ConstrainedBond( *the_atoms[a],
1180 <                                         *the_atoms[b],
1181 <                                         currentBondType->d0 );
1179 >      bondArray[i] = new ConstrainedBond( *the_atoms[a],
1180 >                                          *the_atoms[b],
1181 >                                          currentBondType->d0 );
1182        entry_plug->n_constraints++;
1183      }
1184    }
1080
1081
1082  // clean up the memory
1083  
1084  delete headBondType;
1085
1086 #ifdef IS_MPI
1087  sprintf( checkPointMsg, "TraPPE_Ex bonds initialized succesfully" );
1088  MPIcheckPoint();
1089 #endif // is_mpi
1090
1185   }
1186  
1187 < void TraPPE_ExFF::initializeBends( bend_set* the_bends ){
1187 > void TraPPE_ExFF::initializeBends( int nBends, Bend** bendArray,
1188 >                                   bend_set* the_bends ){
1189    
1095
1096  
1097
1098  bendStruct info;
1099  info.last = 1; // initialize last to have the last set.
1100                 // if things go well, last will be set to 0
1101
1190    QuadraticBend* qBend;
1191    GhostBend* gBend;
1104  SRI **the_sris;
1192    Atom** the_atoms;
1106  int nBends;
1107  the_sris = entry_plug->sr_interactions;
1193    the_atoms = entry_plug->atoms;
1194 <  nBends = entry_plug->n_bends;
1110 <
1194 >  
1195    int i, a, b, c;
1196    char* atomA;
1197    char* atomB;
1198    char* atomC;
1115
1116
1117 #ifdef IS_MPI
1118  if( worldRank == 0 ){
1119 #endif
1120
1121    // read in the bend types.
1122
1123    headBendType = new LinkedType;
1124    
1125    fastForward( "BendTypes", "initializeBends" );
1126
1127    // we are now at the bendTypes section
1128
1129    eof_test =  fgets( readLine, sizeof(readLine), frcFile );
1130    lineNum++;
1131        
1132    // read a line, and start parseing out the bend types
1133
1134    if( eof_test == NULL ){
1135      sprintf( painCave.errMsg,
1136               "Error in reading bends from force file at line %d.\n",
1137               lineNum );
1138      painCave.isFatal = 1;
1139      simError();
1140    }
1141    
1142    // stop reading at end of file, or at next section
1143    while( readLine[0] != '#' && eof_test != NULL ){
1144      
1145      // toss comment lines
1146      if( readLine[0] != '!' ){
1147        
1148        // the parser returns 0 if the line was blank
1149        if( parseBend( readLine, lineNum, info ) ){
1150          headBendType->add( info );
1151        }
1152      }
1153      eof_test = fgets( readLine, sizeof(readLine), frcFile );
1154      lineNum++;
1155    }
1156    
1157 #ifdef IS_MPI
1158    
1159    // send out the linked list to all the other processes
1160
1161    sprintf( checkPointMsg,
1162             "TraPPE_Ex bend structures read successfully." );
1163    MPIcheckPoint();
1164
1165    currentBendType = headBendType;
1166    while( currentBendType != NULL ){
1167      currentBendType->duplicate( info );
1168      sendFrcStruct( &info, mpiBendStructType );
1169      currentBendType = currentBendType->next;
1170    }
1171    info.last = 1;
1172    sendFrcStruct( &info, mpiBendStructType );
1173    
1174  }
1175
1176  else{
1177    
1178    // listen for node 0 to send out the force params
1179    
1180    MPIcheckPoint();
1181
1182    headBendType = new LinkedType;
1183    recieveFrcStruct( &info, mpiBendStructType );
1184    while( !info.last ){
1185
1186      headBendType->add( info );
1187      recieveFrcStruct( &info, mpiBendStructType );
1188    }
1189  }
1190 #endif // is_mpi
1199    
1200    // initialize the Bends
1193  
1194  int index;
1201  
1202    for( i=0; i<nBends; i++ ){
1203      
# Line 1216 | Line 1222 | void TraPPE_ExFF::initializeBends( bend_set* the_bends
1222      
1223      if( !strcmp( currentBendType->type, "quadratic" ) ){
1224        
1219      index = i + entry_plug->n_bonds;
1220      
1225        if( the_bends[i].isGhost){
1226          
1227          if( the_bends[i].ghost == b ){
# Line 1245 | Line 1249 | void TraPPE_ExFF::initializeBends( bend_set* the_bends
1249                               currentBendType->k2,
1250                               currentBendType->k3,
1251                               currentBendType->t0 );
1252 <        the_sris[index] = gBend;
1252 >        bendArray[i] = gBend;
1253        }
1254        else{
1255          qBend = new QuadraticBend( *the_atoms[a],
# Line 1255 | Line 1259 | void TraPPE_ExFF::initializeBends( bend_set* the_bends
1259                               currentBendType->k2,
1260                               currentBendType->k3,
1261                               currentBendType->t0 );
1262 <        the_sris[index] = qBend;
1262 >        bendArray[i] = qBend;
1263        }
1264      }
1265    }
1262
1263
1264  // clean up the memory
1265  
1266  delete headBendType;
1267
1268 #ifdef IS_MPI
1269  sprintf( checkPointMsg, "TraPPE_Ex bends initialized succesfully" );
1270  MPIcheckPoint();
1271 #endif // is_mpi
1272
1266   }
1267  
1268 < void TraPPE_ExFF::initializeTorsions( torsion_set* the_torsions ){
1268 > void TraPPE_ExFF::initializeTorsions( int nTorsions, Torsion** torsionArray,
1269 >                                      torsion_set* the_torsions ){
1270  
1271 <
1278 <  
1279 <
1280 <  torsionStruct info;
1281 <  info.last = 1; // initialize last to have the last set.
1282 <                 // if things go well, last will be set to 0
1283 <
1284 <  int i, a, b, c, d, index;
1271 >  int i, a, b, c, d;
1272    char* atomA;
1273    char* atomB;
1274    char* atomC;
1275    char* atomD;
1289  CubicTorsion* cTors;
1276  
1277 <  SRI **the_sris;
1277 >  CubicTorsion* cTors;
1278    Atom** the_atoms;
1293  int nTorsions;
1294  the_sris = entry_plug->sr_interactions;
1279    the_atoms = entry_plug->atoms;
1296  nTorsions = entry_plug->n_torsions;
1280  
1298 #ifdef IS_MPI
1299  if( worldRank == 0 ){
1300 #endif
1301
1302    // read in the torsion types.
1303
1304    headTorsionType = new LinkedType;
1305    
1306    fastForward( "TorsionTypes", "initializeTorsions" );
1307
1308    // we are now at the torsionTypes section
1309
1310    eof_test =  fgets( readLine, sizeof(readLine), frcFile );
1311    lineNum++;
1312    
1313    
1314    // read a line, and start parseing out the atom types
1315
1316    if( eof_test == NULL ){
1317      sprintf( painCave.errMsg,
1318               "Error in reading torsions from force file at line %d.\n",
1319               lineNum );
1320      painCave.isFatal = 1;
1321      simError();
1322    }
1323    
1324    // stop reading at end of file, or at next section
1325    while( readLine[0] != '#' && eof_test != NULL ){
1326
1327      // toss comment lines
1328      if( readLine[0] != '!' ){
1329        
1330        // the parser returns 0 if the line was blank
1331        if( parseTorsion( readLine, lineNum, info ) ){
1332          headTorsionType->add( info );
1333
1334        }
1335      }
1336      eof_test = fgets( readLine, sizeof(readLine), frcFile );
1337      lineNum++;
1338    }
1339
1340 #ifdef IS_MPI
1341    
1342    // send out the linked list to all the other processes
1343    
1344    sprintf( checkPointMsg,
1345             "TraPPE_Ex torsion structures read successfully." );
1346    MPIcheckPoint();
1347    
1348    currentTorsionType = headTorsionType;
1349    while( currentTorsionType != NULL ){
1350      currentTorsionType->duplicate( info );
1351      sendFrcStruct( &info, mpiTorsionStructType );
1352      currentTorsionType = currentTorsionType->next;
1353    }
1354    info.last = 1;
1355    sendFrcStruct( &info, mpiTorsionStructType );
1356    
1357  }
1358
1359  else{
1360    
1361    // listen for node 0 to send out the force params
1362    
1363    MPIcheckPoint();
1364
1365    headTorsionType = new LinkedType;
1366    recieveFrcStruct( &info, mpiTorsionStructType );
1367    while( !info.last ){
1368
1369      headTorsionType->add( info );
1370      recieveFrcStruct( &info, mpiTorsionStructType );
1371    }
1372  }
1373 #endif // is_mpi
1374  
1281    // initialize the Torsions
1282  
1283    for( i=0; i<nTorsions; i++ ){
# Line 1396 | Line 1302 | void TraPPE_ExFF::initializeTorsions( torsion_set* the
1302      }
1303      
1304      if( !strcmp( currentTorsionType->type, "cubic" ) ){
1399      index = i + entry_plug->n_bonds + entry_plug->n_bends;
1305        
1306        cTors = new CubicTorsion( *the_atoms[a], *the_atoms[b],
1307                                  *the_atoms[c], *the_atoms[d] );
1308        cTors->setConstants( currentTorsionType->k1, currentTorsionType->k2,
1309                             currentTorsionType->k3, currentTorsionType->k4 );
1310 <      the_sris[index] = cTors;
1310 >      torsionArray[i] = cTors;
1311      }
1312    }
1408
1409
1410  // clean up the memory
1411  
1412  delete headTorsionType;
1413
1414 #ifdef IS_MPI
1415  sprintf( checkPointMsg, "TraPPE_Ex torsions initialized succesfully" );
1416  MPIcheckPoint();
1417 #endif // is_mpi
1418
1313   }
1314  
1315   void TraPPE_ExFF::fastForward( char* stopText, char* searchOwner ){

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines