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

Molecule.h

Go to the documentation of this file.
00001 
00007 /*
00008    This class is used to store all of the structural       
00009    information for a simulation.  It reas in this information 
00010    from a .psf file, cross checks and obtains some information
00011    from the Parameters object that is passed in, and then     
00012    stores all this information for later use. 
00013 */
00014 
00015 
00016 #ifndef MOLECULE_H
00017 
00018 #define MOLECULE_H
00019 
00020 #include "parm.h"
00021 
00022 #include "common.h"
00023 #include "NamdTypes.h"
00024 #include "structures.h"
00025 #include "ConfigList.h"
00026 #include "Vector.h"
00027 #include "UniqueSet.h"
00028 #include "Hydrogen.h"
00029 #include "GromacsTopFile.h"
00030 /* BEGIN gf */
00031 #include "GridForceGrid.h"
00032 #include "Tensor.h"
00033 /* END gf */
00034 
00035 #include <vector>
00036 using namespace std;
00037 
00038 class SimParameters;
00039 class Parameters;
00040 class ConfigList;
00041 class PDB;
00042 class MIStream;
00043 class MOStream;
00044 
00045 class BondElem;
00046 class AngleElem;
00047 class DihedralElem;
00048 class ImproperElem;
00049 class CrosstermElem;
00050 class ResidueLookupElem;
00051 template<class Type> class ObjectArena;
00052 
00053 class ExclusionCheck {
00054 public:
00055   int32 min,max;
00056   char *flags;
00057 
00058   ExclusionCheck(){
00059       min=0;
00060       max=-1;
00061       flags = NULL;
00062   }
00063   ExclusionCheck(const ExclusionCheck& chk){
00064       min = chk.min;
00065       max = chk.max;
00066       if(max>min){ 
00067         flags = new char[max-min+1];
00068         memcpy(flags, chk.flags, sizeof(char)*(max-min+1));
00069       }
00070   }
00071   ExclusionCheck &operator=(const ExclusionCheck& chk){
00072     min = chk.min;
00073     max = chk.max;
00074     if(flags) delete [] flags;
00075     flags = NULL;
00076     if(max>min){
00077         flags = new char[max-min+1];
00078         memcpy(flags, chk.flags, sizeof(char)*(max-min+1));
00079     }
00080     return *this;
00081   }
00082   ~ExclusionCheck(){
00083       if(flags) delete [] flags;
00084   }
00085 };
00086 #define EXCHCK_FULL 1
00087 #define EXCHCK_MOD 2
00088 
00089 // List maintaining the global atom indicies sorted by helix groups.
00090 class Molecule
00091 {
00092 typedef struct constraint_params
00093 {
00094    Real k;    //  Force constant
00095    Vector refPos; //  Reference position for restraint
00096 } ConstraintParams;
00097 
00098 
00099 
00100 /* BEGIN gf */
00101 typedef struct gridfrc_params
00102 {
00103     Real k;     // force multiplier
00104     Charge q;   // charge
00105 } GridforceParams;
00106 /* END gf */
00107 
00108 
00109 typedef struct stir_params
00110 {
00111   Real startTheta;
00112   Vector refPos;  //  Reference position for stirring
00113 } StirParams;
00114 
00115 typedef struct movdrag_params
00116 {
00117   Vector v;            //  Linear velocity (A/step)
00118 } MovDragParams;
00119 
00120 
00121 typedef struct rotdrag_params
00122 {
00123    Real v;              //  Angular velocity (deg/step)
00124    Vector a;            //  Rotation axis
00125    Vector p;            //  Rotation pivot point
00126 } RotDragParams;
00127 
00128 typedef struct constorque_params
00129 {
00130    Real v;              //  "Torque" value (Kcal/(mol*A^2))
00131    Vector a;            //  Rotation axis
00132    Vector p;            //  Rotation pivot point
00133 } ConsTorqueParams;
00134 
00135 friend class BondElem;
00136 friend class AngleElem;
00137 friend class DihedralElem;
00138 friend class ImproperElem;
00139 friend class CrosstermElem;
00140 
00141 private:
00142   void initialize(SimParameters *, Parameters *param);
00143             // Sets most data to zero
00144 
00145   #ifdef MEM_OPT_VERSION 
00146   //Indexing to constant pools to save space
00147   AtomCstInfo *atoms;
00148   Index *eachAtomMass; //after initialization, this could be freed (possibly)
00149   Index *eachAtomCharge; //after initialization, this could be freed (possibly)
00150   AtomNameIdx *atomNames;
00151   ObjectArena<char> *nameArena; //the space for names to be allocated  
00152   #else
00153   Atom *atoms;    //  Array of atom structures
00154   ObjectArena<char> *nameArena;
00155   AtomNameInfo *atomNames;//  Array of atom name info.  Only maintained on node 0 for VMD interface
00156   #endif
00157 
00158   ResidueLookupElem *resLookup; // find residues by name
00159 
00160   #ifndef MEM_OPT_VERSION
00161   //replaced by atom signatures
00162   Bond *bonds;    //  Array of bond structures
00163   Angle *angles;    //  Array of angle structures
00164   Dihedral *dihedrals;  //  Array of dihedral structures
00165   Improper *impropers;  //  Array of improper structures                          
00166   Crossterm *crossterms;  //  Array of cross-term structures
00167   #endif
00168   
00169   Bond *donors;         //  Array of hydrogen bond donor structures
00170   Bond *acceptors;  //  Array of hydrogen bond acceptor
00171 
00172   #ifndef MEM_OPT_VERSION
00173   //These will be replaced by exclusion signatures
00174   Exclusion *exclusions;  //  Array of exclusion structures
00175   UniqueSet<Exclusion> exclusionSet;  //  Used for building
00176   #endif
00177 
00178   int32 *consIndexes; //  Constraint indexes for each atom
00179   ConstraintParams *consParams;
00180 
00181 /* BEGIN gf */
00182   int32 *gridfrcIndexes;
00183   GridforceParams *gridfrcParams;
00184   GridforceGrid *gridfrcGrid;
00185 /* END gf */
00186 
00187         //  Parameters for each atom constrained
00188   int32 *stirIndexes; //Stirring indexes for each atoms
00189   StirParams *stirParams;
00190                           // Paramters for each atoms stirred
00191   int32 *movDragIndexes;  //  Moving drag indexes for each atom
00192   MovDragParams *movDragParams;
00193                                 //  Parameters for each atom moving-dragged
00194   int32 *rotDragIndexes;  //  Rotating drag indexes for each atom
00195   RotDragParams *rotDragParams;
00196                                 //  Parameters for each atom rotation-dragged
00197 
00198   Real *langevinParams;   //  b values for langevin dynamics
00199   int32 *fixedAtomFlags;  //  1 for fixed, -1 for fixed group, else 0
00200   int32 *exPressureAtomFlags; // 1 for excluded, -1 for excluded group.
00201 
00202   #ifdef MEM_OPT_VERSION  
00203   //Assumption: all atoms are arranged in the order of clusters. In other words,
00204   //all atoms for a cluster must appear before/after any atoms in other clusters
00205   //The first atom in the cluster (which has the lowest atom id) stores the cluster size
00206   //other atoms in the cluster stores -1
00207   int32 *clusterSigs;
00208   #else
00209         int32 *cluster;   //  first atom of connected cluster
00210         int32 *clusterSize; //  size of connected cluster or 0
00211   #endif
00212                             // 
00213         Real *rigidBondLengths;  //  if H, length to parent or 0. or
00214         //  if not H, length between children or 0.
00215 //fepb
00216         unsigned char *fepAtomFlags; 
00217 //fepe
00218 
00219 #ifndef MEM_OPT_VERSION
00220   ObjectArena<int32> *tmpArena;
00221   int32 **bondsWithAtom;  //  List of bonds involving each atom
00222   ObjectArena<int32> *arena;
00223 #endif
00224 
00225 #ifdef MEM_OPT_VERSION
00226   Index *eachAtomSig;
00227   Index *eachAtomExclSig;
00228 #else
00229 //function is replaced by atom signatures
00230   int32 **bondsByAtom;  //  List of bonds owned by each atom
00231   int32 **anglesByAtom;     //  List of angles owned by each atom
00232   int32 **dihedralsByAtom;  //  List of dihedrals owned by each atom
00233   int32 **impropersByAtom;  //  List of impropers owned by each atom
00234   int32 **crosstermsByAtom;  //  List of crossterms owned by each atom
00235     
00236   int32 **exclusionsByAtom; //  List of exclusions owned by each atom
00237   int32 **fullExclusionsByAtom; //  List of atoms excluded for each atom
00238   int32 **modExclusionsByAtom; //  List of atoms modified for each atom
00239   ObjectArena<char> *exclArena;
00240   ExclusionCheck *all_exclusions;
00241 #endif
00242         //  List of all exclusions, including
00243         //  explicit exclusions and those calculated
00244         //  from the bonded structure based on the
00245         //  exclusion policy.  Also includes 1-4's.
00246 
00247   void build_lists_by_atom();
00248         //  Build the list of structures by atom
00249   
00250 
00251   void read_atoms(FILE *, Parameters *);
00252         //  Read in atom info from .psf
00253   void read_bonds(FILE *, Parameters *);
00254         //  Read in bond info from .psf
00255   void read_angles(FILE *, Parameters *);
00256         //  Read in angle info from .psf
00257   void read_dihedrals(FILE *, Parameters *);
00258         //  Read in dihedral info from .psf
00259   void read_impropers(FILE *, Parameters *);
00260         //  Read in improper info from .psf
00261   void read_crossterms(FILE *, Parameters *);
00262         //  Read in cross-term info from .psf
00263   void read_donors(FILE *);
00264         //  Read in hydrogen bond donors from .psf
00265   void read_acceptors(FILE *);
00266         //  Read in hydrogen bond acceptors from .psf
00267   void read_exclusions(FILE *);
00268         //  Read in exclusion info from .psf
00269 
00270   void build12excl(void);
00271   void build13excl(void);
00272   void build14excl(int);
00273   void stripHGroupExcl(void);
00274   #ifdef MEM_OPT_VERSION
00275   void stripFepFixedExcl(void);
00276   #else
00277   void stripFepExcl(void);
00278   #endif
00279 
00280   void build_exclusions();
00281 
00282   // analyze the atoms, and determine which are oxygen, hb donors, etc.
00283   // this is called after a molecule is sent our (or received in)
00284   void build_atom_status(void);
00285 
00286   // added during the trasition from 1x to 2
00287   SimParameters *simParams;
00288   Parameters *params;
00289 
00290   void read_parm(const GromacsTopFile *);  
00291 
00292 public:
00293   // data for TIP4P
00294   Real r_om;
00295   Real r_ohc;
00296 
00297 
00298 
00299 #ifndef MEM_OPT_VERSION
00300   Atom *getAtoms () const { return atoms; }
00301 #endif
00302 
00303   // return number of fixed atoms, guarded by SimParameters
00304   int num_fixed_atoms() const {
00305     // local variables prefixed by s_
00306     int s_NumFixedAtoms = (simParams->fixedAtomsOn ? numFixedAtoms : 0);
00307     return s_NumFixedAtoms;  // value is "turned on" SimParameters
00308   }
00309 
00310   int num_fixed_groups() const {
00311     // local variables prefixed by s_
00312     int s_NumFixedAtoms = num_fixed_atoms();
00313     int s_NumFixedGroups = (s_NumFixedAtoms ? numFixedGroups : 0);
00314     return s_NumFixedGroups;  // value is "turned on" SimParameters
00315   }
00316 
00317   int num_group_deg_freedom() const {
00318     // local variables prefixed by s_
00319     int s_NumGroupDegFreedom = 3 * numHydrogenGroups;
00320     int s_NumFixedAtoms = num_fixed_atoms();
00321     int s_NumFixedGroups = num_fixed_groups();
00322     if (s_NumFixedGroups) s_NumGroupDegFreedom -= 3 * s_NumFixedGroups;
00323     if ( ! (s_NumFixedAtoms || numConstraints
00324           || simParams->comMove || simParams->langevinOn) ) {
00325       s_NumGroupDegFreedom -= 3;
00326     }
00327     return s_NumGroupDegFreedom;
00328   }
00329 
00330   int num_deg_freedom(int isInitialReport = 0) const {
00331     // local variables prefixed by s_
00332     int s_NumDegFreedom = 3 * numAtoms;
00333     int s_NumFixedAtoms = num_fixed_atoms();
00334     if (s_NumFixedAtoms) s_NumDegFreedom -= 3 * s_NumFixedAtoms;
00335     if (numLonepairs) s_NumDegFreedom -= 3 * numLonepairs;
00336     if ( ! (s_NumFixedAtoms || numConstraints
00337           || simParams->comMove || simParams->langevinOn) ) {
00338       s_NumDegFreedom -= 3;
00339     }
00340     if ( ! isInitialReport && simParams->pairInteractionOn) {
00341       //
00342       // DJH: a kludge?  We want to initially report system degrees of freedom
00343       //
00344       // this doesn't attempt to deal with fixed atoms or constraints
00345       s_NumDegFreedom = 3 * numFepInitial;
00346     }
00347     int s_NumFixedRigidBonds = 
00348       (simParams->fixedAtomsOn ? numFixedRigidBonds : 0);
00349     // numLonepairs is subtracted here because all lonepairs have a rigid bond
00350     // to oxygen, but all of the LP degrees of freedom are dealt with above
00351     s_NumDegFreedom -= (numRigidBonds - s_NumFixedRigidBonds - numLonepairs);
00352     return s_NumDegFreedom;
00353   }
00354 
00355   int numAtoms;   //  Number of atoms                   
00356 
00357   int numRealBonds;   //  Number of bonds for exclusion determination
00358   int numBonds;   //  Number of bonds calculated, including extras
00359   int numAngles;    //  Number of angles
00360   int numDihedrals; //  Number of dihedrals
00361   int numImpropers; //  Number of impropers
00362   int numCrossterms; //  Number of cross-terms
00363   int numDonors;          //  Number of hydrogen bond donors
00364   int numAcceptors; //  Number of hydrogen bond acceptors
00365   int numExclusions;  //  Number of exclusions
00366   int numTotalExclusions; //  Real Total Number of Exclusions // hack
00367   int numLonepairs; // Number of lone pairs
00368   int numDrudeAtoms;  // Number of Drude particles
00369   
00370   int numConstraints; //  Number of atoms constrained
00371 /* BEGIN gf */
00372   int numGridforces;  //  Number of atoms in gridforce file
00373 /* END gf */
00374   int numMovDrag;         //  Number of atoms moving-dragged
00375   int numRotDrag;         //  Number of atoms rotating-dragged
00376   int numConsTorque;  //  Number of atoms "constant"-torqued
00377   int numFixedAtoms;  //  Number of fixed atoms
00378   int numStirredAtoms;  //  Number of stirred atoms
00379   int numExPressureAtoms; //  Number of atoms excluded from pressure
00380   int numHydrogenGroups;  //  Number of hydrogen groups
00381   int numFixedGroups; //  Number of totally fixed hydrogen groups
00382   int numRigidBonds;  //  Number of rigid bonds
00383   int numFixedRigidBonds; //  Number of rigid bonds between fixed atoms
00384 //fepb
00385         int numFepInitial;  // no. of fep atoms with initial flag
00386         int numFepFinal;  // no. of fep atoms with final flag
00387 //fepe
00388 
00389   int numConsForce; //  Number of atoms that have constant force applied
00390   int32 *consForceIndexes;//  Constant force indexes for each atom
00391   Vector *consForce;  //  Constant force array
00392 
00393   int32 *consTorqueIndexes; //  "Constant" torque indexes for each atom
00394   ConsTorqueParams *consTorqueParams;
00395                                 //  Parameters for each atom "constant"-torqued
00396 
00397   // The following are needed for error checking because we
00398   // eliminate bonds, etc. which involve only fixed atoms
00399   int numCalcBonds; //  Number of bonds requiring calculation
00400   int numCalcAngles;  //  Number of angles requiring calculation
00401   int numCalcDihedrals; //  Number of dihedrals requiring calculation
00402   int numCalcImpropers; //  Number of impropers requiring calculation
00403   int numCalcCrossterms; //  Number of cross-terms requiring calculation
00404   int numCalcExclusions;  //  Number of exclusions requiring calculation
00405 
00406   //  Number of dihedrals with multiple periodicity
00407   int numMultipleDihedrals; 
00408   //  Number of impropers with multiple periodicity
00409   int numMultipleImpropers; 
00410   // indexes of "atoms" sorted by hydrogen groups
00411   HydrogenGroup hydrogenGroup;
00412   int waterIndex;
00413 
00414   Molecule(SimParameters *, Parameters *param);
00415   Molecule(SimParameters *, Parameters *param, char *filename, ConfigList *cfgList=NULL);  
00416   
00417   Molecule(SimParameters *, Parameters *, Ambertoppar *);
00418   void read_parm(Ambertoppar *);
00419 
00420   Molecule(SimParameters *, Parameters *, const GromacsTopFile *);
00421 
00422   ~Molecule();    //  Destructor
00423 
00424   void read_psf_file(char *, Parameters *);
00425         //  Read in a .psf file given
00426         //  the filename and the parameter
00427         //  object to use  
00428 
00429   void send_Molecule(Communicate *);
00430         //  send the molecular structure 
00431         //  from the master to the clients
00432   void receive_Molecule(MIStream *);
00433         //  receive the molecular structure
00434         //  from the master on a client
00435   
00436   void build_constraint_params(StringList *, StringList *, StringList *,
00437              PDB *, char *);
00438         //  Build the set of harmonic constraint 
00439         // parameters
00440 
00441 /* BEGIN gf */
00442   void build_gridforce_params(StringList *, StringList *, StringList *, StringList *, PDB *, char *);
00443         //  Build the set of gridForce-style force pars
00444 /* END gf */
00445 
00446   void build_movdrag_params(StringList *, StringList *, StringList *, 
00447           PDB *, char *);
00448         //  Build the set of moving drag pars
00449 
00450   void build_rotdrag_params(StringList *, StringList *, StringList *,
00451           StringList *, StringList *, StringList *,
00452           PDB *, char *);
00453         //  Build the set of rotating drag pars
00454 
00455   void build_constorque_params(StringList *, StringList *, StringList *,
00456              StringList *, StringList *, StringList *,
00457              PDB *, char *);
00458         //  Build the set of "constant" torque pars
00459 
00460 
00461   void build_constant_forces(char *);
00462         //  Build the set of constant forces
00463 
00464   void build_langevin_params(BigReal coupling, Bool doHydrogen);
00465   void build_langevin_params(StringList *, StringList *, PDB *, char *);
00466         //  Build the set of langevin dynamics parameters
00467 
00468   void build_fixed_atoms(StringList *, StringList *, PDB *, char *);
00469         //  Determine which atoms are fixed (if any)
00470 
00471   void build_stirred_atoms(StringList *, StringList *, PDB *, char *);
00472         //  Determine which atoms are stirred (if any)
00473 
00474   void build_extra_bonds(Parameters *parameters, StringList *file);
00475 
00476 //fepb
00477         void build_fep_flags(StringList *, StringList *, PDB *, char *);
00478                                // selection of the mutant atoms
00479 //fepe
00480 
00481   void build_exPressure_atoms(StringList *, StringList *, PDB *, char *);
00482         //  Determine which atoms are excluded from
00483                                 //  pressure (if any)
00484 
00485   void reloadCharges(float charge[], int n);
00486 
00487         Bool is_lp(int);     // return true if atom is a lone pair
00488         Bool is_drude(int);     // return true if atom is a Drude particle
00489         Bool is_hydrogen(int);     // return true if atom is hydrogen
00490         Bool is_oxygen(int);       // return true if atom is oxygen
00491   Bool is_hydrogenGroupParent(int); // return true if atom is group parent
00492   Bool is_water(int);        // return true if atom is part of water 
00493   int  get_groupSize(int);     // return # atoms in (hydrogen) group
00494         int get_mother_atom(int);  // return mother atom of a hydrogen
00495 
00496   #ifdef MEM_OPT_VERSION
00497   int get_cluster_size(int idx) const { return clusterSigs[idx]; }  
00498   #else
00499   int get_cluster(int anum) const { return cluster[anum]; }
00500   int get_clusterSize(int anum) const { return clusterSize[anum]; }
00501   #endif
00502 
00503   #ifdef CHARMIZE_NAMD
00504   Atom *getAllAtoms() {
00505       return atoms;
00506   }
00507   #endif
00508 
00509   //  Get the mass of an atom
00510   Real atommass(int anum) const
00511   {
00512     #ifdef MEM_OPT_VERSION
00513     return atomMassPool[eachAtomMass[anum]];
00514     #else
00515     return(atoms[anum].mass);
00516     #endif
00517   }
00518 
00519   //  Get the charge of an atom
00520   Real atomcharge(int anum) const
00521   {
00522     #ifdef MEM_OPT_VERSION
00523     return atomChargePool[eachAtomCharge[anum]];
00524     #else
00525     return(atoms[anum].charge);
00526     #endif
00527   }
00528   
00529   //  Get the vdw type of an atom
00530   Index atomvdwtype(int anum) const
00531   {      
00532       return(atoms[anum].vdw_type);
00533   }
00534 
00535   #ifndef MEM_OPT_VERSION
00536   //  Retrieve a bond structure
00537   Bond *get_bond(int bnum) const {return (&(bonds[bnum]));}
00538 
00539   //  Retrieve an angle structure
00540   Angle *get_angle(int anum) const {return (&(angles[anum]));}
00541 
00542   //  Retrieve an improper strutcure
00543   Improper *get_improper(int inum) const {return (&(impropers[inum]));}
00544 
00545   //  Retrieve a dihedral structure
00546   Dihedral *get_dihedral(int dnum) const {return (&(dihedrals[dnum]));}
00547 
00548   //  Retrieve a cross-term strutcure
00549   Crossterm *get_crossterm(int inum) const {return (&(crossterms[inum]));}
00550   #endif
00551 
00552   //  Retrieve a hydrogen bond donor structure
00553   Bond *get_donor(int dnum) const {return (&(donors[dnum]));}
00554 
00555   //  Retrieve a hydrogen bond acceptor structure
00556   Bond *get_acceptor(int dnum) const {return (&(acceptors[dnum]));}
00557 
00558   //  Retrieve an exclusion structure
00559   #ifndef MEM_OPT_VERSION
00560   Exclusion *get_exclusion(int ex) const {return (&(exclusions[ex]));}
00561   #endif
00562 
00563   //  Retrieve an atom type
00564   const char *get_atomtype(int anum) const
00565   {
00566     if (atomNames == NULL)
00567     {
00568       NAMD_die("Tried to find atom type on node other than node 0");
00569     }
00570 
00571     #ifdef MEM_OPT_VERSION    
00572     return atomTypePool[atomNames[anum].atomtypeIdx];
00573     #else
00574     return(atomNames[anum].atomtype);
00575     #endif
00576   }
00577 
00578   //  Lookup atom id from segment, residue, and name
00579   int get_atom_from_name(const char *segid, int resid, const char *aname) const;
00580 
00581   //  Lookup number of atoms in residue from segment and residue
00582   int get_residue_size(const char *segid, int resid) const;
00583 
00584   //  Lookup atom id from segment, residue, and index in residue
00585   int get_atom_from_index_in_residue(const char *segid, int resid, int index) const;
00586 
00587   
00588   //  The following routines are used to get the list of bonds
00589   //  for a given atom.  This is used when creating the bond lists
00590   //  for the force objects  
00591 
00592   #ifndef MEM_OPT_VERSION
00593   int32 *get_bonds_for_atom(int anum)
00594       { return bondsByAtom[anum]; } 
00595   int32 *get_angles_for_atom(int anum) 
00596       { return anglesByAtom[anum]; }
00597   int32 *get_dihedrals_for_atom(int anum) 
00598       { return dihedralsByAtom[anum]; }
00599   int32 *get_impropers_for_atom(int anum) 
00600       { return impropersByAtom[anum]; }  
00601   int32 *get_crossterms_for_atom(int anum) 
00602       { return crosstermsByAtom[anum]; }  
00603   int32 *get_exclusions_for_atom(int anum)
00604       { return exclusionsByAtom[anum]; }
00605   const int32 *get_full_exclusions_for_atom(int anum) const
00606       { return fullExclusionsByAtom[anum]; }
00607   const int32 *get_mod_exclusions_for_atom(int anum) const
00608       { return modExclusionsByAtom[anum]; }
00609   #endif
00610   
00611   //  Check for exclusions, either explicit or bonded.
00612         //  Returns 1 for full, 2 for 1-4 exclusions.
00613   #ifdef MEM_OPT_VERSION
00614   int checkExclByIdx(int idx1, int atom1, int atom2) const;
00615   const ExclusionCheck *get_excl_check_for_idx(int idx) const{      
00616       return &exclChkSigPool[idx];
00617   }
00618   #else
00619   int checkexcl(int atom1, int atom2) const;
00620 
00621   const ExclusionCheck *get_excl_check_for_atom(int anum) const{      
00622       return &all_exclusions[anum];             
00623   }
00624   #endif
00625 
00626 /* BEGIN gf */
00627   // Return true or false based on whether or not the atom
00628   // is subject to grid force
00629   Bool is_atom_gridforced(int atomnum) const
00630   {
00631       if (numGridforces)
00632       {
00633           return(gridfrcIndexes[atomnum] != -1);
00634       }
00635       else
00636       {
00637           return(FALSE);
00638       }
00639   }
00640 /* END gf */
00641 
00642   //  Return true or false based on whether the specified atom
00643   //  is constrained or not.
00644   Bool is_atom_constrained(int atomnum) const
00645   {
00646     if (numConstraints)
00647     {
00648       //  Check the index to see if it is constrained
00649       return(consIndexes[atomnum] != -1);
00650     }
00651     else
00652     {
00653       //  No constraints at all, so just return FALSE
00654       return(FALSE);
00655     }
00656   }
00657 
00658   //  Return true or false based on whether the specified atom
00659   //  is moving-dragged or not.
00660   Bool is_atom_movdragged(int atomnum) const
00661   {
00662     if (numMovDrag)
00663     {
00664       //  Check the index to see if it is constrained
00665       return(movDragIndexes[atomnum] != -1);
00666     }
00667     else
00668     {
00669       //  No constraints at all, so just return FALSE
00670       return(FALSE);
00671     }
00672   }
00673 
00674   //  Return true or false based on whether the specified atom
00675   //  is rotating-dragged or not.
00676   Bool is_atom_rotdragged(int atomnum) const
00677   {
00678     if (numRotDrag)
00679     {
00680       //  Check the index to see if it is constrained
00681       return(rotDragIndexes[atomnum] != -1);
00682     }
00683     else
00684     {
00685       //  No constraints at all, so just return FALSE
00686       return(FALSE);
00687     }
00688   }
00689 
00690   //  Return true or false based on whether the specified atom
00691   //  is "constant"-torqued or not.
00692   Bool is_atom_constorqued(int atomnum) const
00693   {
00694     if (numConsTorque)
00695     {
00696       //  Check the index to see if it is constrained
00697       return(consTorqueIndexes[atomnum] != -1);
00698     }
00699     else
00700     {
00701       //  No constraints at all, so just return FALSE
00702       return(FALSE);
00703     }
00704   }
00705 
00706   //  Get the harmonic constraints for a specific atom
00707   void get_cons_params(Real &k, Vector &refPos, int atomnum) const
00708   {
00709     k = consParams[consIndexes[atomnum]].k;
00710     refPos = consParams[consIndexes[atomnum]].refPos;
00711   }
00712 
00713 /* BEGIN gf */
00714   void get_gridfrc_params(Real &k, Charge &q, int atomnum) const
00715   {
00716       k = gridfrcParams[gridfrcIndexes[atomnum]].k;
00717       q = gridfrcParams[gridfrcIndexes[atomnum]].q;
00718   }
00719   
00720   const GridforceGrid* get_gridfrc_grid(void) const
00721   {
00722       return gridfrcGrid;
00723   }
00724 /* END gf */
00725 
00726   Real langevin_param(int atomnum) const
00727   {
00728     return(langevinParams[atomnum]);
00729   }
00730 
00731   //  Get the stirring constraints for a specific atom
00732   void get_stir_refPos(Vector &refPos, int atomnum) const
00733   {
00734     refPos = stirParams[stirIndexes[atomnum]].refPos;
00735   }
00736 
00737 
00738   void put_stir_startTheta(Real theta, int atomnum) const
00739   {
00740     stirParams[stirIndexes[atomnum]].startTheta = theta;
00741   }
00742 
00743 
00744   Real get_stir_startTheta(int atomnum) const
00745   {
00746     return stirParams[stirIndexes[atomnum]].startTheta;
00747   }
00748  
00749 
00750   //  Get the moving drag factor for a specific atom
00751   void get_movdrag_params(Vector &v, int atomnum) const
00752   {
00753     v = movDragParams[movDragIndexes[atomnum]].v;
00754   }
00755 
00756   //  Get the rotating drag pars for a specific atom
00757   void get_rotdrag_params(BigReal &v, Vector &a, Vector &p, 
00758         int atomnum) const
00759   {
00760     v = rotDragParams[rotDragIndexes[atomnum]].v;
00761     a = rotDragParams[rotDragIndexes[atomnum]].a;
00762     p = rotDragParams[rotDragIndexes[atomnum]].p;
00763   }
00764 
00765   //  Get the "constant" torque pars for a specific atom
00766   void get_constorque_params(BigReal &v, Vector &a, Vector &p, 
00767         int atomnum) const
00768   {
00769     v = consTorqueParams[consTorqueIndexes[atomnum]].v;
00770     a = consTorqueParams[consTorqueIndexes[atomnum]].a;
00771     p = consTorqueParams[consTorqueIndexes[atomnum]].p;
00772   }
00773 
00774 //fepb
00775         unsigned char get_fep_type(int anum) const
00776         {
00777                 return(fepAtomFlags[anum]);
00778         }
00779 //fepe
00780 
00781   Bool is_atom_fixed(int atomnum) const
00782   {
00783     return (numFixedAtoms && fixedAtomFlags[atomnum]);
00784   }
00785 
00786         
00787   Bool is_atom_stirred(int atomnum) const
00788   {
00789     if (numStirredAtoms)
00790     {
00791       //  Check the index to see if it is constrained
00792       return(stirIndexes[atomnum] != -1);
00793     }
00794     else
00795     {
00796       //  No constraints at all, so just return FALSE
00797       return(FALSE);
00798     }
00799   }
00800   
00801 
00802   Bool is_group_fixed(int atomnum) const
00803   {
00804     return (numFixedAtoms && (fixedAtomFlags[atomnum] == -1));
00805   }
00806   Bool is_atom_exPressure(int atomnum) const
00807   {
00808     return (numExPressureAtoms && exPressureAtomFlags[atomnum]);
00809   }
00810   // 0 if not rigid or length to parent, for parent refers to H-H length
00811   // < 0 implies MOLLY but not SHAKE, > 1 implies both if MOLLY is on
00812   Real rigid_bond_length(int atomnum) const
00813   {
00814     return(rigidBondLengths[atomnum]);
00815   }
00816 
00817   void print_atoms(Parameters *); 
00818         //  Print out list of atoms
00819   void print_bonds(Parameters *); 
00820         //  Print out list of bonds
00821   void print_exclusions();//  Print out list of exclusions
00822 
00823 private:
00824   //Read in a compressed .psf file (whose format is not standard) for
00825   //the sake of very very large simulations (say, 100M atoms system)
00826   void read_compressed_psf_file(char *, Parameters *);   
00827 
00828 #ifdef MEM_OPT_VERSION
00829 public:  
00830   int atomSigPoolSize;
00831   AtomSignature *atomSigPool;
00832 
00833   /* All the following are temporary variables for reading the compressed psf file */
00834   //declarations for atoms' constant information  
00835   int segNamePoolSize; //Its value is usually less than 5
00836   char **segNamePool; //This seems not to be important, but it only occupied very little space.
00837 
00838   int resNamePoolSize;
00839   char **resNamePool;
00840 
00841   int atomNamePoolSize;
00842   char **atomNamePool;
00843 
00844   int atomTypePoolSize;
00845   char **atomTypePool;
00846 
00847   int chargePoolSize;
00848   Real *atomChargePool;
00849 
00850   int massPoolSize;
00851   Real *atomMassPool;
00852 
00853   AtomSigID getAtomSigId(int aid) {
00854       return eachAtomSig[aid]; 
00855   }
00856   ExclSigID getAtomExclSigId(int aid) const {
00857       return eachAtomExclSig[aid];
00858   }
00859 
00860   //Indicates the size of both exclSigPool and exclChkSigPool
00861   int exclSigPoolSize;
00862   //this will be deleted after build_lists_by_atom
00863   ExclusionSignature *exclSigPool;
00864   //This is the final data structure we want to store  
00865   ExclusionCheck *exclChkSigPool;
00866 
00867   void addNewExclSigPool(const vector<ExclusionSignature>&);
00868 
00869   void build_excl_check_signatures();
00870 
00871   void delEachAtomSigs(){    
00872       //for NAMD-smp version, only one Molecule object is held
00873       //on each node, therefore, only one deletion operation should
00874       //be taken on a node, otherwise, there possibly would be some
00875       //wierd memory problems. The same reason applies to other deletion
00876       //operations inside the Molecule object.   
00877       if(CmiMyRank()) return;
00878 
00879       delete [] eachAtomSig;
00880       delete [] eachAtomExclSig;
00881       eachAtomSig = NULL;
00882       eachAtomExclSig = NULL;
00883   }
00884 
00885   void delChargeSpace(){
00886       if(CmiMyRank()) return;
00887 
00888       delete [] atomChargePool;
00889       delete [] eachAtomCharge;
00890       atomChargePool = NULL;
00891       eachAtomCharge = NULL;
00892   }
00893   
00894   void delMassSpace(){
00895       if(CmiMyRank()) return;
00896 
00897       delete [] atomMassPool;
00898       delete [] eachAtomMass;
00899       atomMassPool = NULL;
00900       eachAtomMass = NULL;
00901   }
00902   
00903   void delClusterSigs() {
00904       if(CmiMyRank()) return;      
00905 
00906       delete [] clusterSigs;
00907       clusterSigs = NULL;
00908   }
00909 
00910   void delOtherEachAtomStructs();
00911 
00912 
00913 private:
00914   Index insert_new_mass(Real newMass);
00915   //void markClusterIdx(int curClusterIdx, int startAtomID);  
00916 
00917   //This function checks whether the exclusion (atom1 and atom2) will
00918   //be stripped by the original stripFepExcl function and by the fixed atoms.
00919   //When stripping exclusions in the stripHGroupExcl function (where we actually
00920   //not performing stripping but only deducting numCalcExclusions), we use
00921   //this function to avoid the repeated deduction. Only exclusions that are only
00922   //stripped due to hydrogen group is counted
00923   int exclStrippedByFepOrFixedAtoms(int atom1, int atom2);
00924 #endif
00925 
00926 };
00927 
00928 #endif
00929 

Generated on Sat Oct 11 04:07:42 2008 for NAMD by  doxygen 1.3.9.1