#ifndef SIMFRONT_H #define SIMFRONT_H #include "mdapi.h" #include "mdio.h" #include "ihash.h" #ifdef __cplusplus extern "C" { #endif #define TRUE 1 #define PDBVEL 1000.0 /* conversion factor for vel to PDB */ #define INV_PDBVEL 0.001 /* conversion factor for PDB to vel */ /* Xplor PDB stores velocity as A/ps, we need A/fs */ /* prototypes from linked engine */ MD_Errcode deven_create_engine(MD_Sim *); void deven_destroy_engine(MD_Sim *); typedef MD_Errcode (*FCreate)(MD_Sim *); typedef void (*FDestroy)(MD_Sim *); #define TBUFLEN 10 #define ARRAYLEN 10 #define INITLEN 10 #define STRING_SIZE 1024 #define ERRMSG_SIZE 1024 #define ERRMSG_MSG_PREC 928 #define ERRMSG_FILE_PREC 64 #define ARRLEN(x) (sizeof(x) / sizeof(x[0])) #define ABORT(sf, msg) terminate(sf, msg, __FILE__, __LINE__) #define ERRMSG(sf, msg) errmsg(sf, msg, __FILE__, __LINE__) struct SimFront_Tag; typedef struct ConfigKeywd_Tag { const char *keywd; int (*set)(struct SimFront_Tag *, char *value); } ConfigKeywd; typedef struct CallbackInfo_Tag { char reductitle[STRING_SIZE]; char reducfmt[STRING_SIZE]; int numcols; int titlefreq; } CallbackInfo; typedef struct SimFront_Tag { /* error message buffer */ char errmsg[ERRMSG_SIZE]; /* command line parameters */ const char *simfront; const char *configfile; const char *engine; FCreate create; FDestroy destroy; /* handle to simulation */ MD_Sim *sim; /* SimFront config file keywords and hash table */ const ConfigKeywd *cfkwd; int cfkwdnum; Ihash kwdtable; /* SimFront parameters set from config file */ char **paramfilelist; int paramfilelistnum; int paramfilelistmax; char *topofile; char *coorfile; char *bincoorfile; char *velfile; char *binvelfile; char *cwd; char *outputfile; int isoutputbin; char *restartfile; int isrestartbin; int restartfreq; int energyfreq; int numsteps; double temperature; /* * Explanatory note: * * Structures Param, Pbuf, Topo, Tbuf, Pdb, and Binres all come from * the MDIO library. This library interface is quite awkward and needs * to be redesigned to make it easier to use. */ /* force field parameter file and buffer space */ /* (in this case, space is dynamically allocated through Pbuf) */ Param param; Pbuf pbuf; MD_Int id_atomparam, id_bondparam, id_angleparam, id_dihedparam, id_imprparam, id_nbfixparam; /* topology file and buffer space */ /* (in this case, space is statically allocated and assigned to Tbuf) */ Topo topo; Tbuf tbuf; MD_Atom atom[TBUFLEN]; MD_Bond bond[TBUFLEN]; MD_Angle angle[TBUFLEN]; MD_Dihed dihed[TBUFLEN]; MD_Impr impr[TBUFLEN]; MD_Excl excl[TBUFLEN]; MD_Int id_atom, id_bond, id_angle, id_dihed, id_impr, id_excl; /* trajectory file and buffer space */ /* (in this case, buffer dvecbuf is provided directly to library calls) */ Pdb pdb; Binres binres; MD_Dvec dvecbuf[ARRAYLEN]; MD_Int id_pos, id_vel; /* callback info that doesn't change */ CallbackInfo cbinfo; } SimFront; /* prototypes */ int init(SimFront *sf, int argc, char **argv); void cleanup(SimFront *sf); void terminate(SimFront *sf, const char *msg, const char *file, int line); void errmsg(SimFront *sf, const char *msg, const char *file, int line); void warning(SimFront *sf, const char *fmt, ...); int setup_config(SimFront *sf); int setup_params(SimFront *sf); int setup_topology(SimFront *sf); int setup_trajectory(SimFront *sf); int setup_callbacks(SimFront *sf); int run_simulation(SimFront *sf); #ifdef __cplusplus } #endif #endif /* SIMFRONT_H */