#include <algorithm>#include "CompressPsf.h"#include "strlib.h"#include "Molecule.h"#include "Parameters.h"#include "SimParameters.h"#include "InfoStream.h"#include "UniqueSet.h"#include "UniqueSetIter.h"Go to the source code of this file.
|
||||||||||||
|
Definition at line 1311 of file CompressPsf.C. References UniqueSet< Elem >::add(), g_mol, j, and Molecule::numAtoms. Referenced by buildExclusions(). 01312 {
01313 for(int atom1=0; atom1<g_mol->numAtoms; atom1++)
01314 {
01315 vector<int> *atom1List = &eachAtomNeighbors[atom1];
01316 for(int j=0; j<atom1List->size(); j++)
01317 {
01318 int atom2 = atom1List->at(j);
01319 if(atom1<atom2)
01320 allExcls.add(Exclusion(atom1, atom2));
01321 else
01322 allExcls.add(Exclusion(atom2, atom1));
01323 }
01324 }
01325 }
|
|
||||||||||||
|
Definition at line 1327 of file CompressPsf.C. References UniqueSet< Elem >::add(), g_mol, j, and Molecule::numAtoms. Referenced by buildExclusions(). 01328 {
01329 for(int atom1=0; atom1<g_mol->numAtoms; atom1++)
01330 {
01331 vector<int> *atom1List = &eachAtomNeighbors[atom1];
01332 for(int j=0; j<atom1List->size(); j++)
01333 {
01334 int atom2 = atom1List->at(j);
01335 vector<int> *atom2List = &eachAtomNeighbors[atom2];
01336 for(int k=0; k<atom2List->size(); k++)
01337 {
01338 int atom3 = atom2List->at(k);
01339 //atom1-atom2, so atom2List contains atom1 which should not be considered
01340 if(atom3 == atom1)
01341 continue;
01342 if(atom1<atom3)
01343 allExcls.add(Exclusion(atom1, atom3));
01344 else
01345 allExcls.add(Exclusion(atom3, atom1));
01346 }
01347 }
01348 }
01349 }
|
|
||||||||||||||||
|
Definition at line 1351 of file CompressPsf.C. References UniqueSet< Elem >::add(), g_mol, j, and Molecule::numAtoms. Referenced by buildExclusions(). 01352 {
01353 for(int atom1=0; atom1<g_mol->numAtoms; atom1++)
01354 {
01355 vector<int> *atom1List = &eachAtomNeighbors[atom1];
01356 for(int j=0; j<atom1List->size(); j++)
01357 {
01358 int atom2 = atom1List->at(j);
01359 vector<int> *atom2List = &eachAtomNeighbors[atom2];
01360 for(int k=0; k<atom2List->size(); k++)
01361 {
01362 int atom3 = atom2List->at(k);
01363 //atom1-atom2, so atom2List contains atom1 which should not be considered
01364 if(atom3 == atom1)
01365 continue;
01366 vector<int> *atom3List = &eachAtomNeighbors[atom3];
01367 for(int l=0; l<atom3List->size(); l++)
01368 {
01369 int atom4 = atom3List->at(l);
01370 //atom1-atom2, so atom2List contains atom1 which should not be considered
01371 if(atom4 == atom2)
01372 continue;
01373 if(atom1<atom4)
01374 allExcls.add(Exclusion(atom1, atom4, modified));
01375 else
01376 allExcls.add(Exclusion(atom4, atom1, modified));
01377 }
01378 }
01379 }
01380 }
01381 }
|
|
|
Definition at line 1079 of file CompressPsf.C. References ANGLE, Angle, angle::angle_type, AtomSigInfo::angleSigIndices, angle::atom1, angle::atom2, angle::atom3, eachAtomSigs, g_mol, Molecule::getAllAngles(), HashPool< T >::lookupCstPool(), Molecule::numAngles, HashPool< T >::push_back(), sigsOfAngles, and HashPool< T >::size(). Referenced by loadMolInfo(). 01080 {
01081 #ifndef MEM_OPT_VERSION
01082 Angle *angles = g_mol->getAllAngles();
01083 //create angles' tupleSignature
01084 for(int i=0; i<g_mol->numAngles; i++)
01085 {
01086 Angle *tuple = angles+i;
01087 TupleSignature oneSig(2,ANGLE,tuple->angle_type);
01088 int offset[2];
01089 offset[0] = tuple->atom2 - tuple->atom1;
01090 offset[1] = tuple->atom3 - tuple->atom1;
01091 oneSig.setOffsets(offset);
01092
01093 int poolIndex = sigsOfAngles.lookupCstPool(oneSig);
01094 if(poolIndex == -1)
01095 {
01096 sigsOfAngles.push_back(oneSig);
01097 poolIndex = (SigIndex)sigsOfAngles.size()-1;
01098 }
01099 eachAtomSigs[tuple->atom1].angleSigIndices.push_back(poolIndex);
01100 }
01101 delete [] angles;
01102 #endif
01103 }
|
|
|
Definition at line 764 of file CompressPsf.C. References Atom, atomData, BasicAtomInfo::atomNameIdx, AtomNameInfo, atomNamePool, AtomSegResInfo, BasicAtomInfo::atomTypeIdx, atomTypePool, BasicAtomInfo::chargeIdx, chargePool, g_mol, Molecule::getAtomNames(), Molecule::getAtoms(), Molecule::getAtomSegResInfo(), HashPool< T >::lookupCstPool(), BasicAtomInfo::massIdx, massPool, Molecule::numAtoms, HashPool< T >::push_back(), seg_resid::resid, BasicAtomInfo::resID, BasicAtomInfo::resNameIdx, resNamePool, BasicAtomInfo::segNameIdx, segNamePool, and HashPool< T >::size(). Referenced by loadMolInfo(). 00765 {
00766 #ifndef MEM_OPT_VERSION
00767 int numAtoms = g_mol->numAtoms;
00768
00769 //1. parse atom data to build constant pool (atom name, mass, charge etc.)
00770 atomData = new BasicAtomInfo[numAtoms];
00771 Atom *atoms = g_mol->getAtoms();
00772 AtomNameInfo *atomNames = g_mol->getAtomNames();
00773 AtomSegResInfo *atomSegResids = g_mol->getAtomSegResInfo();
00774
00775 for(int atomID=0; atomID < numAtoms; atomID++)
00776 {
00777 //building constant pool
00778 int poolIndex;
00779 HashString fieldName;
00780 fieldName.assign(atomSegResids[atomID].segname);
00781 poolIndex = segNamePool.lookupCstPool(fieldName);
00782 if(poolIndex==-1)
00783 {
00784 segNamePool.push_back(fieldName);
00785 poolIndex = segNamePool.size()-1;
00786 }
00787 atomData[atomID].segNameIdx = poolIndex;
00788
00789 atomData[atomID].resID = atomSegResids[atomID].resid;
00790
00791 fieldName.assign(atomNames[atomID].resname);
00792 poolIndex = resNamePool.lookupCstPool(fieldName);
00793 if(poolIndex==-1)
00794 {
00795 resNamePool.push_back(fieldName);
00796 poolIndex = resNamePool.size()-1;
00797 }
00798 atomData[atomID].resNameIdx = poolIndex;
00799
00800 fieldName.assign(atomNames[atomID].atomname);
00801 poolIndex = atomNamePool.lookupCstPool(fieldName);
00802 if(poolIndex==-1)
00803 {
00804 atomNamePool.push_back(fieldName);
00805 poolIndex = atomNamePool.size()-1;
00806 }
00807 atomData[atomID].atomNameIdx = poolIndex;
00808
00809 fieldName.assign(atomNames[atomID].atomtype);
00810 poolIndex = atomTypePool.lookupCstPool(fieldName);
00811 if(poolIndex==-1)
00812 {
00813 atomTypePool.push_back(fieldName);
00814 poolIndex = atomTypePool.size()-1;
00815 }
00816 atomData[atomID].atomTypeIdx = poolIndex;
00817
00818 poolIndex = chargePool.lookupCstPool(atoms[atomID].charge);
00819 if(poolIndex==-1)
00820 {
00821 chargePool.push_back(atoms[atomID].charge);
00822 poolIndex = chargePool.size()-1;
00823 }
00824 atomData[atomID].chargeIdx = poolIndex;
00825
00826 poolIndex = massPool.lookupCstPool(atoms[atomID].mass);
00827 if(poolIndex==-1)
00828 {
00829 massPool.push_back(atoms[atomID].mass);
00830 poolIndex = massPool.size()-1;
00831 }
00832 atomData[atomID].massIdx = poolIndex;
00833 }
00834
00835 //Free those space to reduce transient memory usage
00836 //delete [] atoms; (deleted until per-atom info is output)
00837 delete [] atomNames;
00838 delete [] atomSegResids;
00839 #endif
00840 }
|
|
|
Definition at line 843 of file CompressPsf.C. References bond::atom1, bond::atom2, BOND, Bond, bond::bond_type, AtomSigInfo::bondSigIndices, eachAtomClusterID, eachAtomSigs, eachClusterID, eachClusterSize, g_mol, g_numClusters, Molecule::getAllBonds(), j, lookupCstPool(), HashPool< T >::lookupCstPool(), NAMD_die(), Molecule::numAtoms, Molecule::numBonds, Molecule::numRealBonds, TupleSignature::offset, HashPool< T >::push_back(), SigIndex, sigsOfBonds, and HashPool< T >::size(). Referenced by loadMolInfo(). 00844 {
00845 #ifndef MEM_OPT_VERSION
00846 Bond *bonds = g_mol->getAllBonds();
00847
00848 //then creating bond's tupleSignature
00849 for(int i=0; i<g_mol->numBonds; i++)
00850 {
00851 Bond *b = bonds+i;
00852 TupleSignature oneSig(1,BOND,b->bond_type);
00853 oneSig.offset[0] = b->atom2 - b->atom1;
00854 oneSig.isReal = (i<g_mol->numRealBonds);
00855
00856 int poolIndex = sigsOfBonds.lookupCstPool(oneSig);
00857 int newSig=0;
00858 if(poolIndex == -1)
00859 {
00860 sigsOfBonds.push_back(oneSig);
00861 poolIndex = (SigIndex)sigsOfBonds.size()-1;
00862 newSig=1;
00863 }
00864
00865 if(!newSig)
00866 {//check duplicate bonds in the form of (a, b) && (a, b);
00867 int dupIdx = lookupCstPool(eachAtomSigs[b->atom1].bondSigIndices, (SigIndex)poolIndex);
00868 if(dupIdx!=-1)
00869 {
00870 char err_msg[128];
00871 sprintf(err_msg, "Duplicate bond %d-%d!", b->atom1+1, b->atom2+1);
00872 NAMD_die(err_msg);
00873 }
00874 }
00875 eachAtomSigs[b->atom1].bondSigIndices.push_back(poolIndex);
00876 }
00877
00878 //check duplicate bonds in the form of (a, b) && (b, a)
00879 for(int i=0; i<g_mol->numBonds; i++)
00880 {
00881 Bond *b=bonds+i;
00882 int atom2 = b->atom2;
00883 int thisOffset = atom2 - b->atom1;
00884 for(int j=0; j<eachAtomSigs[atom2].bondSigIndices.size(); j++)
00885 {
00886 SigIndex atom2BondId = eachAtomSigs[atom2].bondSigIndices[j];
00887 TupleSignature *secSig = &(sigsOfBonds[atom2BondId]);
00888 if(thisOffset== -(secSig->offset[0]))
00889 {
00890 char err_msg[128];
00891 sprintf(err_msg, "Duplicate bond %d-%d because two atoms are just reversed!", b->atom1+1, atom2+1);
00892 NAMD_die(err_msg);
00893 }
00894 }
00895 }
00896
00897 //building clusters for this simulation system in two steps
00898 //1. create a list for each atom where each atom in the list is bonded with that atom
00899 vector<int> *atomListOfBonded = new vector<int>[g_mol->numAtoms];
00900
00901 for(int i=0; i<g_mol->numRealBonds; i++)
00902 {
00903 Bond *b=bonds+i;
00904 int atom1 = b->atom1;
00905 int atom2 = b->atom2;
00906 atomListOfBonded[atom1].push_back(atom2);
00907 atomListOfBonded[atom2].push_back(atom1);
00908 }
00909
00910 delete [] bonds;
00911
00912 //2. using breadth-first-search to build the clusters. Here, we avoid recursive call
00913 // because the depth of calls may be of thousands which will blow up the stack, and
00914 //recursive call is slower than the stack-based BFS.
00915 //Considering such structure
00916 //1->1245; 7->1243; 1243->1245
00917 eachAtomClusterID = new int[g_mol->numAtoms];
00918 for(int i=0; i<g_mol->numAtoms; i++)
00919 eachAtomClusterID[i] = -1;
00920
00921 //It is guaranteed that the clusters found in this way use the
00922 //smallest atom id of this cluster because each atom is at least
00923 //connected to one of the atoms in its cluster (by atomListOfBonded
00924 //constructed above).
00925 //--Chao Mei
00926 for(int i=0; i<g_mol->numAtoms; i++)
00927 {
00928 int curClusterID=eachAtomClusterID[i];
00929 //if the atom's cluster id is not -1, the atom has been visited
00930 if(curClusterID!=-1) continue;
00931
00932 curClusterID=i;
00933 deque<int> toVisitAtoms;
00934 toVisitAtoms.push_back(i);
00935 while(!toVisitAtoms.empty())
00936 {
00937 int visAtomID = toVisitAtoms.front();
00938 toVisitAtoms.pop_front();
00939 eachAtomClusterID[visAtomID] = curClusterID;
00940 for(int j=0; j<atomListOfBonded[visAtomID].size(); j++)
00941 {
00942 int otherAtom = atomListOfBonded[visAtomID][j];
00943 if(eachAtomClusterID[otherAtom]!=curClusterID)
00944 toVisitAtoms.push_back(otherAtom);
00945 }
00946 }
00947 }
00948
00949 #if 0
00950 //Now the clusterID of each atom should be usually in the non-decreasing
00951 //order. In other words, the atom ids of a cluster are generally contiguous.
00952 //If this is the case, the temporary memory usage of output IO during
00953 //the simulation can be dramatically reduced. So g_isClusterContiguous
00954 //is used to differentiate the two cases:
00955
00956 //1. if the cluster id of atoms is monotonically increasing
00957 //(g_isClusterContiguous=1), the size of the cluster can be used as this
00958 //this cluster's signature (represented by "eachAtomClusterID").
00959 //The atom who is the first atom (in terms of atom id) in this cluster will
00960 //store the cluster size as its signature. The remaining atoms in this
00961 //cluster store -1.
00962
00963 //2. if the cluster id of atoms is not monotonically increasing, that is,
00964 //the atom ids of a cluster are not contiguous (g_isClusterContiguous=0).
00965 //Then we have to still record each atom's cluster id in variable
00966 //"eachAtomClusterID", and we have to change each unique cluster id (valued
00967 //at the scale of numAtoms) into indexes at the scale of numClusters. For
00968 //example, the cluster ids of atoms up to this point may be (0...0, 24...24,
00969 //789...789,...), after re-scaling, cluster ids should be (0...0,1...1,
00970 //2...2,....) for atoms.
00971 //We made an ASSUMPTION here: the cluster ids are in the non-decreasing
00972 //order, and when a cluster discontiguity happens, the cluster id has
00973 //appeared before! Such ASSUMPTION is to make implementation easy.
00974
00975 int curClusterID;
00976 int prevClusterID = eachAtomClusterID[0];
00977 int curClusterSize = 1;
00978 //step1: segment all atoms according to each cluster
00979 for(int i=1; i<g_mol->numAtoms; i++){
00980 curClusterID = eachAtomClusterID[i];
00981 if(curClusterID == prevClusterID){
00982 curClusterSize++;
00983 }else{
00984 eachClusterSize.push_back(curClusterSize);
00985 eachClusterID.push_back(prevClusterID);
00986 curClusterSize=1;
00987 }
00988 prevClusterID = curClusterID;
00989 }
00990 //record the info of the last cluster segment
00991 eachClusterSize.push_back(curClusterSize);
00992 eachClusterID.push_back(prevClusterID);
00993
00994 //step2: detect contiguity of atoms in each cluster and re-scale
00995 //cluster id.
00996 g_isClusterContiguous = 1;
00997 int *newClusterIDs = new int[eachClusterID.size()];
00998 memset(newClusterIDs, 0, sizeof(int)*eachClusterID.size());
00999 prevClusterID = eachClusterID[0];
01000 int newCId = 0;
01001 newClusterIDs[0] = newCId;
01002 for(int seg=1; seg<eachClusterID.size(); seg++){
01003 curClusterID = eachClusterID[seg];
01004 if(curClusterID > prevClusterID){
01005 newClusterIDs[seg] = ++newCId;
01006 prevClusterID = curClusterID;
01007 }else{
01008 //non-contiguity happens
01009 g_isClusterContiguous = 0;
01010
01011 //we ASSUME this id appears before
01012 //binary search in eachAtomClusterID[0...seg-1).
01013 int jl=0, jh=seg-2;
01014 int isFound = 0;
01015 while(jh>=jl){
01016 int mid = (jl+jh)/2;
01017 if(curClusterID > eachClusterID[mid])
01018 jl = mid+1;
01019 else if(curClusterID < eachClusterID[mid])
01020 jh = mid-1;
01021 else{
01022 newClusterIDs[seg] = newClusterIDs[mid];
01023 isFound = 1;
01024 break;
01025 }
01026 }
01027 if(!isFound){
01028 //ASSUMPTION is wrong and abort
01029 char errmsg[300];
01030 sprintf(errmsg, "Assumption about building cluster is broken in file %s at line %d\n", __FILE__, __LINE__);
01031 NAMD_die(errmsg);
01032 }
01033 }
01034 }
01035
01036 //step 3: modify eachAtomClusterID according to g_isClusterContiguous
01037 //newCId is the id of the last cluster, as id starts from 0, so the
01038 //total number clusters should be newCId+1
01039 g_numClusters = newCId+1;
01040 if(g_isClusterContiguous){
01041 int aid=0;
01042 for(int seg=0; seg<eachClusterSize.size(); seg++)
01043 {
01044 int curSize = eachClusterSize[seg];
01045 eachAtomClusterID[aid] = curSize;
01046 for(int i=aid+1; i<aid+curSize; i++)
01047 eachAtomClusterID[i] = -1;
01048 aid += curSize;
01049 }
01050 }else{
01051 int aid=0;
01052 for(int seg=0; seg<eachClusterSize.size(); seg++)
01053 {
01054 int curSize = eachClusterSize[seg];
01055 for(int i=aid; i<aid+curSize; i++)
01056 eachAtomClusterID[i] = newClusterIDs[seg];
01057 aid += curSize;
01058 }
01059 }
01060 free(newClusterIDs);
01061 eachClusterSize.clear();
01062 eachClusterID.clear();
01063 #endif
01064
01065 /*
01066 //check whether cluster is built correctly
01067 printf("num clusters: %d\n", g_numClusters);
01068 FILE *checkFile = fopen("cluster.opt", "w");
01069 for(int i=0; i<g_mol->numAtoms; i++) fprintf(checkFile, "%d\n", eachAtomClusterID[i]);
01070 fclose(checkFile);
01071 */
01072
01073 for(int i=0; i<g_mol->numAtoms; i++)
01074 atomListOfBonded[i].clear();
01075 delete [] atomListOfBonded;
01076 #endif
01077 }
|
|
|
Definition at line 1163 of file CompressPsf.C. References crossterm::atom1, crossterm::atom2, crossterm::atom3, crossterm::atom4, crossterm::atom5, crossterm::atom6, crossterm::atom7, crossterm::atom8, CROSSTERM, Crossterm, crossterm::crossterm_type, AtomSigInfo::crosstermSigIndices, eachAtomSigs, g_mol, Molecule::getAllCrossterms(), HashPool< T >::lookupCstPool(), Molecule::numCrossterms, HashPool< T >::push_back(), sigsOfCrossterms, and HashPool< T >::size(). Referenced by loadMolInfo(). 01164 {
01165 #ifndef MEM_OPT_VERSION
01166 Crossterm *crossterms = g_mol->getAllCrossterms();
01167 //create crossterm's tupleSignature
01168 for(int i=0; i<g_mol->numCrossterms; i++)
01169 {
01170 Crossterm *tuple = crossterms+i;
01171 TupleSignature oneSig(7, CROSSTERM, tuple->crossterm_type);
01172 int offset[7];
01173 offset[0] = tuple->atom2 - tuple->atom1;
01174 offset[1] = tuple->atom3 - tuple->atom1;
01175 offset[2] = tuple->atom4 - tuple->atom1;
01176 offset[3] = tuple->atom5 - tuple->atom1;
01177 offset[4] = tuple->atom6 - tuple->atom1;
01178 offset[5] = tuple->atom7 - tuple->atom1;
01179 offset[6] = tuple->atom8 - tuple->atom1;
01180 oneSig.setOffsets(offset);
01181
01182 int poolIndex = sigsOfCrossterms.lookupCstPool(oneSig);
01183 if(poolIndex == -1)
01184 {
01185 sigsOfCrossterms.push_back(oneSig);
01186 poolIndex = (SigIndex)sigsOfCrossterms.size()-1;
01187 }
01188 eachAtomSigs[tuple->atom1].crosstermSigIndices.push_back(poolIndex);
01189 }
01190
01191 delete[] crossterms;
01192 #endif
01193 }
|
|
|
Definition at line 1105 of file CompressPsf.C. References dihedral::atom1, dihedral::atom2, dihedral::atom3, dihedral::atom4, DIHEDRAL, Dihedral, dihedral::dihedral_type, AtomSigInfo::dihedralSigIndices, eachAtomSigs, g_mol, Molecule::getAllDihedrals(), HashPool< T >::lookupCstPool(), Molecule::numDihedrals, HashPool< T >::push_back(), sigsOfDihedrals, and HashPool< T >::size(). Referenced by loadMolInfo(). 01106 {
01107 #ifndef MEM_OPT_VERSION
01108 Dihedral *dihedrals = g_mol->getAllDihedrals();
01109
01110 //create dihedrals' tupleSignature
01111 for(int i=0; i<g_mol->numDihedrals; i++)
01112 {
01113 Dihedral *tuple = dihedrals+i;
01114 TupleSignature oneSig(3,DIHEDRAL,tuple->dihedral_type);
01115 int offset[3];
01116 offset[0] = tuple->atom2 - tuple->atom1;
01117 offset[1] = tuple->atom3 - tuple->atom1;
01118 offset[2] = tuple->atom4 - tuple->atom1;
01119 oneSig.setOffsets(offset);
01120
01121 int poolIndex = sigsOfDihedrals.lookupCstPool(oneSig);
01122 if(poolIndex == -1)
01123 {
01124 sigsOfDihedrals.push_back(oneSig);
01125 poolIndex = (SigIndex)sigsOfDihedrals.size()-1;
01126 }
01127 eachAtomSigs[tuple->atom1].dihedralSigIndices.push_back(poolIndex);
01128 }
01129
01130 delete[] dihedrals;
01131 #endif
01132 }
|
|
|
|
|
|
Definition at line 1195 of file CompressPsf.C. References SimParameters::amberOn, atomData, BasicAtomInfo::atomSigIdx, atomSigPool, UniqueSetIter< T >::begin(), AtomSigInfo::bondSigIndices, build12Excls(), build13Excls(), build14Excls(), UniqueSet< Elem >::clear(), eachAtomExclSigs, UniqueSetIter< T >::end(), BasicAtomInfo::exclSigIdx, SimParameters::exclude, ExclSigInfo::fullExclOffset, g_mol, g_simParam, TupleSignature::isReal, j, HashPool< T >::lookupCstPool(), ExclSigInfo::modExclOffset, NONE, Molecule::numAtoms, TupleSignature::offset, ONEFOUR, ONETHREE, ONETWO, HashPool< T >::push_back(), SimParameters::readExclusions, SCALED14, sigsOfBonds, sigsOfExclusions, HashPool< T >::size(), and ExclSigInfo::sortExclOffset(). Referenced by compress_molecule_info(). 01196 {
01197 //1. Build exclusions: mainly accomplish the function of
01198 //Molecule::build_exclusions (based on the bonds)
01199 UniqueSet<Exclusion> allExclusions;
01200
01201 int exclude_flag; //Exclusion policy
01202 exclude_flag = g_simParam->exclude;
01203 //int stripHGroupExclFlag = (simParams->splitPatch == SPLIT_PATCH_HYDROGEN);
01204
01205 //Commented now since no explicit exclusions are read
01206 // Go through the explicit exclusions and add them to the arrays
01207 //for(i=0; i<numExclusions; i++){
01208 // exclusionSet.add(exclusions[i]);
01209 //}
01210
01211 // If this is AMBER force field, and readExclusions is TRUE,
01212 // then all the exclusions were read from parm file, and we
01213 // shouldn't generate any of them.
01214 // Comment on stripHGroupExcl:
01215 // 1. Inside this function, hydrogenGroup is initialized in
01216 // build_atom_status, therefore, not available when reading psf files
01217 // 2. this function's main purpose is to reduce memory usage. Since exclusion
01218 // signatures are used, this function could be overlooked --Chao Mei
01219
01220 vector<int> *eachAtomNeighbors = new vector<int>[g_mol->numAtoms];
01221 for(int atom1=0; atom1<g_mol->numAtoms; atom1++)
01222 {
01223 AtomSigInfo *aSig = &atomSigPool[atomData[atom1].atomSigIdx];
01224 for(int j=0; j<aSig->bondSigIndices.size(); j++)
01225 {
01226 TupleSignature *tSig = &sigsOfBonds[aSig->bondSigIndices[j]];
01227 if(!tSig->isReal) continue;
01228 int atom2 = atom1+tSig->offset[0];
01229 eachAtomNeighbors[atom1].push_back(atom2);
01230 eachAtomNeighbors[atom2].push_back(atom1);
01231 }
01232 }
01233
01234 if (!g_simParam->amberOn || !g_simParam->readExclusions)
01235 { // Now calculate the bonded exlcusions based on the exclusion policy
01236 switch (exclude_flag)
01237 {
01238 case NONE:
01239 break;
01240 case ONETWO:
01241 build12Excls(allExclusions, eachAtomNeighbors);
01242 break;
01243 case ONETHREE:
01244 build12Excls(allExclusions, eachAtomNeighbors);
01245 build13Excls(allExclusions, eachAtomNeighbors);
01246 //if ( stripHGroupExclFlag ) stripHGroupExcl();
01247 break;
01248 case ONEFOUR:
01249 build12Excls(allExclusions, eachAtomNeighbors);
01250 build13Excls(allExclusions, eachAtomNeighbors);
01251 build14Excls(allExclusions, eachAtomNeighbors, 0);
01252 //if ( stripHGroupExclFlag ) stripHGroupExcl();
01253 break;
01254 case SCALED14:
01255 build12Excls(allExclusions, eachAtomNeighbors);
01256 build13Excls(allExclusions, eachAtomNeighbors);
01257 build14Excls(allExclusions, eachAtomNeighbors, 1);
01258 //if ( stripHGroupExclFlag ) stripHGroupExcl();
01259 break;
01260 }
01261 }
01262 //else if (stripHGroupExclFlag && exclude_flag!=NONE && exclude_flag!=ONETWO)
01263 // stripHGroupExcl();
01264
01265 //Commented since atomFepFlags information is not available when reading psf file
01266 //stripFepExcl();
01267
01268 for(int i=0; i<g_mol->numAtoms; i++)
01269 eachAtomNeighbors[i].clear();
01270 delete [] eachAtomNeighbors;
01271
01272 //2. Build each atom's list of exclusions
01273 UniqueSetIter<Exclusion> exclIter(allExclusions);
01274 eachAtomExclSigs = new ExclSigInfo[g_mol->numAtoms];
01275 for(exclIter=exclIter.begin(); exclIter!=exclIter.end(); exclIter++)
01276 {
01277 int atom1 = exclIter->atom1;
01278 int atom2 = exclIter->atom2;
01279 int offset21 = atom2-atom1;
01280 if(exclIter->modified)
01281 {
01282 eachAtomExclSigs[atom1].modExclOffset.push_back(offset21);
01283 eachAtomExclSigs[atom2].modExclOffset.push_back(-offset21);
01284 }
01285 else
01286 {
01287 eachAtomExclSigs[atom1].fullExclOffset.push_back(offset21);
01288 eachAtomExclSigs[atom2].fullExclOffset.push_back(-offset21);
01289 }
01290 }
01291 allExclusions.clear();
01292
01293 //3. Build up exclusion signatures and determine each atom's
01294 //exclusion signature index
01295 for(int i=0; i<g_mol->numAtoms; i++)
01296 {
01297 eachAtomExclSigs[i].sortExclOffset();
01298 int poolIndex = sigsOfExclusions.lookupCstPool(eachAtomExclSigs[i]);
01299 if(poolIndex==-1)
01300 {
01301 poolIndex = sigsOfExclusions.size();
01302 sigsOfExclusions.push_back(eachAtomExclSigs[i]);
01303 }
01304 atomData[i].exclSigIdx = poolIndex;
01305 }
01306 delete [] eachAtomExclSigs;
01307 eachAtomExclSigs = NULL;
01308 printf("Exclusion signatures: %d\n", (int)sigsOfExclusions.size());
01309 }
|
|
|
Definition at line 1134 of file CompressPsf.C. References improper::atom1, improper::atom2, improper::atom3, improper::atom4, eachAtomSigs, g_mol, Molecule::getAllImpropers(), IMPROPER, Improper, improper::improper_type, AtomSigInfo::improperSigIndices, HashPool< T >::lookupCstPool(), Molecule::numImpropers, HashPool< T >::push_back(), sigsOfImpropers, and HashPool< T >::size(). Referenced by loadMolInfo(). 01135 {
01136 #ifndef MEM_OPT_VERSION
01137 Improper *impropers=g_mol->getAllImpropers();
01138
01139 //create improper's tupleSignature
01140 for(int i=0; i<g_mol->numImpropers; i++)
01141 {
01142 Improper *tuple = impropers+i;
01143 TupleSignature oneSig(3,IMPROPER,tuple->improper_type);
01144 int offset[3];
01145 offset[0] = tuple->atom2 - tuple->atom1;
01146 offset[1] = tuple->atom3 - tuple->atom1;
01147 offset[2] = tuple->atom4 - tuple->atom1;
01148 oneSig.setOffsets(offset);
01149
01150 int poolIndex = sigsOfImpropers.lookupCstPool(oneSig);
01151 if(poolIndex == -1)
01152 {
01153 sigsOfImpropers.push_back(oneSig);
01154 poolIndex = (SigIndex)sigsOfImpropers.size()-1;
01155 }
01156 eachAtomSigs[tuple->atom1].improperSigIndices.push_back(poolIndex);
01157 }
01158
01159 delete[] impropers;
01160 #endif
01161 }
|
|
|
Definition at line 419 of file CompressPsf.C. References atomNamePool, atomTypePool, chargePool, HashPool< T >::clear(), eachClusterSize, massPool, resNamePool, segNamePool, sigsOfAngles, sigsOfBonds, sigsOfDihedrals, sigsOfExclusions, and sigsOfImpropers. 00420 {
00421 segNamePool.clear();
00422 resNamePool.clear();
00423 atomNamePool.clear();
00424 atomTypePool.clear();
00425 chargePool.clear();
00426 massPool.clear();
00427 sigsOfBonds.clear();
00428 sigsOfAngles.clear();
00429 sigsOfDihedrals.clear();
00430 sigsOfImpropers.clear();
00431 sigsOfExclusions.clear();
00432
00433 eachClusterSize.clear();
00434 }
|
|
||||||||||||||||||||||||
|
Definition at line 436 of file CompressPsf.C. References buildExclusions(), g_cfgList, g_mol, g_param, g_simParam, integrateAllAtomSigs(), loadMolInfo(), and outputCompressedFile(). Referenced by NamdState::configListInit(). 00437 {
00438 g_mol = mol;
00439 g_param = param;
00440 g_simParam = simParam; //used for building exclusions
00441 g_cfgList = cfgList; //used for integrating extra bonds
00442
00443 //read psf files
00444 //readPsfFile(psfFileName);
00445 loadMolInfo();
00446
00447 integrateAllAtomSigs();
00448
00449 buildExclusions();
00450
00451 //buildParamData();
00452
00453 char *outFileName = new char[strlen(psfFileName)+20];
00454 sprintf(outFileName, "%s.inter", psfFileName);
00455 //the text file for signatures and other non-per-atom info
00456 FILE *txtOfp = fopen(outFileName, "w");
00457 sprintf(outFileName, "%s.inter.bin", psfFileName);
00458 //the binary file for per-atom info
00459 FILE *binOfp = fopen(outFileName, "wb");
00460 delete [] outFileName;
00461
00462 //output compressed psf file
00463 outputCompressedFile(txtOfp, binOfp);
00464
00465 fclose(txtOfp);
00466 fclose(binOfp);
00467 }
|
|
||||||||||||||||
|
Definition at line 406 of file CompressPsf.C. References j. Referenced by OutputAtomRecord::flip(). 00406 {
00407 int mid = elemSize/2;
00408 char *ptr = elem;
00409 for(int i=0; i<numElems; i++) {
00410 for(int j=0; j<mid; j++) {
00411 char tmp = ptr[j];
00412 ptr[j] = ptr[elemSize-1-j];
00413 ptr[elemSize-1-j] = tmp;
00414 }
00415 ptr += elemSize;
00416 }
00417 }
|
|
|
|
|
|
Definition at line 505 of file CompressPsf.C. References atomData, BasicAtomInfo::atomSigIdx, atomSigPool, eachAtomSigs, g_mol, HashPool< T >::lookupCstPool(), Molecule::numAtoms, HashPool< T >::push_back(), sigsOfAngles, sigsOfBonds, sigsOfCrossterms, sigsOfDihedrals, sigsOfImpropers, HashPool< T >::size(), and AtomSigInfo::sortTupleSigIndices(). Referenced by compress_molecule_info(). 00506 {
00507 printf("Bond sigs: %d\n", (int)sigsOfBonds.size());
00508 printf("Angle sigs: %d\n", (int)sigsOfAngles.size());
00509 printf("Dihedral sigs: %d\n", (int)sigsOfDihedrals.size());
00510 printf("Improper sigs: %d\n", (int)sigsOfImpropers.size());
00511 printf("Crossterm sigs: %d\n", (int)sigsOfCrossterms.size());
00512
00513
00514 for(int i=0; i<g_mol->numAtoms; i++)
00515 {
00516 eachAtomSigs[i].sortTupleSigIndices();
00517 int poolIndex = atomSigPool.lookupCstPool(eachAtomSigs[i]);
00518 if(poolIndex==-1)
00519 {
00520 atomSigPool.push_back(eachAtomSigs[i]);
00521 poolIndex = atomSigPool.size()-1;
00522 }
00523 atomData[i].atomSigIdx = poolIndex;
00524 }
00525
00526 printf("Atom's sigs: %d\n", (int)atomSigPool.size());
00527
00528 delete[] eachAtomSigs;
00529 }
|
|
|
Before entering this function, all information about Molecule has been obtained. The Molecule::build_atom_status should also be called. Definition at line 473 of file CompressPsf.C. References buildAngleData(), buildAtomData(), buildBondData(), buildCrosstermData(), buildDihedralData(), buildImproperData(), eachAtomSigs, g_mol, and Molecule::numAtoms. Referenced by compress_molecule_info(). 00474 {
00475 char err_msg[512]; // Error message for NAMD_die
00476 char buffer[512]; // Buffer for file reading
00477 int i; // Loop counter
00478 int NumTitle; // Number of Title lines in .psf file
00479 int ret_code; // ret_code from NAMD_read_line calls
00480 FILE *psf_file;
00481 Parameters *params = g_param;
00482
00483 buildAtomData();
00484
00485 //read extra bonds/angles/dihedrals/impropers information first
00486 //and then integrate them into the following reading procedures
00487 /*if(g_simParam->extraBondsOn)
00488 {
00489 getExtraBonds(g_cfgList->find("extraBondsFile"));
00490 }*/
00491
00492 //initialize eachAtomSigs
00493 eachAtomSigs = new AtomSigInfo[g_mol->numAtoms];
00494
00495 buildBondData();
00496 buildAngleData();
00497 buildDihedralData();
00498 buildImproperData();
00499 buildCrosstermData();
00500
00501 // analyze the data and find the status of each atom
00502 //build_atom_status();
00503 }
|
|
||||||||||||
|
Definition at line 353 of file CompressPsf.C. References four_body_consts::delta, FourBodyConsts, four_body_consts::k, and four_body_consts::n. Referenced by UniqueSetIter< T >::operator==(), ResizeArrayPrimIter< Compute * >::operator==(), and ResizeArrayIter< PatchElem >::operator==().
|
|
||||||||||||
|
Definition at line 370 of file CompressPsf.C. References ImproperValue::multiplicity, and ImproperValue::values. 00371 {
00372 if(d1.multiplicity != d2.multiplicity)
00373 return 0;
00374 for(int i=0; i<MAX_MULTIPLICITY; i++)
00375 {
00376 if(d1.values[i] != d2.values[i])
00377 return 0;
00378 }
00379 return 1;
00380 }
|
|
||||||||||||
|
Definition at line 358 of file CompressPsf.C. References DihedralValue::multiplicity, and DihedralValue::values. 00359 {
00360 if(d1.multiplicity != d2.multiplicity)
00361 return 0;
00362 for(int i=0; i<MAX_MULTIPLICITY; i++)
00363 {
00364 if(d1.values[i] != d2.values[i])
00365 return 0;
00366 }
00367 return 1;
00368 }
|
|
||||||||||||
|
Definition at line 348 of file CompressPsf.C. References AngleValue::k, AngleValue::k_ub, AngleValue::r_ub, and AngleValue::theta0. 00349 {
00350 return (a1.k==a2.k) && (a1.k_ub==a2.k_ub) && (a1.r_ub==a2.r_ub) && (a1.theta0==a2.theta0);
00351 }
|
|
||||||||||||
|
Definition at line 343 of file CompressPsf.C. References BondValue::k, and BondValue::x0.
|
|
||||||||||||
|
Definition at line 253 of file CompressPsf.C. References ExclSigInfo::fullExclOffset, and ExclSigInfo::modExclOffset. 00254 {
00255 if(s1.fullExclOffset.size()!=s2.fullExclOffset.size())
00256 return 0;
00257 if(s1.modExclOffset.size()!=s2.modExclOffset.size())
00258 return 0;
00259
00260 for(int i=0; i<s1.fullExclOffset.size(); i++)
00261 {
00262 if(s1.fullExclOffset[i] != s2.fullExclOffset[i])
00263 return 0;
00264 }
00265
00266 for(int i=0; i<s1.modExclOffset.size(); i++)
00267 {
00268 if(s1.modExclOffset[i] != s2.modExclOffset[i])
00269 return 0;
00270 }
00271 return 1;
00272 }
|
|
||||||||||||
|
Definition at line 146 of file CompressPsf.C. References AtomSigInfo::angleSigIndices, AtomSigInfo::bondSigIndices, AtomSigInfo::crosstermSigIndices, AtomSigInfo::dihedralSigIndices, and AtomSigInfo::improperSigIndices. 00147 {
00148 if(s1.bondSigIndices.size() != s2.bondSigIndices.size())
00149 return 0;
00150 if(s1.angleSigIndices.size() != s2.angleSigIndices.size())
00151 return 0;
00152 if(s1.dihedralSigIndices.size() != s2.dihedralSigIndices.size())
00153 return 0;
00154 if(s1.improperSigIndices.size() != s2.improperSigIndices.size())
00155 return 0;
00156 if(s1.crosstermSigIndices.size() != s2.crosstermSigIndices.size())
00157 return 0;
00158
00159 int equalCnt;
00160 equalCnt=0;
00161 int bondSigCnt = s1.bondSigIndices.size();
00162 for(int i=0; i<bondSigCnt; i++)
00163 equalCnt += (s1.bondSigIndices[i]==s2.bondSigIndices[i]);
00164 if(equalCnt!=bondSigCnt)
00165 return 0;
00166
00167 equalCnt=0;
00168 int angleSigCnt = s1.angleSigIndices.size();
00169 for(int i=0; i<angleSigCnt; i++)
00170 equalCnt += (s1.angleSigIndices[i]==s2.angleSigIndices[i]);
00171 if(equalCnt!=angleSigCnt)
00172 return 0;
00173
00174 equalCnt=0;
00175 int dihedralSigCnt = s1.dihedralSigIndices.size();
00176 for(int i=0; i<dihedralSigCnt; i++)
00177 equalCnt += (s1.dihedralSigIndices[i]==s2.dihedralSigIndices[i]);
00178 if(equalCnt!=dihedralSigCnt)
00179 return 0;
00180
00181 equalCnt=0;
00182 int improperSigCnt = s1.improperSigIndices.size();
00183 for(int i=0; i<improperSigCnt; i++)
00184 equalCnt += (s1.improperSigIndices[i]==s2.improperSigIndices[i]);
00185 if(equalCnt!=improperSigCnt)
00186 return 0;
00187
00188 equalCnt=0;
00189 int crosstermSigCnt = s1.crosstermSigIndices.size();
00190 for(int i=0; i<crosstermSigCnt; i++)
00191 equalCnt += (s1.crosstermSigIndices[i]==s2.crosstermSigIndices[i]);
00192 if(equalCnt!=crosstermSigCnt)
00193 return 0;
00194
00195 return 1;
00196 }
|
|
||||||||||||
|
Output the compressed psf files. The binary per-atom file contains two part. The first part is used for the parallel input containing info such as atom signature ids; the second part is used for the parallel output containing infor such as cluster ids and whether an atom is water or not. -Chao Mei Definition at line 541 of file CompressPsf.C. References AtomSigInfo::angleSigIndices, Atom, atomData, BasicAtomInfo::atomNameIdx, OutputAtomRecord::shortVals::atomNameIdx, atomNamePool, BasicAtomInfo::atomSigIdx, OutputAtomRecord::integerVals::atomSigIdx, atomSigPool, HydrogenGroupID::atomsInGroup, OutputAtomRecord::integerVals::atomsInGroup, HydrogenGroupID::atomsInMigrationGroup, OutputAtomRecord::integerVals::atomsInMigrationGroup, BasicAtomInfo::atomTypeIdx, OutputAtomRecord::shortVals::atomTypeIdx, atomTypePool, ResizeArray< Elem >::begin(), AtomSigInfo::bondSigIndices, BasicAtomInfo::chargeIdx, OutputAtomRecord::shortVals::chargeIdx, chargePool, COMPRESSED_PSF_VER, AtomSigInfo::crosstermSigIndices, Parameters::dihedral_array, AtomSigInfo::dihedralSigIndices, eachAtomClusterID, BasicAtomInfo::exclSigIdx, OutputAtomRecord::integerVals::exclSigIdx, OutputAtomRecord::fSet, ExclSigInfo::fullExclOffset, g_mol, g_numClusters, g_param, g_simParam, Molecule::getAtoms(), Molecule::getBFactorData(), Molecule::getOccupancyData(), HydrogenGroupID::GPID, OutputAtomRecord::integerVals::GPID, Molecule::hydrogenGroup, OutputAtomRecord::integerVals::hydrogenList, atom_constants::hydrogenList, Parameters::improper_array, AtomSigInfo::improperSigIndices, Molecule::is_water(), OutputAtomRecord::iSet, j, BasicAtomInfo::massIdx, OutputAtomRecord::shortVals::massIdx, massPool, Molecule::maxHydrogenGroupSize, Molecule::maxMigrationGroupSize, ExclSigInfo::modExclOffset, HydrogenGroupID::MPID, OutputAtomRecord::integerVals::MPID, ImproperValue::multiplicity, DihedralValue::multiplicity, Molecule::numAtoms, Parameters::NumDihedralParams, Molecule::numHydrogenGroups, Parameters::NumImproperParams, Molecule::numMigrationGroups, TupleSignature::output(), Real, BasicAtomInfo::resID, OutputAtomRecord::integerVals::resID, ResizeArray< Elem >::resize(), BasicAtomInfo::resNameIdx, OutputAtomRecord::shortVals::resNameIdx, resNamePool, Molecule::rigid_bond_length(), OutputAtomRecord::floatVals::rigidBondLength, SimParameters::rigidBonds, BasicAtomInfo::segNameIdx, OutputAtomRecord::shortVals::segNameIdx, segNamePool, SigIndex, sigsOfAngles, sigsOfBonds, sigsOfCrossterms, sigsOfDihedrals, sigsOfExclusions, sigsOfImpropers, HashPool< T >::size(), OutputAtomRecord::sSet, atom_constants::vdw_type, and OutputAtomRecord::shortVals::vdw_type. Referenced by compress_molecule_info(). 00542 {
00543 #ifndef MEM_OPT_VERSION
00544 fprintf(txtOfp, "FORMAT VERSION: %f\n", COMPRESSED_PSF_VER);
00545
00546 fprintf(txtOfp, "%d !NSEGMENTNAMES\n", segNamePool.size());
00547 for(int i=0; i<segNamePool.size(); i++)
00548 {
00549 fprintf(txtOfp, "%s\n", segNamePool[i].c_str());
00550 }
00551
00552 fprintf(txtOfp, "%d !NRESIDUENAMES\n", resNamePool.size());
00553 for(int i=0; i<resNamePool.size(); i++)
00554 {
00555 fprintf(txtOfp, "%s\n", resNamePool[i].c_str());
00556 }
00557
00558 fprintf(txtOfp, "%d !NATOMNAMES\n", atomNamePool.size());
00559 for(int i=0; i<atomNamePool.size(); i++)
00560 {
00561 fprintf(txtOfp, "%s\n", atomNamePool[i].c_str());
00562 }
00563
00564 fprintf(txtOfp, "%d !NATOMTYPES\n", atomTypePool.size());
00565 for(int i=0; i<atomTypePool.size(); i++)
00566 {
00567 fprintf(txtOfp, "%s\n", atomTypePool[i].c_str());
00568 }
00569
00570 fprintf(txtOfp, "%d !NCHARGES\n", chargePool.size());
00571 for(int i=0; i<chargePool.size(); i++)
00572 {
00573 const Real charge = chargePool[i];
00574 fprintf(txtOfp, "%f\n", charge);
00575 }
00576
00577 fprintf(txtOfp, "%d !NMASSES\n", massPool.size());
00578 for(int i=0; i<massPool.size(); i++)
00579 {
00580 const Real mass = massPool[i];
00581 fprintf(txtOfp, "%f\n", mass);
00582 }
00583
00584
00585 fprintf(txtOfp, "%d !NATOMSIGS\n", atomSigPool.size());
00586 for(int i=0; i<atomSigPool.size(); i++)
00587 {
00588 AtomSigInfo& oneAtomSig = atomSigPool[i];
00589 int oneTypeCnt = oneAtomSig.bondSigIndices.size();
00590 fprintf(txtOfp, "%d !%sSIGS\n", oneTypeCnt, "NBOND");
00591 for(int j=0; j<oneTypeCnt; j++)
00592 {
00593 SigIndex idx = oneAtomSig.bondSigIndices[j];
00594 TupleSignature& tSig = sigsOfBonds[idx];
00595 tSig.output(txtOfp);
00596 }
00597
00598 oneTypeCnt = oneAtomSig.angleSigIndices.size();
00599 fprintf(txtOfp, "%d !%sSIGS\n", oneTypeCnt, "NTHETA");
00600 for(int j=0; j<oneTypeCnt; j++)
00601 {
00602 SigIndex idx = oneAtomSig.angleSigIndices[j];
00603 TupleSignature& tSig = sigsOfAngles[idx];
00604 tSig.output(txtOfp);
00605 }
00606
00607 oneTypeCnt = oneAtomSig.dihedralSigIndices.size();
00608 fprintf(txtOfp, "%d !%sSIGS\n", oneTypeCnt, "NPHI");
00609 for(int j=0; j<oneTypeCnt; j++)
00610 {
00611 SigIndex idx = oneAtomSig.dihedralSigIndices[j];
00612 TupleSignature& tSig = sigsOfDihedrals[idx];
00613 tSig.output(txtOfp);
00614 }
00615
00616 oneTypeCnt = oneAtomSig.improperSigIndices.size();
00617 fprintf(txtOfp, "%d !%sSIGS\n", oneTypeCnt, "NIMPHI");
00618 for(int j=0; j<oneTypeCnt; j++)
00619 {
00620 SigIndex idx = oneAtomSig.improperSigIndices[j];
00621 TupleSignature& tSig = sigsOfImpropers[idx];
00622 tSig.output(txtOfp);
00623 }
00624
00625 oneTypeCnt = oneAtomSig.crosstermSigIndices.size();
00626 fprintf(txtOfp, "%d !%sSIGS\n", oneTypeCnt, "NCRTERM");
00627 for(int j=0; j<oneTypeCnt; j++)
00628 {
00629 SigIndex idx = oneAtomSig.crosstermSigIndices[j];
00630 TupleSignature& tSig = sigsOfCrossterms[idx];
00631 tSig.output(txtOfp);
00632 }
00633 }
00634
00635 //2. Output exclusion signatures
00636 int exclSigCnt = sigsOfExclusions.size();
00637 fprintf(txtOfp, "%d !NEXCLSIGS\n", exclSigCnt);
00638 for(int i=0; i<exclSigCnt; i++)
00639 {
00640 ExclSigInfo *sig = &sigsOfExclusions[i];
00641 //first line is for full exclusions (1-2, 1-3) in the format of count offset1 offset2 offset3 ...
00642 fprintf(txtOfp, "%d", sig->fullExclOffset.size());
00643 for(int j=0; j<sig->fullExclOffset.size(); j++)
00644 fprintf(txtOfp, " %d", sig->fullExclOffset[j]);
00645 fprintf(txtOfp, "\n");
00646
00647 //second line is for modified exclusions (1-4)
00648 fprintf(txtOfp, "%d", sig->modExclOffset.size());
00649 for(int j=0; j<sig->modExclOffset.size(); j++)
00650 fprintf(txtOfp, " %d", sig->modExclOffset[j]);
00651 fprintf(txtOfp, "\n");
00652 }
00653
00654 //3. Output the cluster information
00655 fprintf(txtOfp, "%d !NCLUSTERS\n", g_numClusters);
00656
00657 //4. Output atom info
00658 fprintf(txtOfp, "%d !NATOM\n", g_mol->numAtoms);
00659 fprintf(txtOfp, "%d !NHYDROGENGROUP\n", g_mol->numHydrogenGroups);
00660 fprintf(txtOfp, "%d !MAXHYDROGENGROUPSIZE\n", g_mol->maxHydrogenGroupSize);
00661 fprintf(txtOfp, "%d !NMIGRATIONGROUP\n", g_mol->numMigrationGroups);
00662 fprintf(txtOfp, "%d !MAXMIGRATIONGROUPSIZE\n", g_mol->maxMigrationGroupSize);
00663
00664 //5. Output rigid bond type
00665 fprintf(txtOfp, "%d !RIGIDBONDTYPE\n", g_simParam->rigidBonds);
00666 #if 0
00667 const float *atomOccupancy = g_mol->getOccupancyData();
00668 const float *atomBFactor = g_mol->getBFactorData();
00669 fprintf(txtOfp, "%d !OCCUPANCYVALID\n", (atomOccupancy==NULL)?0:1);
00670 fprintf(txtOfp, "%d !TEMPFACTORVALID\n", (atomBFactor==NULL)?0:1);
00671
00672 float *zeroFloats = NULL;
00673 if(atomOccupancy==NULL || atomBFactor==NULL) {
00674 zeroFloats = new float[g_mol->numAtoms];
00675 memset(zeroFloats, 0, sizeof(float)*g_mol->numAtoms);
00676 if(atomOccupancy==NULL) atomOccupancy = (const float *)zeroFloats;
00677 if(atomBFactor==NULL) atomBFactor = (const float *)zeroFloats;
00678 }
00679 #endif
00680
00681 Atom *atoms = g_mol->getAtoms(); //need to output its partner and hydrogenList
00682 HydrogenGroupID *hg = g_mol->hydrogenGroup.begin();
00683
00684 //First, output magic number
00685 int magicNum = COMPRESSED_PSF_MAGICNUM;
00686 fwrite(&magicNum, sizeof(int), 1, binOfp);
00687 //Second, version number
00688 float verNum = (float)COMPRESSED_PSF_VER;
00689 fwrite(&verNum, sizeof(float), 1, binOfp);
00690 //Third, the per-atom record size
00691 int recSize = sizeof(OutputAtomRecord);
00692 fwrite(&recSize, sizeof(int), 1, binOfp);
00693 //Fourth, each atom info
00694 OutputAtomRecord oneRec;
00695 for(int i=0; i<g_mol->numAtoms; i++)
00696 {
00697 oneRec.sSet.segNameIdx = atomData[i].segNameIdx;
00698 oneRec.sSet.resNameIdx = atomData[i].resNameIdx;
00699 oneRec.sSet.atomNameIdx = atomData[i].atomNameIdx;
00700 oneRec.sSet.atomTypeIdx = atomData[i].atomTypeIdx;
00701 oneRec.sSet.chargeIdx = atomData[i].chargeIdx;
00702 oneRec.sSet.massIdx = atomData[i].massIdx;
00703 oneRec.iSet.atomSigIdx = atomData[i].atomSigIdx;
00704
00705 oneRec.iSet.exclSigIdx = atomData[i].exclSigIdx;
00706 oneRec.sSet.vdw_type = atoms[i].vdw_type;
00707 oneRec.iSet.resID = atomData[i].resID;
00708 int hydIdx = atoms[i].hydrogenList;
00709 oneRec.iSet.hydrogenList = hydIdx;
00710 oneRec.iSet.atomsInGroup = hg[hydIdx].atomsInGroup;
00711 oneRec.iSet.GPID = hg[hydIdx].GPID;
00712 //oneRec.waterVal = hg[hydIdx].waterVal;
00713 oneRec.iSet.atomsInMigrationGroup = hg[hydIdx].atomsInMigrationGroup;
00714 oneRec.iSet.MPID = hg[hydIdx].MPID;
00715 //oneRec.fSet.occupancy = atomOccupancy[i];
00716 //oneRec.fSet.bfactor = atomBFactor[i];
00717 oneRec.fSet.rigidBondLength = g_mol->rigid_bond_length(i);
00718 fwrite(&oneRec, sizeof(OutputAtomRecord), 1, binOfp);
00719 }
00720 //if(zeroFloats) delete[] zeroFloats;
00721 delete[] atomData;
00722
00723 //Output the info required for parallel output:
00724 //1. Cluster ids of each atom
00725 //Since the cluster info is only when doing output under
00726 //wrapAll or wrapWater conditions, for the purpose of parallel
00727 //output, it is reasonable to separate the cluster info from
00728 //the above per-atom info. So whole the binary per-atom file
00729 //contains two parts, one for parallel input to create patches
00730 //and computes; the other for parallel output -Chao Mei
00731 //Fifth: output the cluster id of each atoms
00732 fwrite(eachAtomClusterID, sizeof(int), g_mol->numAtoms, binOfp);
00733 //2. Whether each atom is water or not
00734 char *isWater = new char[g_mol->numAtoms];
00735 for(int i=0; i<g_mol->numAtoms; i++){
00736 isWater[i] = g_mol->is_water(i);
00737 }
00738 fwrite(isWater, sizeof(char), g_mol->numAtoms, binOfp);
00739 delete [] isWater;
00740 delete[] atoms;
00741 g_mol->hydrogenGroup.resize(0);
00742 delete[] eachAtomClusterID;
00743
00744 //Output the parameter new values if extraBonds are present.
00745 //The parameters are not needed since now extraBonds' parameters will be
00746 //read again during running the simulation
00747
00748 //6. Output the "multiplicity" field TUPLE_array of the Parameter object
00749 fprintf(txtOfp, "!DIHEDRALPARAMARRAY\n");
00750 for(int i=0; i<g_param->NumDihedralParams; i++)
00751 {
00752 fprintf(txtOfp, "%d ", g_param->dihedral_array[i].multiplicity);
00753 }
00754 fprintf(txtOfp, "\n");
00755 fprintf(txtOfp, "!IMPROPERPARAMARRAY\n");
00756 for(int i=0; i<g_param->NumImproperParams; i++)
00757 {
00758 fprintf(txtOfp, "%d ", g_param->improper_array[i].multiplicity);
00759 }
00760 fprintf(txtOfp, "\n");
00761 #endif
00762 }
|
|
|
Definition at line 314 of file CompressPsf.C. Referenced by buildAtomData(), buildExclusions(), integrateAllAtomSigs(), and outputCompressedFile(). |
|
|
Definition at line 309 of file CompressPsf.C. Referenced by buildAtomData(), clearGlobalVectors(), Molecule::get_atom_from_name(), outputCompressedFile(), Molecule::receive_Molecule(), and Molecule::send_Molecule(). |
|
|
Definition at line 313 of file CompressPsf.C. Referenced by buildExclusions(), integrateAllAtomSigs(), outputCompressedFile(), Molecule::receive_Molecule(), Molecule::send_Molecule(), and ParallelIOMgr::updateMolInfo(). |
|
|
Definition at line 310 of file CompressPsf.C. Referenced by buildAtomData(), clearGlobalVectors(), Molecule::get_atomtype(), and outputCompressedFile(). |
|
|
Definition at line 311 of file CompressPsf.C. Referenced by buildAtomData(), clearGlobalVectors(), and outputCompressedFile(). |
|
|
Definition at line 317 of file CompressPsf.C. Referenced by buildBondData(), and outputCompressedFile(). |
|
|
Definition at line 330 of file CompressPsf.C. Referenced by buildExclusions(). |
|
|
Definition at line 327 of file CompressPsf.C. Referenced by buildAngleData(), buildBondData(), buildCrosstermData(), buildDihedralData(), buildImproperData(), integrateAllAtomSigs(), and loadMolInfo(). |
|
|
Definition at line 319 of file CompressPsf.C. Referenced by buildBondData(). |
|
|
Definition at line 318 of file CompressPsf.C. Referenced by buildBondData(), and clearGlobalVectors(). |
|
|
Definition at line 339 of file CompressPsf.C. |
|
|
Definition at line 334 of file CompressPsf.C. |
|
|
Definition at line 338 of file CompressPsf.C. |
|
|
Definition at line 333 of file CompressPsf.C. |
|
|
Definition at line 340 of file CompressPsf.C. |
|
|
Definition at line 335 of file CompressPsf.C. |
|
|
Definition at line 341 of file CompressPsf.C. |
|
|
Definition at line 336 of file CompressPsf.C. |
|
|
Definition at line 35 of file CompressPsf.C. Referenced by compress_molecule_info(). |
|
|
Very tricky part: Generating the tuple type affects the Parameter object. Particularly, the "multiplicity" field in the TUPLE_array will be changed in the function assign_TUPLE_index. TUPLE=dihedral, improper. And when we read the compressed psf files, assign_TUPLE_index functions will not be called so that the value of "multiplicity" will not be updated. This results in the incorrect energy from bonded interaction. Therefore, we need to store its value in the compressed psf file. When it comes to read them, we need to update the Parameter object with these values. Definition at line 32 of file CompressPsf.C. Referenced by build12Excls(), build13Excls(), build14Excls(), buildAngleData(), buildAtomData(), buildBondData(), buildCrosstermData(), buildDihedralData(), buildExclusions(), buildImproperData(), compress_molecule_info(), integrateAllAtomSigs(), loadMolInfo(), and outputCompressedFile(). |
|
|
Definition at line 320 of file CompressPsf.C. Referenced by buildBondData(), and outputCompressedFile(). |
|
|
Definition at line 33 of file CompressPsf.C. Referenced by compress_molecule_info(), and outputCompressedFile(). |
|
|
Definition at line 34 of file CompressPsf.C. Referenced by buildExclusions(), compress_molecule_info(), and outputCompressedFile(). |
|
|
Definition at line 312 of file CompressPsf.C. Referenced by buildAtomData(), clearGlobalVectors(), and outputCompressedFile(). |
|
|
Definition at line 308 of file CompressPsf.C. Referenced by buildAtomData(), clearGlobalVectors(), and outputCompressedFile(). |
|
|
Definition at line 307 of file CompressPsf.C. Referenced by buildAtomData(), clearGlobalVectors(), and outputCompressedFile(). |
|
|
Definition at line 323 of file CompressPsf.C. Referenced by buildAngleData(), clearGlobalVectors(), integrateAllAtomSigs(), and outputCompressedFile(). |
|
|
Definition at line 322 of file CompressPsf.C. Referenced by buildBondData(), buildExclusions(), clearGlobalVectors(), integrateAllAtomSigs(), and outputCompressedFile(). |
|
|
Definition at line 326 of file CompressPsf.C. Referenced by buildCrosstermData(), integrateAllAtomSigs(), and outputCompressedFile(). |
|
|
Definition at line 324 of file CompressPsf.C. Referenced by buildDihedralData(), clearGlobalVectors(), integrateAllAtomSigs(), and outputCompressedFile(). |
|
|
Definition at line 329 of file CompressPsf.C. Referenced by buildExclusions(), clearGlobalVectors(), and outputCompressedFile(). |
|
|
Definition at line 325 of file CompressPsf.C. Referenced by buildImproperData(), clearGlobalVectors(), integrateAllAtomSigs(), and outputCompressedFile(). |
1.3.9.1