00001
00009 #ifndef HAMOLMECH_H
00010 #define HAMOLMECH_H
00011
00012 #include "hastl.h"
00013 #include "hastring.h"
00014 #include "command.h"
00015 #include "hacompmod.h"
00016 #include "halinalg.h"
00017 #include "vec3d.h"
00018 #include "haatom.h"
00019
00020 #define AMBER_INT 1
00021
00022 class HaMolMechMod;
00023 class AtomList;
00024 class HaField3D;
00025
00026 enum SET_METHOD { NOT_SET = 0, SET_DEFAULT = 1, SET_FF_FIELD = 2, SET_RES_TEMPL = 3, SET_SPEC = 4 };
00027
00029 class MMBond
00030 {
00031 public:
00032 MMBond();
00033 MMBond(MatPoint* new_pt1, MatPoint* new_pt2);
00034 ~MMBond();
00035
00036 bool operator==(const MMBond& rhs) const;
00037 bool operator< (const MMBond& rhs) const;
00038
00039 double r0;
00040 double fc;
00041
00042 int set_type;
00043
00044 public:
00045 MatPoint* pt1;
00046 MatPoint* pt2;
00047
00048 };
00049
00051 class MMNonBndParam
00052 {
00053 public:
00054 MMNonBndParam() {}
00055 virtual ~MMNonBndParam() {}
00056
00057 double cn_6;
00058 double cn_12;
00059
00060 bool operator == (const MMNonBndParam& rhs) const;
00061 bool operator < (const MMNonBndParam& rhs) const;
00062
00063 };
00064
00065
00067 class MMValAngle
00068 {
00069 public:
00070 MMValAngle();
00071 MMValAngle(MatPoint* new_pt1, MatPoint* new_pt2,
00072 MatPoint* new_pt3);
00073 ~MMValAngle();
00074
00075 public:
00076 MatPoint* pt1;
00077 MatPoint* pt2;
00078 MatPoint* pt3;
00079
00080 double a0;
00081 double fc;
00082
00083 int set_type;
00084
00085 bool operator == (const MMValAngle& rhs) const;
00086 bool operator < (const MMValAngle& rhs) const;
00087 };
00088
00089
00091 class MMDihedral
00092 {
00093 public:
00094 MMDihedral();
00095 MMDihedral(MatPoint* new_pt1, MatPoint* new_pt2,
00096 MatPoint* new_pt3, MatPoint* new_pt4, bool improper_flag = false);
00097 virtual ~MMDihedral();
00098
00099 public:
00100 bool improper;
00101 bool calc_14;
00102
00103 MatPoint* pt1;
00104 MatPoint* pt2;
00105 MatPoint* pt3;
00106 MatPoint* pt4;
00107
00108 int set_type;
00109
00110
00111
00112
00113 int GetNTerms() const { return pk.size(); }
00114 void ClearParams() { pn.clear(); phase.clear(); pk.clear(); idivf.clear(); }
00115
00116 vector<double> pn;
00117 vector<double> phase;
00118 vector<double> pk;
00119 vector<double> idivf;
00120
00121 int AddTerm( double pn_new, double phase_new, double pk_new, double idivf_new = 1.0 );
00122
00123 bool operator == (const MMDihedral& rhs) const;
00124 bool operator < (const MMDihedral& rhs) const;
00125
00126 };
00127
00128 typedef set<MatPoint*, less<MatPoint*> > SetMatPt;
00129
00130
00131 const int MD_RUN = 0, MIN_RUN = 1, ENER_RUN = 2;
00132 const int NO_NMR_RESTRAIN = 0, READ_NMR_RESTRAIN=1,
00133 NOESY_NMR_RESTRAIN = 2;
00134 const int CONJ_GRAD = 0, STEEPEST_DESCENT = 2;
00135 const int NO_PERIODICITY = 0, CONST_VOL = 1, CONST_PRES = 2;
00136 const int NO_BORN = 0, PAIR_GEN_BORN = 1, VACUUM = 2, DIST_DEPEND_DIEL = 3;
00137 const int WRT_FORM = 0, WRT_BIN = 1;
00138 const int READ_X_FORM = 1, READ_X_BIN =2, READ_XV_BIN = 4,
00139 READ_XV_FORM = 5, READ_XVBOX_BIN=6, READ_XVBOX_FORM = 7;
00140 const int NO_RESTART=0, DO_RESTART=1;
00141 const int RESTRAINT_BIN=0, RESTRAINT_FORM =1;
00142 const int WRITE_X_BIN = 0, WRITE_X_FORM = 1;
00143 const int CALC_ALL_INTER = 1, OMIT_BONDS_H = 2, OMIT_BONDS = 3 ,
00144 OMIT_BONDS_VANG_H = 4, OMITS_BONDS_VANG = 5,
00145 OMIT_BONDS_VANG_DIH_H = 6, OMIT_BONDS_VANG_DIH = 7;
00146 const int WATER_PAIRLIST_OXYGEN = 0, WATER_PAIRLIST_ATOMS = 86;
00147 const int DIST_DEP_DIEL = 0, CONST_DIEL = 1, GEN_BORN = 2;
00148 const int NO_SOFT_REPULSION = 0, SOFT_REPULSION_NO_HBOND = 1,
00149 SOFT_REPULSION_ALL = 2;
00150 const int NO_POLAR = 0, ATOM_POLAR = 1, T3BODY_POLAR = 2;
00151 const int MAXWELL_START_VEL = 3, READ_START_VEL = 4;
00152 const int CONST_ENE_MD = 0, CONST_TEMP_UNIFORM = 1,
00153 CONST_TEMP_SOLUTE = 2, CONST_TEMP_THRESH = 3,
00154 CONST_TEMP_QUICK_RESCALE = 4, CONST_TEMP_SOLUTE_SOLV = 5,
00155 CONST_TEMP_MAXWELL = -1;
00156 const int NO_CONST_P=0, ISOTROP_CONST_P=1, ANISOTROP_CONST_P=2;
00157 const int ATOM_PRESS_SCALE = 0, MOL_PRESS_SCALE=1;
00158 const int NO_SHAKE = 1, H_ATOM_SHAKE=2, ALL_ATOM_SHAKE=3;
00159 const int NORMAL_FAST_WATER = 0, REDEF_WATER_NAMES = 1, ONLY_SHAKE_FAST_WATER = 2,
00160 ONLY_SHAKE_FAST_WATER_REDEF_NAMES = 3, NO_FAST_WATER = 4;
00161 const int NMR_ABS_VAL_ERR = 1, NMR_SQ_SUM_ERR = 2, NMR_NOESY_PENALTY = 3;
00162
00163 const int CALC_VDW_NO = 0, CALC_VDW_NORMAL = 1, CALC_VDW_NO_ATTRACT = 2;
00164
00165 class CWinThread;
00166
00167 const int SCRIPT_CONTINUE = 0;
00168 const int SCRIPT_START = 1;
00169 const int SCRIPT_STOP = 2;
00170
00171
00172
00173
00176 class HaMolMechMod : public HaCompMod
00177 {
00178 public:
00180
00181 HaMolMechMod(HaMolSet* new_pmset=NULL);
00182 ~HaMolMechMod();
00183
00184 int SetStdParams();
00185 int Initialize();
00186
00187 int SetStdValParams();
00188 int SetStdVdWParams();
00189
00190 vector<SetMatPt> excluded_atom_list;
00191 vector<SetMatPt> nonbond_contact_list;
00192
00193 bool BuildExcludedAtomList();
00194 bool BuildNonBondContactList();
00195
00196 bool BuildGrpGrpNonBondList(AtomList* group1, AtomList* group2);
00197
00198 virtual int OnDelAtoms(AtomCollection& del_atoms);
00199 bool DeletePoints( set< MatPoint*, less<MatPoint*> > *pt_set);
00200 bool Print_info(ostream& sout, const int level);
00201
00202 vector<MatPoint*> Points;
00203 set<MMBond, less<MMBond> > MBonds;
00204 set<MMValAngle, less<MMValAngle> > ValAngles;
00205 vector<MMDihedral> Dihedrals;
00206 vector<MMDihedral> ImprDihedrals;
00207 vector<MMBond> BondConstrains;
00208
00209 MMBond* GetMMBond(MatPoint* pt1, MatPoint* pt2);
00210 MMValAngle* GetValAngle(MatPoint* pt1, MatPoint* pt2, MatPoint* pt3);
00211 MMDihedral* GetDihedral(MatPoint* pt1, MatPoint* pt2, MatPoint* pt3,MatPoint* pt4);
00212 MMDihedral* GetImprDihedral(MatPoint* pt1, MatPoint* pt2, MatPoint* pt3, MatPoint* pt4);
00213
00215 multimap<unsigned long, unsigned long, less<unsigned long> > res_impr_dih_map;
00216
00217 typedef vector<MatPoint*> POINTS_TYPE;
00218
00219 list<MMNonBndParam> HBondParams;
00220
00221
00223
00224 static StrVecMap symb_ppar_map;
00225 static StrVecMap bond_param_map;
00226 static StrVecMap vang_param_map;
00227 static StrVecMap dih_param_map;
00228 static StrVecMap impdih_param_map;
00229
00230 static HaVec_double FindPointParamFromSymbol( const char* ats1);
00231 static HaVec_double FindBondParamFromSymbol ( const char* ats1,const char* ats2);
00232 static HaVec_double FindValAngleParamFromSymbol( const char* ats1,const char* ats2,const char* ats3);
00233 static HaVec_double FindDihedralParamFromSymbol( const char* ats1,const char* ats2,const char* ats3,const char* ats4, bool improper_flag = false);
00234
00235 static int init_ff_maps;
00236
00237 MMDihedral* AddImprDihedral(MatPoint* pt1, MatPoint* pt2, MatPoint* pt3, MatPoint* pt4);
00238
00239 int SetMMBond(MatPoint* pt1,MatPoint* pt2,double r0,double fc,int set_type = NOT_SET);
00240 int SetValAngle(MatPoint* pt1,MatPoint* pt2,MatPoint* pt3,double a0,double fc,int set_type = NOT_SET);
00241
00242 int GetResImprAngles(HaResidue* pres, list<MMDihedral*>& res_idih_list);
00243
00244
00245
00246 int Set14interDihFlags();
00247
00248
00249
00250
00251
00252 int cur_nstep;
00253 double time;
00254 double temp;
00255 double press;
00256
00257 double cur_energy;
00258
00259 double kin_ene;
00260 double pot_ene;
00261 double bond_ene;
00262 double vang_ene;
00263 double dihed_ene;
00264
00265 double vdw_ene;
00266 double vdw_ene_14;
00267 double vdw_ene_nb;
00268
00269 double electr_ene;
00270 double electr_ene_14;
00271 double electr_ene_nb;
00272 double polar_ene;
00273
00274 double hbond_ene;
00275
00276 double constraint_ene;
00277
00278 double density;
00279
00280 double rms_ene;
00281 double grad_ene_max;
00282
00283 int module_to_init_flag;
00284 int build_nb_contact_list_flag;
00285 int param_to_init_flag;
00286 int init_charges_flag;
00287 int InitParamSet();
00288
00289
00290
00291 HaString amber_run_file;
00292 HaString amber_inp_file;
00293 HaString amber_top_file;
00294 HaString amber_crd_file;
00295
00296 HaString amber_out_file;
00297 HaString amber_rst_file;
00298
00299 HaString amber_trj_coord_file;
00300 HaString amber_trj_vel_file;
00301 HaString amber_trj_ene_file;
00302 HaString amber_constr_crd_file;
00303
00304 FILE* trj_coord_fp;
00305 FILE* trj_vel_fp;
00306 FILE* trj_ene_fp;
00307
00308 int SaveAmberRunFile();
00309 int SaveAmberInpFile();
00310 int SaveAmberTopFile();
00311 int SaveAmberCrdFile();
00312 int SaveAmberAllInpFiles();
00313
00314
00315
00316 int run_internal_flag;
00317 int RunSanderInt();
00318
00319 int LoadAmberRestartFile();
00320 int LoadAmberMDInfoFile();
00321
00322 int RunAmber();
00323 int RunAmberThread();
00324 HaString sander_exe_fname;
00325
00326 int OpenSanderFilesToRead();
00327 int ReadTrajPoint();
00328
00329 HaString traj_script;
00330
00331 long amber_proc_id;
00332
00333 int StopCalc();
00334
00335 CWinThread* run_amber_thread;
00336
00337 int delay_time;
00338 int stop_calc_flag;
00339 int skip_pt_init;
00340 int skip_pt_between;
00341 int play_back_flag;
00342
00343 int CalculateEnergy();
00344
00345 bool CalcNonBondPt(const MatPoint* pt1, const MatPoint* pt2, double& vdw_at_ene, double& el_at_ene);
00347
00349
00350 int time_limit;
00351 int run_type;
00352 int nmr_restrain;
00353
00354 int amber_version;
00355
00356
00357
00358 int init_read_coord;
00359 int restart_flag;
00360 int restraint_format;
00361
00362
00363
00364 int write_coord_format;
00365 int print_freq;
00366 int nbstp_wrt_rstrt;
00367 int nbstp_wrt_coord;
00368 int nbstp_wrt_vel;
00369 int nbstp_wrt_ener;
00370 int traj_wrt_format;
00371 int limit_wrt_atoms;
00372
00373 int wrap_coord;
00374
00375
00376
00377 int omit_interactions;
00378 int period_bcond;
00379 int electr_model;
00380
00381 double scale_14_electr;
00382 double scale_14_vdw;
00383 double nonb_cutoff_dist;
00384
00385
00386 double diel_const;
00387
00388 int nonb_list_flag;
00389 int nonb_list_update_freq;
00390 int water_pairlist_method;
00391 int neutral_end_hydr_flag;
00392
00393 int calc_vdw_flag;
00394 int calc_electr_flag;
00395
00396 int soft_repulsion;
00397 double soft_repulsion_const;
00398
00399
00400 int polar_method;
00401
00402
00403 int num_3body_inter;
00404 int num_ions;
00405
00406
00408 HaVec_int atom2_3body;
00409 HaVec_int atom3_3body;
00410 HaVec_double pexp_3body;
00411 HaVec_double beta_3body;
00412 HaVec_double gamma_3body;
00413
00414
00415
00416 double atom_restr_const;
00417
00418 int SetMoveOnly( const HaString& new_mov_atom_list_name);
00419 int SetMoveAll();
00420
00421 AtomList* GetMovingAtoms();
00422
00423 HaString moving_atoms;
00424
00425 int SetRestrainedAtoms( const char* restr_atom_list_name);
00426 AtomList* GetRestrAtoms();
00427 HaString restrained_atoms;
00428
00429 bool SetHBondConstraints(double force_const);
00430 int AddHarmConstraint(HaAtom* atom1,HaAtom* atom2, double eq_dist, double force_const);
00431 bool ClearConstraints();
00432
00433
00434
00435 int min_type;
00436
00437 int max_comp_cycles;
00438 int num_step_steep_descent;
00439
00440 double init_min_step;
00441 double max_min_step;
00442 double min_cnvrg_criterium;
00443
00444
00445
00446 int num_md_run;
00447 int length_md_run;
00448 int num_dfreedom_sub;
00449
00450 int remove_init_motion_flag;
00451
00452
00453 int remove_motion_freq;
00454
00455
00456 int start_vel_method;
00457 double start_time;
00458 double md_time_step;
00459
00460
00461
00462 double ref_temp;
00463 double init_temp;
00464 int random_seed;
00465 double scale_init_vel;
00466 int temp_scale_method;
00467
00468
00469 int last_solute_atom;
00470 double temp_deviation;
00471 double temp_relax_time_solute;
00472 double temp_relax_time_solvent;
00473 double vel_limit;
00474
00475
00476
00477 double peaks_rate;
00478 double peaks_coupling;
00479 double peaks_init_pot;
00480
00481
00482
00483 int pressure_reg_method;
00484 double ref_pressure;
00485 double compressibility;
00486 double pressure_relax_time;
00487 int pressure_scale_method;
00488
00489
00490
00491 int shake_constr;
00492 double shake_tol;
00493
00494
00495
00496
00497 int solute_solvent_image_flag;
00498
00499
00500 int remove_solute_nb_cut_flag;
00501
00502 int fast_water_method;
00503
00504
00505 HaString wat_res_name;
00506 HaString wat_ox_name;
00507 HaString wat_h1_name;
00508 HaString wat_h2_name;
00509
00510
00511
00512 int water_cap_flag;
00513 int cap_atom_num;
00514 double cap_fconst;
00515
00516
00517
00518
00519 int noesy_vol_freq;
00520
00521
00522 int nmr_penalty_min_method;
00523
00524 int nmr_max_num_submol;
00525
00526
00527
00528
00529 int pmesh_ewald_flag;
00530 double pme_box_x;
00531 double pme_box_y;
00532 double pme_box_z;
00533 double pme_box_alpha;
00534 double pme_box_beta;
00535 double pme_box_gamma;
00536
00537 int pme_grid_nx;
00538 int pme_grid_ny;
00539 int pme_grid_nz;
00540
00541 int pme_spline_order;
00542 int pme_neutralize_system;
00543 int pme_verbose;
00544 int exact_ewald_flag;
00545 double pme_dsum_tol;
00546
00547 protected:
00548
00549 };
00550
00551
00552 #if defined(AMBER_INT)
00553 extern "C" {
00554 void sandermn_(doublereal* x,integer* ix, integer* ih,
00555 integer* ipairs, doublereal* r_stack, integer* i_stack);
00556
00557 typedef struct{
00558 char mdin[80], mdout[80], inpcrd[80], parm[80], restrt[80],
00559 refc[80], mdvel[80], mden[80], mdcrd[80], mdinfo[80],
00560 nmr[80], mincor[80], vecs[80], radii[80], freqe[80], owrite[80],
00561 rstdip[80], mddip[80], inpdip[80];
00562 } files_type;
00563
00564 extern files_type files_;
00565
00566 };
00567 #endif
00568
00569 #endif // end if !defined(HAMOLMECH_H)
00570