00001
00007
00008
00009
00010
00011
00012
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
00031 #include "GridForceGrid.h"
00032 #include "Tensor.h"
00033
00034
00035
00036 #define MAX_GO_CHAINS 10
00037 #define MAX_RESTRICTIONS 10
00038
00039
00040 #include "molfile_plugin.h"
00041
00042 #include <vector>
00043
00044 class SimParameters;
00045 class Parameters;
00046 class ConfigList;
00047 class PDB;
00048 class MIStream;
00049 class MOStream;
00050
00051 class ExclElem;
00052 class BondElem;
00053 class AngleElem;
00054 class DihedralElem;
00055 class ImproperElem;
00056 class TholeElem;
00057 class AnisoElem;
00058 class CrosstermElem;
00059 class ResidueLookupElem;
00060
00061 struct OutputAtomRecord;
00062
00063 template<class Type> class ObjectArena;
00064
00065 class ExclusionCheck {
00066 public:
00067 int32 min,max;
00068 char *flags;
00069
00070 ExclusionCheck(){
00071 min=0;
00072 max=-1;
00073 flags = NULL;
00074 }
00075 ExclusionCheck(const ExclusionCheck& chk){
00076 min = chk.min;
00077 max = chk.max;
00078 if(max>min){
00079 flags = new char[max-min+1];
00080 memcpy(flags, chk.flags, sizeof(char)*(max-min+1));
00081 }
00082 }
00083 ExclusionCheck &operator=(const ExclusionCheck& chk){
00084 min = chk.min;
00085 max = chk.max;
00086 if(flags) delete [] flags;
00087 flags = NULL;
00088 if(max>min){
00089 flags = new char[max-min+1];
00090 memcpy(flags, chk.flags, sizeof(char)*(max-min+1));
00091 }
00092 return *this;
00093 }
00094 ~ExclusionCheck(){
00095 if(flags) delete [] flags;
00096 }
00097 };
00098 #define EXCHCK_FULL 1
00099 #define EXCHCK_MOD 2
00100
00101
00102 typedef struct go_val
00103 {
00104 Real epsilon;
00105 int exp_a;
00106 int exp_b;
00107 int exp_rep;
00108 Real sigmaRep;
00109 Real epsilonRep;
00110 Real cutoff;
00111 int restrictions[MAX_RESTRICTIONS];
00112 } GoValue;
00113
00114 typedef struct go_pair
00115 {
00116 int goIndxA;
00117 int goIndxB;
00118 double A;
00119 double B;
00120 } GoPair;
00121
00122
00123
00124 typedef struct seg_resid
00125 {
00126 char segname[11];
00127 int resid;
00128 }AtomSegResInfo;
00129
00130
00131 class Molecule
00132 {
00133 private:
00134 typedef struct constraint_params
00135 {
00136 Real k;
00137 Vector refPos;
00138 } ConstraintParams;
00139
00140
00141
00142
00143 typedef struct gridfrc_params
00144 {
00145 Real k;
00146 Charge q;
00147 } GridforceParams;
00148
00149
00150
00151 typedef struct stir_params
00152 {
00153 Real startTheta;
00154 Vector refPos;
00155 } StirParams;
00156
00157 typedef struct movdrag_params
00158 {
00159 Vector v;
00160 } MovDragParams;
00161
00162
00163 typedef struct rotdrag_params
00164 {
00165 Real v;
00166 Vector a;
00167 Vector p;
00168 } RotDragParams;
00169
00170 typedef struct constorque_params
00171 {
00172 Real v;
00173 Vector a;
00174 Vector p;
00175 } ConsTorqueParams;
00176
00177 #ifdef MEM_OPT_VERSION
00178
00179 struct AtomSet{
00180 AtomID aid1;
00181 AtomID aid2;
00182
00183 int operator < (const AtomSet &a) const{
00184 return aid1 < a.aid1;
00185 }
00186 };
00187 typedef ResizeArray<AtomSet> AtomSetList;
00188
00189 void load_atom_set(StringList *setfile, const char *setname,
00190 int *numAtomsInSet, Molecule::AtomSetList **atomsSet) const;
00191
00192 #endif
00193
00194 friend class ExclElem;
00195 friend class BondElem;
00196 friend class AngleElem;
00197 friend class DihedralElem;
00198 friend class ImproperElem;
00199 friend class TholeElem;
00200 friend class AnisoElem;
00201 friend class CrosstermElem;
00202 friend class WorkDistrib;
00203
00204 private:
00205
00206 #ifndef MEM_OPT_VERSION
00207 Atom *atoms;
00208 ObjectArena<char> *nameArena;
00209 AtomNameInfo *atomNames;
00210
00211 Bond *bonds;
00212 Angle *angles;
00213 Dihedral *dihedrals;
00214 Improper *impropers;
00215 Crossterm *crossterms;
00216
00217
00218 Exclusion *exclusions;
00219 UniqueSet<Exclusion> exclusionSet;
00220
00221 int32 *cluster;
00222
00223 ObjectArena<int32> *tmpArena;
00224 int32 **bondsWithAtom;
00225 ObjectArena<int32> *arena;
00226
00227
00228 int32 **bondsByAtom;
00229 int32 **anglesByAtom;
00230 int32 **dihedralsByAtom;
00231 int32 **impropersByAtom;
00232 int32 **crosstermsByAtom;
00233
00234 int32 **exclusionsByAtom;
00235 int32 **fullExclusionsByAtom;
00236 int32 **modExclusionsByAtom;
00237 ObjectArena<char> *exclArena;
00238 ExclusionCheck *all_exclusions;
00239
00240
00241 int32 **tholesByAtom;
00242 int32 **anisosByAtom;
00243
00244
00245 #else
00246
00247 AtomCstInfo *atoms;
00248 Index *eachAtomMass;
00249 Index *eachAtomCharge;
00250 AtomNameIdx *atomNames;
00251 ObjectArena<char> *nameArena;
00252
00253
00254
00255
00256
00257 int32 *clusterSigs;
00258 int32 numClusters;
00259
00260 AtomSigID *eachAtomSig;
00261 ExclSigID *eachAtomExclSig;
00262
00263 AtomSetList *fixedAtomsSet;
00264 AtomSetList *constrainedAtomsSet;
00265 #endif
00266
00267 ResidueLookupElem *resLookup;
00268
00269 AtomSegResInfo *atomSegResids;
00270
00271 Bond *donors;
00272 Bond *acceptors;
00273
00274
00275 DrudeConst *drudeConsts;
00276 Thole *tholes;
00277 Aniso *anisos;
00278 Lphost *lphosts;
00279 int32 *lphostIndexes;
00280
00281
00282 int32 *consIndexes;
00283 ConstraintParams *consParams;
00284
00285
00286 int32 **gridfrcIndexes;
00287 GridforceParams **gridfrcParams;
00288 GridforceGrid **gridfrcGrid;
00289
00290
00291
00292 int32 *stirIndexes;
00293 StirParams *stirParams;
00294
00295 int32 *movDragIndexes;
00296 MovDragParams *movDragParams;
00297
00298 int32 *rotDragIndexes;
00299 RotDragParams *rotDragParams;
00300
00301
00302 Real *langevinParams;
00303 int32 *fixedAtomFlags;
00304 int32 *exPressureAtomFlags;
00305
00306
00307
00308
00309
00310 int32 *clusterSize;
00311
00312 Real *rigidBondLengths;
00313
00314
00315 unsigned char *fepAtomFlags;
00316
00317
00318
00319 float *occupancy;
00320 float *bfactor;
00321
00322
00323
00324 SimParameters *simParams;
00325 Parameters *params;
00326
00327 private:
00328 void initialize(SimParameters *, Parameters *param);
00329
00330
00331
00332 int *lcpoParamType;
00333
00334 #ifndef MEM_OPT_VERSION
00335 void read_psf_file(char *, Parameters *);
00336
00337
00338
00339
00340 void read_atoms(FILE *, Parameters *);
00341
00342 void read_bonds(FILE *, Parameters *);
00343
00344 void read_angles(FILE *, Parameters *);
00345
00346 void read_dihedrals(FILE *, Parameters *);
00347
00348 void read_impropers(FILE *, Parameters *);
00349
00350 void read_crossterms(FILE *, Parameters *);
00351
00352 void read_donors(FILE *);
00353
00354 void read_acceptors(FILE *);
00355
00356 void read_exclusions(FILE *);
00357
00358
00359 void read_exclusions(int*, int*, int);
00360
00361 static bool goPairCompare (GoPair, GoPair);
00362
00363
00364
00365
00366 void read_lphosts(FILE *);
00367
00368 void read_anisos(FILE *);
00369
00370
00371
00372
00373
00374
00375
00376
00377
00378 void assignLCPOTypes(int inputType);
00379
00380
00381 void plgLoadAtomBasics(molfile_atom_t *atomarray);
00382 void plgLoadBonds(int *from, int *to);
00383 void plgLoadAngles(int *plgAngles);
00384 void plgLoadDihedrals(int *plgDihedrals);
00385 void plgLoadImpropers(int *plgImpropers);
00386 void plgLoadCrossterms(int *plgCterms);
00387
00388
00389
00390
00391
00392 void build_lists_by_atom();
00393
00394
00395 void build12excl(void);
00396 void build13excl(void);
00397 void build14excl(int);
00398
00399
00400 void build_inherited_excl(int);
00401
00402 void stripFepExcl(void);
00403
00404 void build_exclusions();
00405
00406
00407 void build_atom_status(void);
00408
00409 #else
00410
00411
00412 void read_mol_signatures(char *fname, Parameters *params, ConfigList *cfgList=0);
00413 void load_one_inputatom(int aid, OutputAtomRecord *one, InputAtom *fAtom);
00414 void build_excl_check_signatures();
00415 #endif
00416
00417 void read_parm(const GromacsTopFile *);
00418
00419 public:
00420
00421 int is_drude_psf;
00422 int is_lonepairs_psf;
00423
00424
00425
00426 Real r_om;
00427 Real r_ohc;
00428
00429
00430 BigReal tail_corr_ener;
00431 BigReal tail_corr_virial;
00432
00433 int const * getLcpoParamType() {
00434 return lcpoParamType;
00435 }
00436
00437 BigReal GetAtomAlpha(int i) const {
00438 return drudeConsts[i].alpha;
00439 }
00440
00441 #ifdef MEM_OPT_VERSION
00442 AtomCstInfo *getAtoms() const { return atoms; }
00443 AtomNameIdx *getAtomNames() const { return atomNames; }
00444 #else
00445 Atom *getAtoms () const { return atoms; }
00446 AtomNameInfo *getAtomNames() const { return atomNames; }
00447 #endif
00448
00449 AtomSegResInfo *getAtomSegResInfo() const { return atomSegResids; }
00450
00451
00452 int num_fixed_atoms() const {
00453
00454 int s_NumFixedAtoms = (simParams->fixedAtomsOn ? numFixedAtoms : 0);
00455 return s_NumFixedAtoms;
00456 }
00457
00458 int num_fixed_groups() const {
00459
00460 int s_NumFixedAtoms = num_fixed_atoms();
00461 int s_NumFixedGroups = (s_NumFixedAtoms ? numFixedGroups : 0);
00462 return s_NumFixedGroups;
00463 }
00464
00465 int num_group_deg_freedom() const {
00466
00467 int s_NumGroupDegFreedom = 3 * numHydrogenGroups;
00468 int s_NumFixedAtoms = num_fixed_atoms();
00469 int s_NumFixedGroups = num_fixed_groups();
00470 if (s_NumFixedGroups) s_NumGroupDegFreedom -= 3 * s_NumFixedGroups;
00471 if ( ! (s_NumFixedAtoms || numConstraints
00472 || simParams->comMove || simParams->langevinOn) ) {
00473 s_NumGroupDegFreedom -= 3;
00474 }
00475 return s_NumGroupDegFreedom;
00476 }
00477
00478 int num_deg_freedom(int isInitialReport = 0) const {
00479
00480 int s_NumDegFreedom = 3 * numAtoms;
00481 int s_NumFixedAtoms = num_fixed_atoms();
00482 if (s_NumFixedAtoms) s_NumDegFreedom -= 3 * s_NumFixedAtoms;
00483 if (numLonepairs) s_NumDegFreedom -= 3 * numLonepairs;
00484 if ( ! (s_NumFixedAtoms || numConstraints
00485 || simParams->comMove || simParams->langevinOn) ) {
00486 s_NumDegFreedom -= 3;
00487 }
00488 if ( ! isInitialReport && simParams->pairInteractionOn) {
00489
00490
00491
00492
00493 s_NumDegFreedom = 3 * numFepInitial;
00494 }
00495 int s_NumFixedRigidBonds =
00496 (simParams->fixedAtomsOn ? numFixedRigidBonds : 0);
00497 if (simParams->watmodel == WAT_TIP4) {
00498
00499
00500 s_NumDegFreedom -= (numRigidBonds - s_NumFixedRigidBonds - numLonepairs);
00501 }
00502 else {
00503
00504
00505
00506 s_NumDegFreedom -= (numRigidBonds - s_NumFixedRigidBonds);
00507 }
00508 return s_NumDegFreedom;
00509 }
00510
00511 int numAtoms;
00512
00513 int numRealBonds;
00514 int numBonds;
00515 int numAngles;
00516 int numDihedrals;
00517 int suspiciousAlchBonds;
00518 int alchDroppedAngles;
00519 int alchDroppedDihedrals;
00520 int alchDroppedImpropers;
00521 int numImpropers;
00522 int numCrossterms;
00523 int numDonors;
00524 int numAcceptors;
00525 int numExclusions;
00526 int numTotalExclusions;
00527
00528
00529 int numLonepairs;
00530 int numDrudeAtoms;
00531 int numTholes;
00532 int numAnisos;
00533 int numLphosts;
00534
00535
00536 int numConstraints;
00537
00538 int numGridforceGrids;
00539 int *numGridforces;
00540
00541 int numMovDrag;
00542 int numRotDrag;
00543 int numConsTorque;
00544 int numFixedAtoms;
00545 int numStirredAtoms;
00546 int numExPressureAtoms;
00547 int numHydrogenGroups;
00548 int maxHydrogenGroupSize;
00549 int numMigrationGroups;
00550 int maxMigrationGroupSize;
00551 int numFixedGroups;
00552 int numRigidBonds;
00553 int numFixedRigidBonds;
00554
00555 int numFepInitial;
00556 int numFepFinal;
00557
00558
00559 int numConsForce;
00560 int32 *consForceIndexes;
00561 Vector *consForce;
00562
00563 int32 *consTorqueIndexes;
00564 ConsTorqueParams *consTorqueParams;
00565
00566
00567
00568
00569 int numCalcBonds;
00570 int numCalcAngles;
00571 int numCalcDihedrals;
00572 int numCalcImpropers;
00573 int numCalcCrossterms;
00574 int numCalcExclusions;
00575
00576
00577 int numCalcTholes;
00578 int numCalcAnisos;
00579
00580
00581
00582 int numMultipleDihedrals;
00583
00584 int numMultipleImpropers;
00585
00586 HydrogenGroup hydrogenGroup;
00587
00588
00589 int numGoAtoms;
00590 int32 *atomChainTypes;
00591 int32 *goSigmaIndices;
00592 int32 *goResidIndices;
00593 Real *goSigmas;
00594 bool *goWithinCutoff;
00595 Real *goCoordinates;
00596 int *goResids;
00597 PDB *goPDB;
00598
00599 int goNumLJPair;
00600 int *goIndxLJA;
00601 int *goIndxLJB;
00602 double *goSigmaPairA;
00603 double *goSigmaPairB;
00604 int *pointerToGoBeg;
00605 int *pointerToGoEnd;
00606
00607 int numPair;
00608 int numLJPair;
00609 int *pointerToLJBeg;
00610 int *pointerToLJEnd;
00611 int *indxLJA;
00612 int *indxLJB;
00613 Real *pairC6;
00614 Real *pairC12;
00615
00616 int *pointerToGaussBeg;
00617 int *pointerToGaussEnd;
00618 int numGaussPair;
00619 int *indxGaussA;
00620 int *indxGaussB;
00621 Real *gA;
00622 Real *gMu1;
00623 Real *giSigma1;
00624 Real *gMu2;
00625 Real *giSigma2;
00626 Real *gRepulsive;
00627
00628
00629 BigReal energyNative;
00630 BigReal energyNonnative;
00631
00632
00633
00634 Molecule(SimParameters *, Parameters *param);
00635 Molecule(SimParameters *, Parameters *param, char *filename, ConfigList *cfgList=NULL);
00636 Molecule(SimParameters *simParams, Parameters *param, molfile_plugin_t *pIOHdl, void *pIOFileHdl, int natoms);
00637
00638 Molecule(SimParameters *, Parameters *, Ambertoppar *);
00639 void read_parm(Ambertoppar *);
00640
00641 Molecule(SimParameters *, Parameters *, const GromacsTopFile *);
00642
00643 ~Molecule();
00644
00645 void send_Molecule(MOStream *);
00646
00647
00648
00649 void receive_Molecule(MIStream *);
00650
00651
00652
00653 void build_constraint_params(StringList *, StringList *, StringList *,
00654 PDB *, char *);
00655
00656
00657
00658
00659 void build_gridforce_params(StringList *, StringList *, StringList *, StringList *, PDB *, char *);
00660
00661
00662
00663 void build_movdrag_params(StringList *, StringList *, StringList *,
00664 PDB *, char *);
00665
00666
00667 void build_rotdrag_params(StringList *, StringList *, StringList *,
00668 StringList *, StringList *, StringList *,
00669 PDB *, char *);
00670
00671
00672 void build_constorque_params(StringList *, StringList *, StringList *,
00673 StringList *, StringList *, StringList *,
00674 PDB *, char *);
00675
00676
00677
00678 void build_constant_forces(char *);
00679
00680
00681 void build_langevin_params(BigReal coupling, BigReal drudeCoupling,
00682 Bool doHydrogen);
00683 void build_langevin_params(StringList *, StringList *, PDB *, char *);
00684
00685
00686 #ifdef MEM_OPT_VERSION
00687 void load_fixed_atoms(StringList *fixedFile);
00688 void load_constrained_atoms(StringList *constrainedFile);
00689 #endif
00690
00691 void build_fixed_atoms(StringList *, StringList *, PDB *, char *);
00692
00693
00694 void build_stirred_atoms(StringList *, StringList *, PDB *, char *);
00695
00696
00697 void build_extra_bonds(Parameters *parameters, StringList *file);
00698
00699
00700 void build_fep_flags(StringList *, StringList *, PDB *, char *, const char *);
00701
00702 void delete_alch_bonded(void);
00703
00704
00705 void build_exPressure_atoms(StringList *, StringList *, PDB *, char *);
00706
00707
00708
00709
00710 void print_go_sigmas();
00711 void build_go_sigmas(StringList *, char *);
00712
00713
00714 void build_go_sigmas2(StringList *, char *);
00715
00716
00717 void build_go_arrays(StringList *, char *);
00718
00719 BigReal get_gro_force(BigReal, BigReal, BigReal, int, int) const;
00720 BigReal get_gro_force2(BigReal, BigReal, BigReal, int, int, BigReal *, BigReal *) const;
00721 BigReal get_go_force(BigReal, int, int, BigReal *, BigReal *) const;
00722
00723
00724 BigReal get_go_force_new(BigReal, int, int, BigReal *, BigReal *) const;
00725
00726 BigReal get_go_force2(BigReal, BigReal, BigReal, int, int, BigReal *, BigReal *) const;
00727
00728 Bool atoms_1to4(unsigned int, unsigned int);
00729
00730
00731 void reloadCharges(float charge[], int n);
00732
00733 Bool is_lp(int);
00734 Bool is_drude(int);
00735 Bool is_hydrogen(int);
00736 Bool is_oxygen(int);
00737 Bool is_hydrogenGroupParent(int);
00738 Bool is_water(int);
00739 int get_groupSize(int);
00740 int get_mother_atom(int);
00741
00742 #ifdef MEM_OPT_VERSION
00743
00744
00745 int get_cluster_size_con(int aid) const { return clusterSigs[aid]; }
00746
00747
00748 int get_cluster_size_uncon(int cIdx) const { return clusterSize[cIdx]; }
00749 int get_cluster_idx(int aid) const { return clusterSigs[aid]; }
00750 int get_num_clusters() const { return numClusters; }
00751 #else
00752 int get_cluster(int anum) const { return cluster[anum]; }
00753 int get_clusterSize(int anum) const { return clusterSize[anum]; }
00754 #endif
00755
00756 #ifndef MEM_OPT_VERSION
00757 const float *getOccupancyData() { return (const float *)occupancy; }
00758 void setOccupancyData(molfile_atom_t *atomarray);
00759 void freeOccupancyData() { delete [] occupancy; occupancy=NULL; }
00760
00761 const float *getBFactorData() { return (const float *)bfactor; }
00762 void setBFactorData(molfile_atom_t *atomarray);
00763 void freeBFactorData() { delete [] bfactor; bfactor=NULL; }
00764 #endif
00765
00766
00767 Real atommass(int anum) const
00768 {
00769 #ifdef MEM_OPT_VERSION
00770 return atomMassPool[eachAtomMass[anum]];
00771 #else
00772 return(atoms[anum].mass);
00773 #endif
00774 }
00775
00776
00777 Real atomcharge(int anum) const
00778 {
00779 #ifdef MEM_OPT_VERSION
00780 return atomChargePool[eachAtomCharge[anum]];
00781 #else
00782 return(atoms[anum].charge);
00783 #endif
00784 }
00785
00786
00787 Index atomvdwtype(int anum) const
00788 {
00789 return(atoms[anum].vdw_type);
00790 }
00791
00792 #ifndef MEM_OPT_VERSION
00793
00794 Bond *get_bond(int bnum) const {return (&(bonds[bnum]));}
00795
00796
00797 Angle *get_angle(int anum) const {return (&(angles[anum]));}
00798
00799
00800 Improper *get_improper(int inum) const {return (&(impropers[inum]));}
00801
00802
00803 Dihedral *get_dihedral(int dnum) const {return (&(dihedrals[dnum]));}
00804
00805
00806 Crossterm *get_crossterm(int inum) const {return (&(crossterms[inum]));}
00807 #endif
00808
00809
00810 Lphost *get_lphost(int atomid) const {
00811
00812
00813 int index = lphostIndexes[atomid];
00814 return (index != -1 ? &(lphosts[index]) : NULL);
00815 }
00816
00817
00818 #ifndef MEM_OPT_VERSION
00819 Bond *getAllBonds() const {return bonds;}
00820 Angle *getAllAngles() const {return angles;}
00821 Improper *getAllImpropers() const {return impropers;}
00822 Dihedral *getAllDihedrals() const {return dihedrals;}
00823 Crossterm *getAllCrossterms() const {return crossterms;}
00824 #endif
00825
00826
00827 Lphost *getAllLphosts() const { return lphosts; }
00828
00829
00830
00831 Bond *get_donor(int dnum) const {return (&(donors[dnum]));}
00832
00833
00834 Bond *get_acceptor(int dnum) const {return (&(acceptors[dnum]));}
00835
00836 Bond *getAllDonors() const {return donors;}
00837 Bond *getAllAcceptors() const {return acceptors;}
00838
00839
00840 #ifndef MEM_OPT_VERSION
00841 Exclusion *get_exclusion(int ex) const {return (&(exclusions[ex]));}
00842 #endif
00843
00844
00845 const char *get_atomtype(int anum) const
00846 {
00847 if (atomNames == NULL)
00848 {
00849 NAMD_die("Tried to find atom type on node other than node 0");
00850 }
00851
00852 #ifdef MEM_OPT_VERSION
00853 return atomTypePool[atomNames[anum].atomtypeIdx];
00854 #else
00855 return(atomNames[anum].atomtype);
00856 #endif
00857 }
00858
00859
00860 int get_atom_from_name(const char *segid, int resid, const char *aname) const;
00861
00862
00863 int get_residue_size(const char *segid, int resid) const;
00864
00865
00866 int get_atom_from_index_in_residue(const char *segid, int resid, int index) const;
00867
00868
00869
00870
00871
00872
00873 #ifndef MEM_OPT_VERSION
00874 int32 *get_bonds_for_atom(int anum)
00875 { return bondsByAtom[anum]; }
00876 int32 *get_angles_for_atom(int anum)
00877 { return anglesByAtom[anum]; }
00878 int32 *get_dihedrals_for_atom(int anum)
00879 { return dihedralsByAtom[anum]; }
00880 int32 *get_impropers_for_atom(int anum)
00881 { return impropersByAtom[anum]; }
00882 int32 *get_crossterms_for_atom(int anum)
00883 { return crosstermsByAtom[anum]; }
00884 int32 *get_exclusions_for_atom(int anum)
00885 { return exclusionsByAtom[anum]; }
00886 const int32 *get_full_exclusions_for_atom(int anum) const
00887 { return fullExclusionsByAtom[anum]; }
00888 const int32 *get_mod_exclusions_for_atom(int anum) const
00889 { return modExclusionsByAtom[anum]; }
00890 #endif
00891
00892
00893
00894 #ifdef MEM_OPT_VERSION
00895 int checkExclByIdx(int idx1, int atom1, int atom2) const;
00896 const ExclusionCheck *get_excl_check_for_idx(int idx) const{
00897 return &exclChkSigPool[idx];
00898 }
00899 #else
00900 int checkexcl(int atom1, int atom2) const;
00901
00902 const ExclusionCheck *get_excl_check_for_atom(int anum) const{
00903 return &all_exclusions[anum];
00904 }
00905 #endif
00906
00907
00908
00909
00910 Bool is_atom_gridforced(int atomnum, int gridnum) const
00911 {
00912 if (numGridforceGrids)
00913 {
00914 return(gridfrcIndexes[gridnum][atomnum] != -1);
00915 }
00916 else
00917 {
00918 return(FALSE);
00919 }
00920 }
00921
00922
00923 #ifndef MEM_OPT_VERSION
00924
00925
00926 Bool is_atom_constrained(int atomnum) const
00927 {
00928 if (numConstraints)
00929 {
00930
00931 return(consIndexes[atomnum] != -1);
00932 }
00933 else
00934 {
00935
00936 return(FALSE);
00937 }
00938 }
00939 #endif
00940
00941
00942
00943 Bool is_atom_movdragged(int atomnum) const
00944 {
00945 if (numMovDrag)
00946 {
00947
00948 return(movDragIndexes[atomnum] != -1);
00949 }
00950 else
00951 {
00952
00953 return(FALSE);
00954 }
00955 }
00956
00957
00958
00959 Bool is_atom_rotdragged(int atomnum) const
00960 {
00961 if (numRotDrag)
00962 {
00963
00964 return(rotDragIndexes[atomnum] != -1);
00965 }
00966 else
00967 {
00968
00969 return(FALSE);
00970 }
00971 }
00972
00973
00974
00975 Bool is_atom_constorqued(int atomnum) const
00976 {
00977 if (numConsTorque)
00978 {
00979
00980 return(consTorqueIndexes[atomnum] != -1);
00981 }
00982 else
00983 {
00984
00985 return(FALSE);
00986 }
00987 }
00988
00989 #ifndef MEM_OPT_VERSION
00990
00991 void get_cons_params(Real &k, Vector &refPos, int atomnum) const
00992 {
00993 k = consParams[consIndexes[atomnum]].k;
00994 refPos = consParams[consIndexes[atomnum]].refPos;
00995 }
00996 #endif
00997
00998
00999 void get_gridfrc_params(Real &k, Charge &q, int atomnum, int gridnum) const
01000 {
01001 k = gridfrcParams[gridnum][gridfrcIndexes[gridnum][atomnum]].k;
01002 q = gridfrcParams[gridnum][gridfrcIndexes[gridnum][atomnum]].q;
01003 }
01004
01005 GridforceGrid* get_gridfrc_grid(int gridnum) const
01006 {
01007 GridforceGrid *result = NULL;
01008 if (gridnum >= 0 && gridnum < numGridforceGrids) {
01009 result = gridfrcGrid[gridnum];
01010 }
01011 return result;
01012 }
01013
01014 int set_gridfrc_grid(int gridnum, GridforceGrid *grid)
01015 {
01016 if (grid && gridnum >= 0 && gridnum < numGridforceGrids) {
01017 gridfrcGrid[gridnum] = grid;
01018 return 0;
01019 } else {
01020 return -1;
01021 }
01022 }
01023
01024
01025 Real langevin_param(int atomnum) const
01026 {
01027 return(langevinParams ? langevinParams[atomnum] : 0.);
01028 }
01029
01030
01031 void get_stir_refPos(Vector &refPos, int atomnum) const
01032 {
01033 refPos = stirParams[stirIndexes[atomnum]].refPos;
01034 }
01035
01036
01037 void put_stir_startTheta(Real theta, int atomnum) const
01038 {
01039 stirParams[stirIndexes[atomnum]].startTheta = theta;
01040 }
01041
01042
01043 Real get_stir_startTheta(int atomnum) const
01044 {
01045 return stirParams[stirIndexes[atomnum]].startTheta;
01046 }
01047
01048
01049
01050 void get_movdrag_params(Vector &v, int atomnum) const
01051 {
01052 v = movDragParams[movDragIndexes[atomnum]].v;
01053 }
01054
01055
01056 void get_rotdrag_params(BigReal &v, Vector &a, Vector &p,
01057 int atomnum) const
01058 {
01059 v = rotDragParams[rotDragIndexes[atomnum]].v;
01060 a = rotDragParams[rotDragIndexes[atomnum]].a;
01061 p = rotDragParams[rotDragIndexes[atomnum]].p;
01062 }
01063
01064
01065 void get_constorque_params(BigReal &v, Vector &a, Vector &p,
01066 int atomnum) const
01067 {
01068 v = consTorqueParams[consTorqueIndexes[atomnum]].v;
01069 a = consTorqueParams[consTorqueIndexes[atomnum]].a;
01070 p = consTorqueParams[consTorqueIndexes[atomnum]].p;
01071 }
01072
01073
01074 unsigned char get_fep_type(int anum) const
01075 {
01076 return(fepAtomFlags[anum]);
01077 }
01078
01079
01080 #ifndef MEM_OPT_VERSION
01081 Bool is_atom_fixed(int atomnum) const
01082 {
01083 return (numFixedAtoms && fixedAtomFlags[atomnum]);
01084 }
01085 #else
01086
01087
01088
01089
01090
01091
01092
01093 Bool is_atom_in_set(AtomSetList *localAtomsSet, int aid, int *listIdx) const;
01094 inline Bool is_atom_fixed(int aid, int *listIdx=NULL) const {
01095 return is_atom_in_set(fixedAtomsSet,aid,listIdx);
01096 }
01097 inline Bool is_atom_constrained(int aid, int *listIdx=NULL) const {
01098 return is_atom_in_set(constrainedAtomsSet,aid,listIdx);
01099 }
01100 #endif
01101
01102 Bool is_atom_stirred(int atomnum) const
01103 {
01104 if (numStirredAtoms)
01105 {
01106
01107 return(stirIndexes[atomnum] != -1);
01108 }
01109 else
01110 {
01111
01112 return(FALSE);
01113 }
01114 }
01115
01116
01117 Bool is_group_fixed(int atomnum) const
01118 {
01119 return (numFixedAtoms && (fixedAtomFlags[atomnum] == -1));
01120 }
01121 Bool is_atom_exPressure(int atomnum) const
01122 {
01123 return (numExPressureAtoms && exPressureAtomFlags[atomnum]);
01124 }
01125
01126
01127 Real rigid_bond_length(int atomnum) const
01128 {
01129 return(rigidBondLengths[atomnum]);
01130 }
01131
01132 void print_atoms(Parameters *);
01133
01134 void print_bonds(Parameters *);
01135
01136 void print_exclusions();
01137
01138 public:
01139 int isOccupancyValid, isBFactorValid;
01140
01141 #ifdef MEM_OPT_VERSION
01142
01143
01144
01145 void read_binary_atom_info(int fromAtomID, int toAtomID, InputAtomList &inAtoms);
01146
01147 int getNumCalcExclusions(){return numCalcExclusions;}
01148 void setNumCalcExclusions(int x){numCalcExclusions= x;}
01149
01150 Index getEachAtomMass(int i){return eachAtomMass[i];}
01151 Index getEachAtomCharge(int i){return eachAtomCharge[i];}
01152
01153 ExclSigID getAtomExclSigId(int aid) const {
01154 return eachAtomExclSig[aid];
01155 }
01156
01157 Real *getAtomMassPool(){return atomMassPool;}
01158 Real *getAtomChargePool(){return atomChargePool;}
01159 AtomCstInfo *getAtoms(){return atoms;}
01160
01161 int atomSigPoolSize;
01162 AtomSignature *atomSigPool;
01163
01164
01165
01166 int segNamePoolSize;
01167 char **segNamePool;
01168
01169 int resNamePoolSize;
01170 char **resNamePool;
01171
01172 int atomNamePoolSize;
01173 char **atomNamePool;
01174
01175 int atomTypePoolSize;
01176 char **atomTypePool;
01177
01178 int chargePoolSize;
01179 Real *atomChargePool;
01180
01181 int massPoolSize;
01182 Real *atomMassPool;
01183
01184 AtomSigID getAtomSigId(int aid) {
01185 return eachAtomSig[aid];
01186 }
01187
01188
01189 int exclSigPoolSize;
01190
01191 ExclusionSignature *exclSigPool;
01192
01193 ExclusionCheck *exclChkSigPool;
01194
01195 void addNewExclSigPool(const std::vector<ExclusionSignature>&);
01196
01197 void delEachAtomSigs(){
01198
01199
01200
01201
01202
01203 if(CmiMyRank()) return;
01204
01205 delete [] eachAtomSig;
01206 delete [] eachAtomExclSig;
01207 eachAtomSig = NULL;
01208 eachAtomExclSig = NULL;
01209 }
01210
01211 void delChargeSpace(){
01212 if(CmiMyRank()) return;
01213
01214 delete [] atomChargePool;
01215 delete [] eachAtomCharge;
01216 atomChargePool = NULL;
01217 eachAtomCharge = NULL;
01218 }
01219
01220 void delMassSpace(){
01221 if(CmiMyRank()) return;
01222
01223 delete [] atomMassPool;
01224 delete [] eachAtomMass;
01225 atomMassPool = NULL;
01226 eachAtomMass = NULL;
01227 }
01228
01229 void delClusterSigs() {
01230 if(CmiMyRank()) return;
01231
01232 delete [] clusterSigs;
01233 clusterSigs = NULL;
01234 }
01235
01236 void delAtomNames(){
01237 if(CmiMyRank()) return;
01238 delete [] atomNamePool;
01239 delete [] atomNames;
01240 atomNamePool = NULL;
01241 atomNames = NULL;
01242 }
01243
01244 void delFixedAtoms(){
01245 if(CmiMyRank()) return;
01246 delete fixedAtomsSet;
01247 fixedAtomsSet = NULL;
01248 }
01249
01250 private:
01251 Index insert_new_mass(Real newMass);
01252
01253 #endif
01254
01255
01256 public:
01257
01258 GoValue go_array[MAX_GO_CHAINS*MAX_GO_CHAINS];
01259 int go_indices[MAX_GO_CHAINS+1];
01260 int NumGoChains;
01261
01262
01263 void goInit();
01264
01265
01266 void build_gro_pair();
01267
01268
01269 void build_go_params(StringList *);
01270
01271
01272 void read_go_file(char *);
01273
01274
01275 Real get_go_cutoff(int chain1, int chain2) { return go_array[MAX_GO_CHAINS*chain1 + chain2].cutoff; };
01276
01277
01278 Real get_go_epsilonRep(int chain1, int chain2) { return go_array[MAX_GO_CHAINS*chain1 + chain2].epsilonRep; };
01279
01280
01281 Real get_go_sigmaRep(int chain1, int chain2) { return go_array[MAX_GO_CHAINS*chain1 + chain2].sigmaRep; };
01282
01283
01284 Real get_go_epsilon(int chain1, int chain2) { return go_array[MAX_GO_CHAINS*chain1 + chain2].epsilon; };
01285
01286
01287 int get_go_exp_a(int chain1, int chain2) { return go_array[MAX_GO_CHAINS*chain1 + chain2].exp_a; };
01288
01289
01290 int get_go_exp_b(int chain1, int chain2) { return go_array[MAX_GO_CHAINS*chain1 + chain2].exp_b; };
01291
01292
01293 int get_go_exp_rep(int chain1, int chain2) { return go_array[MAX_GO_CHAINS*chain1 + chain2].exp_rep; };
01294
01295
01296 Bool go_restricted(int, int, int);
01297
01298
01299 void print_go_params();
01300
01301 void initialize();
01302
01303 void send_GoMolecule(MOStream *);
01304
01305
01306
01307 void receive_GoMolecule(MIStream *);
01308
01309
01310 };
01311
01312 #endif
01313