00001
00002
00003
00004
00072 #ifndef FORCE_H
00073 #define FORCE_H
00074
00075 #include "mdapi/mdtypes.h"
00076
00077 #ifdef __cplusplus
00078 extern "C" {
00079 #endif
00080
00107 typedef struct ForceParam_tag {
00108
00109 MD_AtomPrm *atomprm;
00110 MD_BondPrm *bondprm;
00111 MD_AnglePrm *angleprm;
00112 MD_TorsPrm *dihedprm;
00113 MD_TorsPrm *imprprm;
00114 MD_NbfixPrm *nbfixprm;
00116 int32 atomprm_len;
00117 int32 bondprm_len;
00118 int32 angleprm_len;
00119 int32 dihedprm_len;
00120 int32 imprprm_len;
00121 int32 nbfixprm_len;
00123
00124 MD_Atom *atom;
00125 MD_Bond *bond;
00126 MD_Angle *angle;
00127 MD_Tors *dihed;
00128 MD_Tors *impr;
00129 MD_Excl *excl;
00130 int32 atom_len;
00132 int32 bond_len;
00133 int32 angle_len;
00134 int32 dihed_len;
00135 int32 impr_len;
00136 int32 excl_len;
00138
00139 double xlen;
00140 double ylen;
00141 double zlen;
00142 MD_Dvec center;
00144
00145 double radius1;
00147 double radius2;
00149 double length1;
00152 double length2;
00155 double konst1;
00156 double konst2;
00157 int32 exp1;
00159 int32 exp2;
00162
00163 double cutoff;
00165 double elec_cutoff;
00166 double vdw_cutoff;
00167 double switchdist;
00169 double elec_const;
00172 double dielectric;
00174 double scaling14;
00179
00180 int32 flags;
00182 } ForceParam;
00183
00184
00210 enum ForceFlags_tag {
00211
00212 FORCE_BOND = 0x000001,
00214 FORCE_ANGLE = 0x000002,
00216 FORCE_DIHED = 0x000004,
00218 FORCE_IMPR = 0x000008,
00220 FORCE_ELEC = 0x000010,
00222 FORCE_VDW = 0x000020,
00224 FORCE_BONDED = FORCE_BOND | FORCE_ANGLE | FORCE_DIHED | FORCE_IMPR,
00226 FORCE_NONBONDED = FORCE_ELEC | FORCE_VDW,
00228 FORCE_ALL = FORCE_BONDED | FORCE_NONBONDED,
00231 FORCE_ELEC_DIRECT = 0x000040,
00233 FORCE_VDW_DIRECT = 0x000080,
00235 FORCE_DIRECT = FORCE_ELEC_DIRECT | FORCE_VDW_DIRECT,
00238 FORCE_MASK_TYPE = 0x0000FF,
00241
00242 FORCE_NONPERIODIC = 0x000000,
00244 FORCE_X_PERIODIC = 0x000100,
00246 FORCE_Y_PERIODIC = 0x000200,
00248 FORCE_Z_PERIODIC = 0x000400,
00250 FORCE_PERIODIC = FORCE_X_PERIODIC | FORCE_Y_PERIODIC | FORCE_Z_PERIODIC,
00252 FORCE_MASK_PERIOD = 0x000F00,
00255
00256 FORCE_SPHERE = 0x001000,
00258 FORCE_X_CYLINDER = 0x002000,
00261 FORCE_Y_CYLINDER = 0x004000,
00264 FORCE_Z_CYLINDER = 0x008000,
00267 FORCE_MASK_BC = 0x00F000,
00270
00271 FORCE_EXCL_NONE = 0x000000,
00274 FORCE_EXCL_12 = 0x010000,
00276 FORCE_EXCL_13 = 0x020000,
00279 FORCE_EXCL_14 = 0x030000,
00282 FORCE_EXCL_SCAL14 = 0x040000,
00286 FORCE_MASK_EXCL = 0x0F0000,
00289
00290 FORCE_SMOOTH = 0x100000,
00293 FORCE_SWITCH = 0x200000,
00297 FORCE_CONTINUOUS = FORCE_SMOOTH | FORCE_SWITCH,
00300 FORCE_ELEC_EXCL = 0x400000,
00303 FORCE_VDW_EXCL = 0x800000,
00306 FORCE_EXCL = FORCE_ELEC_EXCL | FORCE_VDW_EXCL,
00309 FORCE_MASK_CUTOFF = 0xF00000,
00312 FORCE_MD_VACUUM = FORCE_ALL | FORCE_EXCL_SCAL14 | FORCE_CONTINUOUS,
00316 FORCE_MD_CELL = FORCE_MD_VACUUM | FORCE_PERIODIC
00319 };
00320
00321
00322 enum {
00323 FORCE_FAIL = -1
00324 };
00325
00326
00335 typedef struct ForceEnergy_tag {
00336 double pe;
00337 double bond;
00338 double angle;
00339 double dihed;
00340 double impr;
00341 double elec;
00342 double vdw;
00343 double bound;
00344 } ForceEnergy;
00345
00346
00363 typedef struct ForceResult_tag {
00364 MD_Dvec *f;
00365 MD_Dvec *f_bond;
00366 MD_Dvec *f_angle;
00367 MD_Dvec *f_dihed;
00368 MD_Dvec *f_impr;
00369 MD_Dvec *f_elec;
00370 MD_Dvec *f_vdw;
00371 MD_Dvec *f_bound;
00372 } ForceResult;
00373
00374
00377 typedef struct ForceCell_tag {
00378
00379 int32 head;
00380 int32 cnt;
00381 int32 nnbrs;
00382 int32 nbr[14];
00383 MD_Dvec offset[14];
00384 } ForceCell;
00385
00386
00391 typedef struct Force_tag {
00392 ForceParam *param;
00393 ForceEnergy *energy;
00394 ForceResult *result;
00395
00396 double elec_const;
00397 double inv_elec_cutoff2;
00398 double switchdist2;
00399 double inv_denom_switch;
00400 double elec_cutoff2;
00401 double vdw_cutoff2;
00402
00403 double *vdwtable;
00404
00405 MD_Dvec lo;
00406 double inv_cutoff;
00407 double inv_xcellsize;
00408 double inv_ycellsize;
00409 double inv_zcellsize;
00410
00411 MD_Dvec *wrap;
00412
00413 int32 *next;
00414 ForceCell *cell;
00415 int32 ncells;
00416 int32 nxcells;
00417 int32 nycells;
00418 int32 nzcells;
00419 int32 is_resize;
00420 int32 is_xresize;
00421 int32 is_yresize;
00422 int32 is_zresize;
00423
00424
00425 int32 **excl_list;
00426 int32 **scaled14_list;
00427
00428
00429 int32 **exclx;
00430 int32 **excl12;
00431 int32 **excl13;
00432 int32 **excl14;
00433 int32 **scaled14;
00434 int32 *lenx;
00435 int32 *len12;
00436 int32 *len13;
00437 int32 *accum;
00438 int32 *dest;
00439
00440
00441 int32 is_bcterm1;
00442 int32 is_bcterm2;
00443 double sq_minradius;
00444 double minlength;
00445
00446 } Force;
00447
00448
00449
00450
00458 int force_init(Force *);
00459
00474 int force_setup(Force *, ForceParam *fp, ForceEnergy *fe, ForceResult *fr);
00475
00496 int force_compute(Force *, const MD_Dvec *pos, MD_Dvec *wrap);
00497
00503 void force_done(Force *);
00504
00505
00506
00507
00517 int32 **force_excl_list(const Force *);
00518
00526 int32 **force_scaled14_list(const Force *);
00527
00528
00529
00530 int force_setup_bonded(Force *);
00531 int force_setup_nonbonded(Force *);
00532 int force_setup_nonbonded_cells(Force *);
00533 int force_setup_boundary(Force *);
00534
00535
00536 int force_compute_bonded(Force *, const MD_Dvec *pos);
00537 int force_compute_nonbonded(Force *, const MD_Dvec *pos, MD_Dvec *wrap);
00538 int force_compute_boundary(Force *, const MD_Dvec *pos, const MD_Dvec *wrap);
00539
00540
00541 #ifdef __cplusplus
00542 }
00543 #endif
00544
00545 #endif