00001
00007
00008
00009
00010
00011
00012
00013 #ifndef PARAM_H
00014
00015 #define PARAM_H
00016
00017 #include "parm.h"
00018
00019 #include "common.h"
00020 #include "structures.h"
00021 #include "strlib.h"
00022 #include "MStream.h"
00023
00024 #include "SimParameters.h"
00025
00026
00027 #include "GromacsTopFile.h"
00028
00029 class Communicate;
00030 class StringList;
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063 #define MAX_MULTIPLICITY 6
00064
00065
00066 #define MAX_ATOMTYPE_CHARS 6
00067
00068
00069
00070
00071 #define paraXplor 0
00072 #define paraCharmm 1
00073
00074
00075
00076 class BondValue {
00077 public:
00078 Real k;
00079 Real x0;
00080 };
00081
00082 class AngleValue {
00083 public:
00084 Real k;
00085 Real theta0;
00086 Real k_ub;
00087 Real r_ub;
00088 int normal;
00089 };
00090
00091 typedef struct four_body_consts
00092 {
00093 Real k;
00094 int n;
00095 Real delta;
00096 } FourBodyConsts;
00097
00098 class DihedralValue {
00099 public:
00100 int multiplicity;
00101 FourBodyConsts values[MAX_MULTIPLICITY];
00102 };
00103
00104 class ImproperValue {
00105 public:
00106 int multiplicity;
00107 FourBodyConsts values[MAX_MULTIPLICITY];
00108 };
00109
00110 struct CrosstermData { BigReal d00,d01,d10,d11; };
00111
00112 class CrosstermValue {
00113 public:
00114 enum {dim=25};
00115 CrosstermData c[dim][dim];
00116 };
00117
00118 class NonbondedExclValue {
00119 public:
00120
00121
00122 Real k;
00123 Real x0;
00124 };
00125
00126 typedef struct vdw_val
00127 {
00128 Real sigma;
00129 Real epsilon;
00130 Real sigma14;
00131 Real epsilon14;
00132 } VdwValue;
00133
00134
00135
00136
00137
00138 typedef struct indexed_vdw_pair
00139 {
00140 Index ind1;
00141 Index ind2;
00142 Real A;
00143 Real A14;
00144 Real B;
00145 Real B14;
00146 struct indexed_vdw_pair *right;
00147 struct indexed_vdw_pair *left;
00148 } IndexedVdwPair;
00149
00150
00151 struct bond_params;
00152 struct angle_params;
00153 struct improper_params;
00154 struct dihedral_params;
00155 struct crossterm_params;
00156 struct vdw_params;
00157 struct vdw_pair_params;
00158
00159 class Parameters
00160 {
00161 private:
00162 void initialize();
00163
00164 char *atomTypeNames;
00165 Bool AllFilesRead;
00166
00167
00168
00169
00170
00171 int paramType;
00172
00173 bool cosAngles;
00174 struct bond_params *bondp;
00175 struct angle_params *anglep;
00176 struct improper_params *improperp;
00177 struct dihedral_params *dihedralp;
00178 struct crossterm_params *crosstermp;
00179 struct vdw_params *vdwp;
00180 struct vdw_pair_params *vdw_pairp;
00181 public:
00182 BondValue *bond_array;
00183 AngleValue *angle_array;
00184 DihedralValue *dihedral_array;
00185 ImproperValue *improper_array;
00186 CrosstermValue *crossterm_array;
00187 VdwValue *vdw_array;
00188 IndexedVdwPair *vdw_pair_tree;
00189 int NumBondParams;
00190 int NumAngleParams;
00191 int NumCosAngles;
00192 int NumDihedralParams;
00193 int NumImproperParams;
00194 int NumCrosstermParams;
00195 private:
00196 int NumVdwParams;
00197 int NumVdwParamsAssigned;
00198 int NumVdwPairParams;
00199 ResizeArray<char *> error_msgs;
00200
00201 int *maxDihedralMults;
00202
00203 int *maxImproperMults;
00204
00205
00206 void skip_stream_read(char *, FILE *);
00207
00208 void add_bond_param(char *);
00209 struct bond_params *add_to_bond_tree(struct bond_params * ,
00210 struct bond_params *);
00211
00212 void add_angle_param(char *);
00213 struct angle_params *add_to_angle_tree(struct angle_params * ,
00214 struct angle_params *);
00215
00216 void add_dihedral_param(char *, FILE *);
00217 void add_to_dihedral_list(struct dihedral_params *);
00218 void add_to_charmm_dihedral_list(struct dihedral_params *);
00219
00220 void add_improper_param(char *, FILE *);
00221 void add_to_improper_list(struct improper_params *);
00222
00223 void add_crossterm_param(char *, FILE *);
00224 void add_to_crossterm_list(struct crossterm_params *);
00225
00226 void add_vdw_param(char *);
00227 struct vdw_params *add_to_vdw_tree(struct vdw_params *,
00228 struct vdw_params *);
00229
00230 void add_vdw_pair_param(char *);
00231 void add_to_vdw_pair_list(struct vdw_pair_params *);
00232
00233 void add_hb_pair_param(char *);
00234
00235
00236
00237 void traverse_vdw_pair_params(struct vdw_pair_params *);
00238 void traverse_vdw_params(struct vdw_params *);
00239 void traverse_dihedral_params(struct dihedral_params *);
00240 void traverse_improper_params(struct improper_params *);
00241 void traverse_crossterm_params(struct crossterm_params *);
00242 void traverse_angle_params(struct angle_params *);
00243 void traverse_bond_params(struct bond_params *);
00244
00245
00246
00247
00248 Index index_bonds(struct bond_params *, Index);
00249 Index index_angles(struct angle_params *, Index);
00250 Index index_vdw(struct vdw_params *, Index);
00251 void index_dihedrals();
00252 void index_impropers();
00253 void index_crossterms();
00254
00255 void convert_vdw_pairs();
00256 IndexedVdwPair *add_to_indexed_vdw_pairs(IndexedVdwPair *, IndexedVdwPair *);
00257
00258 int vdw_pair_to_arrays(int *, int *, Real *, Real *, Real *, Real *,
00259 int, IndexedVdwPair *);
00260
00261
00262
00263 void free_bond_tree(struct bond_params *);
00264 void free_angle_tree(struct angle_params *);
00265 void free_dihedral_list(struct dihedral_params *);
00266 void free_improper_list(struct improper_params *);
00267 void free_crossterm_list(struct crossterm_params *);
00268 void free_vdw_tree(struct vdw_params *);
00269 void free_vdw_pair_tree(IndexedVdwPair *);
00270 void free_vdw_pair_list();
00271
00272
00273
00274 void read_parm(const GromacsTopFile *, Bool min);
00275 public:
00276
00278 Parameters();
00279 Parameters(SimParameters *, StringList *f);
00280
00281
00282 Parameters(Ambertoppar *, BigReal);
00283 void read_parm(Ambertoppar *, BigReal);
00284
00285
00286
00287
00288
00289
00290 Parameters(const GromacsTopFile *gf, Bool min);
00291
00292 ~Parameters();
00293
00294
00295
00296
00297
00298 char *atom_type_name(Index a) {
00299 return (atomTypeNames + (a * (MAX_ATOMTYPE_CHARS + 1)));
00300 }
00301
00302
00303 void read_parameter_file(char *);
00304
00305
00306 void read_charmm_parameter_file(char *);
00307
00308
00309
00310
00311 void done_reading_files();
00312
00313
00314
00315 void done_reading_structure();
00316
00317
00318
00319
00320
00321 #ifdef MEM_OPT_VERSION
00322 void assign_vdw_index(char *, AtomCstInfo *);
00323 #else
00324 void assign_vdw_index(char *, Atom *);
00325 #endif
00326
00327 void assign_bond_index(char *, char *, Bond *);
00328
00329
00330 void assign_angle_index(char *, char *, char *, Angle *);
00331
00332
00333 void assign_dihedral_index(char *, char*, char*, char *, Dihedral *, int);
00334
00335
00336 void assign_improper_index(char *, char*, char*, char *, Improper *, int);
00337
00338
00339 void assign_crossterm_index(char *, char*, char*, char *, char *, char*, char*, char *, Crossterm *);
00340
00341
00342
00343 void send_Parameters(Communicate *);
00344
00345
00346
00347 void receive_Parameters(MIStream *);
00348
00349
00350
00351
00352 void get_bond_params(Real *k, Real *x0, Index index)
00353 {
00354 *k = bond_array[index].k;
00355 *x0 = bond_array[index].x0;
00356 }
00357
00358 void get_angle_params(Real *k, Real *theta0, Real *k_ub, Real *r_ub,
00359 Index index)
00360 {
00361 *k = angle_array[index].k;
00362 *theta0 = angle_array[index].theta0;
00363 *k_ub = angle_array[index].k_ub;
00364 *r_ub = angle_array[index].r_ub;
00365 }
00366
00367 int get_improper_multiplicity(Index index)
00368 {
00369 return(improper_array[index].multiplicity);
00370 }
00371
00372 int get_dihedral_multiplicity(Index index)
00373 {
00374 return(dihedral_array[index].multiplicity);
00375 }
00376
00377 void get_improper_params(Real *k, int *n, Real *delta,
00378 Index index, int mult)
00379 {
00380 if ( (mult<0) || (mult>MAX_MULTIPLICITY) )
00381 {
00382 NAMD_die("Bad mult index in Parameters::get_improper_params");
00383 }
00384
00385 *k = improper_array[index].values[mult].k;
00386 *n = improper_array[index].values[mult].n;
00387 *delta = improper_array[index].values[mult].delta;
00388 }
00389
00390 void get_dihedral_params(Real *k, int *n, Real *delta,
00391 Index index, int mult)
00392 {
00393 if ( (mult<0) || (mult>MAX_MULTIPLICITY) )
00394 {
00395 NAMD_die("Bad mult index in Parameters::get_dihedral_params");
00396 }
00397
00398 *k = dihedral_array[index].values[mult].k;
00399 *n = dihedral_array[index].values[mult].n;
00400 *delta = dihedral_array[index].values[mult].delta;
00401 }
00402
00403 void get_vdw_params(Real *sigma, Real *epsilon, Real *sigma14,
00404 Real *epsilon14, Index index)
00405 {
00406 if ( vdw_array ) {
00407 *sigma = vdw_array[index].sigma;
00408 *epsilon = vdw_array[index].epsilon;
00409 *sigma14 = vdw_array[index].sigma14;
00410 *epsilon14 = vdw_array[index].epsilon14;
00411 } else {
00412 *sigma = 0.;
00413 *epsilon = 0.;
00414 *sigma14 = 0.;
00415 *epsilon14 = 0.;
00416 }
00417 }
00418
00419 int get_vdw_pair_params(Index ind1, Index ind2, Real *, Real *, Real *, Real *);
00420
00421
00422 int get_num_vdw_params(void) { return NumVdwParamsAssigned; }
00423
00424
00425 void print_bond_params();
00426 void print_angle_params();
00427 void print_dihedral_params();
00428 void print_improper_params();
00429 void print_crossterm_params();
00430 void print_vdw_params();
00431 void print_vdw_pair_params();
00432 void print_param_summary();
00433 };
00434
00435 #endif
00436