#ifndef MDGX_H #define MDGX_H #include #ifdef MPI #include #endif #include "fftw3.h" #ifndef MdgxConstants #define MdgxConstants /*** Pi ***/ #define PI 3.1415926535898 #define TWOPI 6.2831853071796 #define HALFPI 1.5707963267949 #define INVPI 3.1830988618379e-1 #define INV_TWOPI 1.5915494309189e-1 #define ONE_THIRD 0.3333333333333 #define ONE_SIXTH 0.1666666666667 #define ELE_SIXTH 1.8333333333333 #define TN_BASE_E 2.3025850929940 /*** Base of the natural logarithm ***/ #define LNBASE 2.7182818284590 /*** Discretizations of lookup tables ***/ #define SIN_TAB_DSC 6.2831853071796e-2 #define INV_SIN_DSC 1.5915494309189e+1 #define ASIN_TAB_DSC 0.02 #define ACOS_TAB_BUF 0.76 #define INV_ASIN_DSC 50.0 #define COS_OFFSET 25 /*** Coulomb's constant in units of kcal/mol-e^2 ***/ #define BIOQ 332.0522 /*** The universal gas constant in kcal/mol-K ***/ #define GASCNST 1.987216e-3 /*** Avogadro's number ***/ #define AVOGADRO 6.0221418e+23 /*** Factor for converting pressure in kcal/mol-A^2 to bar ***/ #define PCONVFAC 6.94770014e4 /*** Conversion of Hartrees to kcal/mol ***/ #define H2KCAL 627.509649 /*** Conversion of e-A to Debye ***/ #define EA2DEBYE 4.80245625 /*** Conversion of Bohr to Angstrom ***/ #define B2ANG 0.529177249 /*** The nonbonded minimum distance ***/ #define MINNB 2.0 #define MINNB2 4.0 /*** Double-to-integer conversion factors ***/ #define LOC2IFAC 8388608.0 #define I2LOCFAC 1.1920928955078e-07 #define I2LOCBITS 23 #define Q2IFAC 268435456.0 #define I2QFAC 3.7252902984619e-09 #define I2QBITS 28 /*** String length variables ***/ #define MAXTITL 128 #define MAXNAME 512 #define MAXLINE 1024 /*** Maximum number of systems for replica exchange ***/ #define MAXSYS 512 /*** Detect debugging flags ***/ #ifdef DEBUG #define IDEBUG 1 #else #define IDEBUG 0 #endif /*** Maximum valgrind-acceptable message size ***/ #ifdef MPI #define VALGR_MAX_BUFF 64000 #endif #endif #ifndef MacroDefinitions #define MacroDefinitions /***=======================================================================***/ /*** Useful functions ***/ /***=======================================================================***/ #define SIGN(x) ((x >= 0.0) ? 1.0 : -1.0) #define SIGN2(a,b) ((b) >= 0.0 ? fabs(a) : -fabs(a)) #define MAX(a, b) ((a) > (b) ? (a) : (b)) #define MIN(a, b) ((a) > (b) ? (b) : (a)) #define SWAP(x, y, tmp) (tmp) = (x); (x) = (y); (y) = (tmp) #endif /***=======================================================================***/ /*** uform: all the potential function structs wrapped up in one type. ***/ /***=======================================================================***/ struct PotentialFunction { prmtop tp; // Topology dircon dcinp; // Direct-space controls FrcTab Etab; // Direct-space standard (coarse) lookup table FrcTab EHtab; // Direct-space high-resolution lookkup table reccon rcinp; // Reciprocal space controls bckit PPk; // Convolution support data }; typedef struct PotentialFunction uform; /***=======================================================================***/ /*** mdsys: all structs for a molecular dynamics trajectory in one type. ***/ /***=======================================================================***/ struct MolecularDynamicsSystem { coord crd; // Coordinates (phone book organization of the system) cellgrid CG; // Cell grid (spatial reorganization of the system) Energy sysUV; // System energy decomposition and virial execon etimers; // Timing data (for this system only) }; typedef struct MolecularDynamicsSystem mdsys; void GetPrmTop(prmtop *tp, trajcon *tj, int adjbnd); void FreeTopology(prmtop *tp); coord ReadRst(prmtop *tp, char* source); void DestroyCoord(coord *crd); void LongRangeVDW(prmtop *tp, dircon *dcinp); FrcTab DirectSpaceR2(double range, double spc, double ewcoeff, int contderiv); void FreeFrcTab(FrcTab *F); cellgrid CreateCellGrid(coord *crd, dircon *dcinp, reccon *rcinp, prmtop *tp, trajcon *tj, int sysnum); #ifdef MPI void LinkCellGrid(cellgrid *CG, coord *crd, reccon *rcinp); #else void LinkCellGrid(cellgrid *CG, reccon *rcinp); #endif void DestroyCellGrid(cellgrid *CG); void DestroyEnergyTracker(Energy *sysUV); void PrepPME(cellgrid *CG, reccon *rcinp, coord *crd); void DestroyRecCon(reccon *rcinp, cellgrid *CG); bckit CreateBCKit(reccon *rcinp, dbook *Q, coord *crd, prmtop *tp, int DoPlan); void DestroyBCKit(bckit *PPk); void AtomForces(coord *crd, cellgrid *CG, prmtop *tp, dircon *dcinp, FrcTab *Etab, FrcTab *EHtab, reccon *rcinp, bckit *PPk, Energy *sysUV, execon *etimers, trajcon *tj); double KineticEnergy(cellgrid *CG, coord *crd, prmtop *tp, trajcon *tj); double SystemTemperature(cellgrid *CG, coord *crd, prmtop *tp, Energy *sysUV, trajcon *tj, int updateKE); #ifdef MPI void SumTotalEnergy(cellgrid *CG, Energy *sysUV); #else void SumTotalEnergy(Energy *sysUV); #endif void InitHistory(coord *crd); void InitBasicDircon(dircon *dcinp, double NBcut); void InitBasicReccon(reccon *rcinp, dircon *dcinp); void PrimeBasicTopology(prmtop *tp); void InitBasicTrajcon(trajcon *tj); void InitExecon(execon *tm); void InitializeEnergy(Energy *sysUV, trajcon *tj, prmtop *tp, int allocBondUdc); uform InitPotential(char* topsrc, double NBcut, trajcon *tj); mdsys LoadCoordToGrid(char* crdname, uform *U, trajcon *tj); void MMForceEnergy(uform *U, mdsys *MD, trajcon *tj); void AtomsToCells(coord *crd, cellgrid *CG, prmtop *tp); void ImageBondedGroups(coord *crd, prmtop *tp); void DefineMPITypes(trajcon *tj); void FreeMPITypes(trajcon *tj); void TransCrd(double* crds, int natom, double* tvec, double step); void RotateCrd(double* crds, int natom, dmat U); void FindCoordCenter(double* C, double* mass, int usem, int n, double* cofm); void QuatAlign(double* frameI, double* frameII, int natom, double* mass, int m, dmat *U); imat CreateImat(int N, int M); void DestroyImat(imat *A); imat ReallocImat(imat *A, int M, int N); dmat CreateDmat(int N, int M, int prepFFT); void DestroyDmat(dmat *A); dmat ReallocDmat(dmat *A, int M, int N); void CopyDmat(dmat *Ac, dmat *A, int Acex); void DestroyTrajCon(trajcon *tj); void DestroyCmat(cmat *A); #endif