00001
00002
00003
00004
00005
00006
00007
00008
00009
00010 #ifndef COLVARCOMP_H
00011 #define COLVARCOMP_H
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023 #include "colvarmodule.h"
00024 #include "colvar.h"
00025 #include "colvaratoms.h"
00026 #include "colvar_arithmeticpath.h"
00027
00028 #if (__cplusplus >= 201103L)
00029
00030 #include "colvar_geometricpath.h"
00031 #include <memory>
00032 #include <functional>
00033 #endif
00034
00035 #include <map>
00036
00037
00075
00076 class colvar::cvc
00077 : public colvarparse, public colvardeps
00078 {
00079 public:
00080
00083 std::string name;
00084
00093 std::string function_type;
00094
00096 std::string config_key;
00097
00099 cvm::real sup_coeff;
00101 int sup_np;
00102
00104 cvm::real period;
00105
00107 cvm::real wrap_center;
00108
00112 cvc(std::string const &conf);
00113
00115 int set_function_type(std::string const &type);
00116
00120 virtual int init(std::string const &conf);
00121
00123 virtual int init_dependencies();
00124
00128 cvm::atom_group *parse_group(std::string const &conf,
00129 char const *group_key,
00130 bool optional = false);
00131
00133 virtual int init_total_force_params(std::string const &conf);
00134
00136 int setup();
00137
00140 cvc();
00141
00143 virtual ~cvc();
00144
00146 static std::vector<feature *> cvc_features;
00147
00149 virtual const std::vector<feature *> &features() const
00150 {
00151 return cvc_features;
00152 }
00153 virtual std::vector<feature *> &modify_features()
00154 {
00155 return cvc_features;
00156 }
00157 static void delete_features() {
00158 for (size_t i=0; i < cvc_features.size(); i++) {
00159 delete cvc_features[i];
00160 }
00161 cvc_features.clear();
00162 }
00163
00165 virtual std::vector<std::vector<int> > get_atom_lists();
00166
00168 virtual void read_data();
00169
00171 virtual void calc_value() = 0;
00172
00175 virtual void calc_gradients() {}
00176
00178 void calc_fit_gradients();
00179
00181 virtual void debug_gradients();
00182
00185 virtual void collect_gradients(std::vector<int> const &atom_ids, std::vector<cvm::rvector> &atomic_gradients);
00186
00189 virtual void calc_force_invgrads();
00190
00192 virtual void calc_Jacobian_derivative();
00193
00194
00196 colvarvalue const & value() const;
00197
00199 colvarvalue const & total_force() const;
00200
00203 colvarvalue const & Jacobian_derivative() const;
00204
00214 virtual void apply_force(colvarvalue const &cvforce) = 0;
00215
00244 virtual cvm::real dist2(colvarvalue const &x1,
00245 colvarvalue const &x2) const;
00246
00250 virtual colvarvalue dist2_lgrad(colvarvalue const &x1,
00251 colvarvalue const &x2) const;
00252
00256 virtual colvarvalue dist2_rgrad(colvarvalue const &x1,
00257 colvarvalue const &x2) const;
00258
00260 virtual void wrap(colvarvalue &x_unwrapped) const;
00261
00264 std::vector<cvm::atom_group *> atom_groups;
00265
00267 void register_atom_group(cvm::atom_group *ag);
00268
00270 virtual colvarvalue const *get_param_grad(std::string const ¶m_name);
00271
00273 virtual int set_param(std::string const ¶m_name, void const *new_value);
00274
00276 bool b_try_scalable;
00277
00280 inline void set_value(colvarvalue const &new_value) {
00281 x = new_value;
00282 }
00283
00284 protected:
00285
00287 std::vector<std::string> function_types;
00288
00290 colvarvalue x;
00291
00293 colvarvalue x_old;
00294
00299 colvarvalue ft;
00300
00303 colvarvalue jd;
00304
00306 void init_as_distance();
00307
00309 void init_as_angle();
00310
00312 void init_as_periodic_angle();
00313
00315 void init_scalar_boundaries(cvm::real lb, cvm::real ub);
00316
00318 colvarvalue lower_boundary;
00319
00321 colvarvalue upper_boundary;
00322
00324 cvm::real width;
00325 };
00326
00327
00328 inline colvarvalue const & colvar::cvc::value() const
00329 {
00330 return x;
00331 }
00332
00333
00334 inline colvarvalue const & colvar::cvc::total_force() const
00335 {
00336 return ft;
00337 }
00338
00339
00340 inline colvarvalue const & colvar::cvc::Jacobian_derivative() const
00341 {
00342 return jd;
00343 }
00344
00345
00346
00349
00350 class colvar::distance
00351 : public colvar::cvc
00352 {
00353 protected:
00355 cvm::atom_group *group1;
00357 cvm::atom_group *group2;
00359 cvm::rvector dist_v;
00360 public:
00361 distance(std::string const &conf);
00362 distance();
00363 virtual ~distance() {}
00364 virtual void calc_value();
00365 virtual void calc_gradients();
00366 virtual void calc_force_invgrads();
00367 virtual void calc_Jacobian_derivative();
00368 virtual void apply_force(colvarvalue const &force);
00369 virtual cvm::real dist2(colvarvalue const &x1,
00370 colvarvalue const &x2) const;
00371 virtual colvarvalue dist2_lgrad(colvarvalue const &x1,
00372 colvarvalue const &x2) const;
00373 virtual colvarvalue dist2_rgrad(colvarvalue const &x1,
00374 colvarvalue const &x2) const;
00375 };
00376
00377
00378
00379
00380
00381
00382 class colvar::distance_vec
00383 : public colvar::distance
00384 {
00385 public:
00386 distance_vec(std::string const &conf);
00387 distance_vec();
00388 virtual ~distance_vec() {}
00389 virtual void calc_value();
00390 virtual void calc_gradients();
00391 virtual void apply_force(colvarvalue const &force);
00393 virtual cvm::real dist2(colvarvalue const &x1,
00394 colvarvalue const &x2) const;
00396 virtual colvarvalue dist2_lgrad(colvarvalue const &x1,
00397 colvarvalue const &x2) const;
00399 virtual colvarvalue dist2_rgrad(colvarvalue const &x1,
00400 colvarvalue const &x2) const;
00401 };
00402
00403
00404
00408 class colvar::distance_dir
00409 : public colvar::distance
00410 {
00411 public:
00412 distance_dir(std::string const &conf);
00413 distance_dir();
00414 virtual ~distance_dir() {}
00415 virtual void calc_value();
00416 virtual void calc_gradients();
00417 virtual void apply_force(colvarvalue const &force);
00419 virtual cvm::real dist2(colvarvalue const &x1,
00420 colvarvalue const &x2) const;
00422 virtual colvarvalue dist2_lgrad(colvarvalue const &x1,
00423 colvarvalue const &x2) const;
00425 virtual colvarvalue dist2_rgrad(colvarvalue const &x1,
00426 colvarvalue const &x2) const;
00427 };
00428
00429
00430
00433 class colvar::distance_z
00434 : public colvar::cvc
00435 {
00436 protected:
00438 cvm::atom_group *main;
00440 cvm::atom_group *ref1;
00442 cvm::atom_group *ref2;
00444 cvm::rvector axis;
00446 cvm::real axis_norm;
00448 cvm::rvector dist_v;
00450 bool fixed_axis;
00451 public:
00452 distance_z(std::string const &conf);
00453 distance_z();
00454 virtual ~distance_z() {}
00455 virtual void calc_value();
00456 virtual void calc_gradients();
00457 virtual void calc_force_invgrads();
00458 virtual void calc_Jacobian_derivative();
00459 virtual void apply_force(colvarvalue const &force);
00460 virtual cvm::real dist2(colvarvalue const &x1,
00461 colvarvalue const &x2) const;
00462 virtual colvarvalue dist2_lgrad(colvarvalue const &x1,
00463 colvarvalue const &x2) const;
00464 virtual colvarvalue dist2_rgrad(colvarvalue const &x1,
00465 colvarvalue const &x2) const;
00467 virtual void wrap(colvarvalue &x_unwrapped) const;
00468 };
00469
00470
00471
00474 class colvar::distance_xy
00475 : public colvar::distance_z
00476 {
00477 protected:
00479 cvm::rvector dist_v_ortho;
00481 cvm::rvector v12, v13;
00482 public:
00483 distance_xy(std::string const &conf);
00484 distance_xy();
00485 virtual ~distance_xy() {}
00486 virtual void calc_value();
00487 virtual void calc_gradients();
00488 virtual void calc_force_invgrads();
00489 virtual void calc_Jacobian_derivative();
00490 virtual void apply_force(colvarvalue const &force);
00491 virtual cvm::real dist2(colvarvalue const &x1,
00492 colvarvalue const &x2) const;
00493 virtual colvarvalue dist2_lgrad(colvarvalue const &x1,
00494 colvarvalue const &x2) const;
00495 virtual colvarvalue dist2_rgrad(colvarvalue const &x1,
00496 colvarvalue const &x2) const;
00497 };
00498
00499
00502 class colvar::polar_phi
00503 : public colvar::cvc
00504 {
00505 public:
00506 polar_phi(std::string const &conf);
00507 polar_phi();
00508 virtual ~polar_phi() {}
00509 protected:
00510 cvm::atom_group *atoms;
00511 cvm::real r, theta, phi;
00512 public:
00513 virtual void calc_value();
00514 virtual void calc_gradients();
00515 virtual void apply_force(colvarvalue const &force);
00517 virtual cvm::real dist2(colvarvalue const &x1,
00518 colvarvalue const &x2) const;
00520 virtual colvarvalue dist2_lgrad(colvarvalue const &x1,
00521 colvarvalue const &x2) const;
00523 virtual colvarvalue dist2_rgrad(colvarvalue const &x1,
00524 colvarvalue const &x2) const;
00526 virtual void wrap(colvarvalue &x_unwrapped) const;
00527 };
00528
00529
00532 class colvar::polar_theta
00533 : public colvar::cvc
00534 {
00535 public:
00536 polar_theta(std::string const &conf);
00537 polar_theta();
00538 virtual ~polar_theta() {}
00539 protected:
00540 cvm::atom_group *atoms;
00541 cvm::real r, theta, phi;
00542 public:
00543 virtual void calc_value();
00544 virtual void calc_gradients();
00545 virtual void apply_force(colvarvalue const &force);
00547 virtual cvm::real dist2(colvarvalue const &x1,
00548 colvarvalue const &x2) const;
00550 virtual colvarvalue dist2_lgrad(colvarvalue const &x1,
00551 colvarvalue const &x2) const;
00553 virtual colvarvalue dist2_rgrad(colvarvalue const &x1,
00554 colvarvalue const &x2) const;
00555 };
00556
00559 class colvar::distance_inv
00560 : public colvar::cvc
00561 {
00562 protected:
00564 cvm::atom_group *group1;
00566 cvm::atom_group *group2;
00568 int exponent;
00569 public:
00570 distance_inv(std::string const &conf);
00571 virtual ~distance_inv() {}
00572 virtual void calc_value();
00573 virtual void calc_gradients();
00574 virtual void apply_force(colvarvalue const &force);
00575 virtual cvm::real dist2(colvarvalue const &x1,
00576 colvarvalue const &x2) const;
00577 virtual colvarvalue dist2_lgrad(colvarvalue const &x1,
00578 colvarvalue const &x2) const;
00579 virtual colvarvalue dist2_rgrad(colvarvalue const &x1,
00580 colvarvalue const &x2) const;
00581 };
00582
00583
00584
00587 class colvar::distance_pairs
00588 : public colvar::cvc
00589 {
00590 protected:
00592 cvm::atom_group *group1;
00594 cvm::atom_group *group2;
00595 public:
00596 distance_pairs(std::string const &conf);
00597 distance_pairs();
00598 virtual ~distance_pairs() {}
00599 virtual void calc_value();
00600 virtual void calc_gradients();
00601 virtual void apply_force(colvarvalue const &force);
00602 };
00603
00604
00605
00607 class colvar::dipole_magnitude
00608 : public colvar::cvc
00609 {
00610 protected:
00612 cvm::atom_group *atoms;
00613 cvm::atom_pos dipoleV;
00614 public:
00616 dipole_magnitude (std::string const &conf);
00617 dipole_magnitude (cvm::atom const &a1);
00618 dipole_magnitude();
00619 virtual inline ~dipole_magnitude() {}
00620 virtual void calc_value();
00621 virtual void calc_gradients();
00622
00623
00624 virtual void apply_force (colvarvalue const &force);
00625 virtual cvm::real dist2 (colvarvalue const &x1,
00626 colvarvalue const &x2) const;
00627 virtual colvarvalue dist2_lgrad (colvarvalue const &x1,
00628 colvarvalue const &x2) const;
00629 virtual colvarvalue dist2_rgrad (colvarvalue const &x1,
00630 colvarvalue const &x2) const;
00631 };
00632
00633
00634
00637 class colvar::gyration
00638 : public colvar::cvc
00639 {
00640 protected:
00642 cvm::atom_group *atoms;
00643 public:
00644 gyration(std::string const &conf);
00645 virtual ~gyration() {}
00646 virtual void calc_value();
00647 virtual void calc_gradients();
00648 virtual void calc_force_invgrads();
00649 virtual void calc_Jacobian_derivative();
00650 virtual void apply_force(colvarvalue const &force);
00651 virtual cvm::real dist2(colvarvalue const &x1,
00652 colvarvalue const &x2) const;
00653 virtual colvarvalue dist2_lgrad(colvarvalue const &x1,
00654 colvarvalue const &x2) const;
00655 virtual colvarvalue dist2_rgrad(colvarvalue const &x1,
00656 colvarvalue const &x2) const;
00657 };
00658
00659
00660
00663 class colvar::inertia
00664 : public colvar::gyration
00665 {
00666 public:
00668 inertia(std::string const &conf);
00669 inertia();
00670 virtual ~inertia() {}
00671 virtual void calc_value();
00672 virtual void calc_gradients();
00673 virtual void apply_force(colvarvalue const &force);
00674 virtual cvm::real dist2(colvarvalue const &x1,
00675 colvarvalue const &x2) const;
00676 virtual colvarvalue dist2_lgrad(colvarvalue const &x1,
00677 colvarvalue const &x2) const;
00678 virtual colvarvalue dist2_rgrad(colvarvalue const &x1,
00679 colvarvalue const &x2) const;
00680 };
00681
00682
00683
00686 class colvar::inertia_z
00687 : public colvar::inertia
00688 {
00689 protected:
00691 cvm::rvector axis;
00692 public:
00694 inertia_z(std::string const &conf);
00695 inertia_z();
00696 virtual ~inertia_z() {}
00697 virtual void calc_value();
00698 virtual void calc_gradients();
00699 virtual void apply_force(colvarvalue const &force);
00700 virtual cvm::real dist2(colvarvalue const &x1,
00701 colvarvalue const &x2) const;
00702 virtual colvarvalue dist2_lgrad(colvarvalue const &x1,
00703 colvarvalue const &x2) const;
00704 virtual colvarvalue dist2_rgrad(colvarvalue const &x1,
00705 colvarvalue const &x2) const;
00706 };
00707
00708
00709
00712 class colvar::eigenvector
00713 : public colvar::cvc
00714 {
00715 protected:
00716
00718 cvm::atom_group * atoms;
00719
00721 std::vector<cvm::atom_pos> ref_pos;
00722
00724 std::vector<cvm::rvector> eigenvec;
00725
00727 cvm::real eigenvec_invnorm2;
00728
00729 public:
00730
00732 eigenvector(std::string const &conf);
00733 virtual ~eigenvector() {}
00734 virtual void calc_value();
00735 virtual void calc_gradients();
00736 virtual void calc_force_invgrads();
00737 virtual void calc_Jacobian_derivative();
00738 virtual void apply_force(colvarvalue const &force);
00739 virtual cvm::real dist2(colvarvalue const &x1,
00740 colvarvalue const &x2) const;
00741 virtual colvarvalue dist2_lgrad(colvarvalue const &x1,
00742 colvarvalue const &x2) const;
00743 virtual colvarvalue dist2_rgrad(colvarvalue const &x1,
00744 colvarvalue const &x2) const;
00745 };
00746
00747
00748
00751 class colvar::angle
00752 : public colvar::cvc
00753 {
00754 protected:
00755
00757 cvm::atom_group *group1;
00759 cvm::atom_group *group2;
00761 cvm::atom_group *group3;
00762
00764 cvm::rvector r21, r23;
00766 cvm::real r21l, r23l;
00768 cvm::rvector dxdr1, dxdr3;
00769
00773 bool b_1site_force;
00774 public:
00775
00777 angle(std::string const &conf);
00779 angle(cvm::atom const &a1, cvm::atom const &a2, cvm::atom const &a3);
00780 virtual ~angle() {}
00781 virtual void calc_value();
00782 virtual void calc_gradients();
00783 virtual void calc_force_invgrads();
00784 virtual void calc_Jacobian_derivative();
00785 virtual void apply_force(colvarvalue const &force);
00786 virtual cvm::real dist2(colvarvalue const &x1,
00787 colvarvalue const &x2) const;
00788 virtual colvarvalue dist2_lgrad(colvarvalue const &x1,
00789 colvarvalue const &x2) const;
00790 virtual colvarvalue dist2_rgrad(colvarvalue const &x1,
00791 colvarvalue const &x2) const;
00792 };
00793
00794
00795
00798 class colvar::dipole_angle
00799 : public colvar::cvc
00800 {
00801 protected:
00802
00804 cvm::atom_group *group1;
00806 cvm::atom_group *group2;
00808 cvm::atom_group *group3;
00809
00811 cvm::rvector r21, r23;
00813 cvm::real r21l, r23l;
00815 cvm::rvector dxdr1, dxdr3;
00816
00820 bool b_1site_force;
00821 public:
00822
00824 dipole_angle (std::string const &conf);
00826 dipole_angle (cvm::atom const &a1, cvm::atom const &a2, cvm::atom const &a3);
00827 dipole_angle();
00828 virtual ~dipole_angle() {}
00829 virtual void calc_value();
00830 virtual void calc_gradients();
00831 virtual void apply_force (colvarvalue const &force);
00832 virtual cvm::real dist2 (colvarvalue const &x1,
00833 colvarvalue const &x2) const;
00834 virtual colvarvalue dist2_lgrad (colvarvalue const &x1,
00835 colvarvalue const &x2) const;
00836 virtual colvarvalue dist2_rgrad (colvarvalue const &x1,
00837 colvarvalue const &x2) const;
00838 };
00839
00840
00841
00844 class colvar::dihedral
00845 : public colvar::cvc
00846 {
00847 protected:
00848
00850 cvm::atom_group *group1;
00852 cvm::atom_group *group2;
00854 cvm::atom_group *group3;
00856 cvm::atom_group *group4;
00858 cvm::rvector r12, r23, r34;
00859
00862 bool b_1site_force;
00863
00864 public:
00865
00867 dihedral(std::string const &conf);
00869 dihedral(cvm::atom const &a1, cvm::atom const &a2, cvm::atom const &a3, cvm::atom const &a4);
00870 dihedral();
00871 virtual ~dihedral() {}
00872 virtual void calc_value();
00873 virtual void calc_gradients();
00874 virtual void calc_force_invgrads();
00875 virtual void calc_Jacobian_derivative();
00876 virtual void apply_force(colvarvalue const &force);
00877
00879 virtual cvm::real dist2(colvarvalue const &x1,
00880 colvarvalue const &x2) const;
00882 virtual colvarvalue dist2_lgrad(colvarvalue const &x1,
00883 colvarvalue const &x2) const;
00885 virtual colvarvalue dist2_rgrad(colvarvalue const &x1,
00886 colvarvalue const &x2) const;
00888 virtual void wrap(colvarvalue &x_unwrapped) const;
00889 };
00890
00891
00892
00895 class colvar::coordnum
00896 : public colvar::cvc
00897 {
00898 protected:
00900 cvm::atom_group *group1;
00902 cvm::atom_group *group2;
00904 cvm::real r0;
00906 cvm::rvector r0_vec;
00908 bool b_anisotropic;
00910 int en;
00912 int ed;
00913
00915 bool b_group2_center_only;
00916
00918 cvm::real tolerance;
00919
00921 int pairlist_freq;
00922
00924 bool *pairlist;
00925
00926 public:
00927
00928 coordnum(std::string const &conf);
00929 ~coordnum();
00930
00931 virtual void calc_value();
00932 virtual void calc_gradients();
00933 virtual void apply_force(colvarvalue const &force);
00934 virtual cvm::real dist2(colvarvalue const &x1,
00935 colvarvalue const &x2) const;
00936 virtual colvarvalue dist2_lgrad(colvarvalue const &x1,
00937 colvarvalue const &x2) const;
00938 virtual colvarvalue dist2_rgrad(colvarvalue const &x1,
00939 colvarvalue const &x2) const;
00940
00941 enum {
00942 ef_null = 0,
00943 ef_gradients = 1,
00944 ef_anisotropic = (1<<8),
00945 ef_use_pairlist = (1<<9),
00946 ef_rebuild_pairlist = (1<<10)
00947 };
00948
00956 template<int flags>
00957 static cvm::real switching_function(cvm::real const &r0,
00958 cvm::rvector const &r0_vec,
00959 int en,
00960 int ed,
00961 cvm::atom &A1,
00962 cvm::atom &A2,
00963 bool **pairlist_elem,
00964 cvm::real tolerance);
00965
00967 template<int flags> int compute_coordnum();
00968
00970 template<int flags> void main_loop(bool **pairlist_elem);
00971
00972 };
00973
00974
00975
00978 class colvar::selfcoordnum
00979 : public colvar::cvc
00980 {
00981 protected:
00982
00984 cvm::atom_group *group1;
00986 cvm::real r0;
00988 int en;
00990 int ed;
00991 cvm::real tolerance;
00992 int pairlist_freq;
00993 bool *pairlist;
00994
00995 public:
00996
00997 selfcoordnum(std::string const &conf);
00998 ~selfcoordnum();
00999 virtual void calc_value();
01000 virtual void calc_gradients();
01001 virtual void apply_force(colvarvalue const &force);
01002
01003 virtual cvm::real dist2(colvarvalue const &x1,
01004 colvarvalue const &x2) const;
01005 virtual colvarvalue dist2_lgrad(colvarvalue const &x1,
01006 colvarvalue const &x2) const;
01007 virtual colvarvalue dist2_rgrad(colvarvalue const &x1,
01008 colvarvalue const &x2) const;
01009
01011 template<int flags> int compute_selfcoordnum();
01012 };
01013
01014
01015
01018 class colvar::groupcoordnum
01019 : public colvar::distance
01020 {
01021 protected:
01023 cvm::real r0;
01025 cvm::rvector r0_vec;
01028 bool b_anisotropic;
01030 int en;
01032 int ed;
01033 public:
01035 groupcoordnum(std::string const &conf);
01036 virtual ~groupcoordnum() {}
01037 virtual void calc_value();
01038 virtual void calc_gradients();
01039 virtual void apply_force(colvarvalue const &force);
01040
01041 virtual cvm::real dist2(colvarvalue const &x1,
01042 colvarvalue const &x2) const;
01043 virtual colvarvalue dist2_lgrad(colvarvalue const &x1,
01044 colvarvalue const &x2) const;
01045 virtual colvarvalue dist2_rgrad(colvarvalue const &x1,
01046 colvarvalue const &x2) const;
01047 };
01048
01049
01050
01054 class colvar::h_bond
01055 : public colvar::cvc
01056 {
01057 protected:
01059 cvm::real r0;
01061 int en;
01063 int ed;
01064 public:
01065 h_bond(std::string const &conf);
01067 h_bond(cvm::atom const &acceptor,
01068 cvm::atom const &donor,
01069 cvm::real r0, int en, int ed);
01070 h_bond();
01071 virtual ~h_bond() {}
01072 virtual void calc_value();
01073 virtual void calc_gradients();
01074 virtual void apply_force(colvarvalue const &force);
01075
01076 virtual cvm::real dist2(colvarvalue const &x1,
01077 colvarvalue const &x2) const;
01078 virtual colvarvalue dist2_lgrad(colvarvalue const &x1,
01079 colvarvalue const &x2) const;
01080 virtual colvarvalue dist2_rgrad(colvarvalue const &x1,
01081 colvarvalue const &x2) const;
01082 };
01083
01084
01085
01090
01091
01092
01093
01094
01095
01096
01097
01098
01099
01100
01101
01102
01103
01104
01105
01106
01107
01108
01109
01110
01111
01112
01113
01114
01115
01116
01117
01118
01119
01120
01121
01122
01123
01124
01125
01126
01127
01132 class colvar::alpha_angles
01133 : public colvar::cvc
01134 {
01135 protected:
01136
01138 cvm::real theta_ref;
01139
01141 cvm::real theta_tol;
01142
01144 std::vector<angle *> theta;
01145
01147 std::vector<h_bond *> hb;
01148
01150 cvm::real hb_coeff;
01151
01152 public:
01153
01154 alpha_angles(std::string const &conf);
01155 alpha_angles();
01156 virtual ~alpha_angles();
01157 void calc_value();
01158 void calc_gradients();
01160 void collect_gradients(std::vector<int> const &atom_ids, std::vector<cvm::rvector> &atomic_gradients);
01161 void apply_force(colvarvalue const &force);
01162 virtual cvm::real dist2(colvarvalue const &x1,
01163 colvarvalue const &x2) const;
01164 virtual colvarvalue dist2_lgrad(colvarvalue const &x1,
01165 colvarvalue const &x2) const;
01166 virtual colvarvalue dist2_rgrad(colvarvalue const &x1,
01167 colvarvalue const &x2) const;
01168 };
01169
01170
01171
01176 class colvar::dihedPC
01177 : public colvar::cvc
01178 {
01179 protected:
01180
01181 std::vector<dihedral *> theta;
01182 std::vector<cvm::real> coeffs;
01183
01184 public:
01185
01186 dihedPC(std::string const &conf);
01187 dihedPC();
01188 virtual ~dihedPC();
01189 void calc_value();
01190 void calc_gradients();
01192 void collect_gradients(std::vector<int> const &atom_ids, std::vector<cvm::rvector> &atomic_gradients);
01193 void apply_force(colvarvalue const &force);
01194 virtual cvm::real dist2(colvarvalue const &x1,
01195 colvarvalue const &x2) const;
01196 virtual colvarvalue dist2_lgrad(colvarvalue const &x1,
01197 colvarvalue const &x2) const;
01198 virtual colvarvalue dist2_rgrad(colvarvalue const &x1,
01199 colvarvalue const &x2) const;
01200 };
01201
01202
01203
01208 class colvar::orientation
01209 : public colvar::cvc
01210 {
01211 protected:
01212
01214 cvm::atom_group * atoms;
01216 cvm::atom_pos atoms_cog;
01217
01219 std::vector<cvm::atom_pos> ref_pos;
01220
01222 cvm::rotation rot;
01223
01226 cvm::quaternion ref_quat;
01227
01228 public:
01229
01230 orientation(std::string const &conf);
01231 orientation();
01232 virtual int init(std::string const &conf);
01233 virtual ~orientation() {}
01234 virtual void calc_value();
01235 virtual void calc_gradients();
01236 virtual void apply_force(colvarvalue const &force);
01237 virtual cvm::real dist2(colvarvalue const &x1,
01238 colvarvalue const &x2) const;
01239 virtual colvarvalue dist2_lgrad(colvarvalue const &x1,
01240 colvarvalue const &x2) const;
01241 virtual colvarvalue dist2_rgrad(colvarvalue const &x1,
01242 colvarvalue const &x2) const;
01243 };
01244
01245
01246
01250 class colvar::orientation_angle
01251 : public colvar::orientation
01252 {
01253 public:
01254
01255 orientation_angle(std::string const &conf);
01256 virtual int init(std::string const &conf);
01257 virtual ~orientation_angle() {}
01258 virtual void calc_value();
01259 virtual void calc_gradients();
01260 virtual void apply_force(colvarvalue const &force);
01261 virtual cvm::real dist2(colvarvalue const &x1,
01262 colvarvalue const &x2) const;
01263 virtual colvarvalue dist2_lgrad(colvarvalue const &x1,
01264 colvarvalue const &x2) const;
01265 virtual colvarvalue dist2_rgrad(colvarvalue const &x1,
01266 colvarvalue const &x2) const;
01267 };
01268
01269
01270
01274 class colvar::orientation_proj
01275 : public colvar::orientation
01276 {
01277 public:
01278
01279 orientation_proj(std::string const &conf);
01280 orientation_proj();
01281 virtual int init(std::string const &conf);
01282 virtual ~orientation_proj() {}
01283 virtual void calc_value();
01284 virtual void calc_gradients();
01285 virtual void apply_force(colvarvalue const &force);
01286 virtual cvm::real dist2(colvarvalue const &x1,
01287 colvarvalue const &x2) const;
01288 virtual colvarvalue dist2_lgrad(colvarvalue const &x1,
01289 colvarvalue const &x2) const;
01290 virtual colvarvalue dist2_rgrad(colvarvalue const &x1,
01291 colvarvalue const &x2) const;
01292 };
01293
01294
01295
01298 class colvar::tilt
01299 : public colvar::orientation
01300 {
01301 protected:
01302
01303 cvm::rvector axis;
01304
01305 public:
01306
01307 tilt(std::string const &conf);
01308 virtual int init(std::string const &conf);
01309 virtual ~tilt() {}
01310 virtual void calc_value();
01311 virtual void calc_gradients();
01312 virtual void apply_force(colvarvalue const &force);
01313 virtual cvm::real dist2(colvarvalue const &x1,
01314 colvarvalue const &x2) const;
01315 virtual colvarvalue dist2_lgrad(colvarvalue const &x1,
01316 colvarvalue const &x2) const;
01317 virtual colvarvalue dist2_rgrad(colvarvalue const &x1,
01318 colvarvalue const &x2) const;
01319 };
01320
01321
01322
01325 class colvar::spin_angle
01326 : public colvar::orientation
01327 {
01328 protected:
01329
01330 cvm::rvector axis;
01331
01332 public:
01333
01334 spin_angle(std::string const &conf);
01335 spin_angle();
01336 virtual int init(std::string const &conf);
01337 virtual ~spin_angle() {}
01338 virtual void calc_value();
01339 virtual void calc_gradients();
01340 virtual void apply_force(colvarvalue const &force);
01342 virtual cvm::real dist2(colvarvalue const &x1,
01343 colvarvalue const &x2) const;
01345 virtual colvarvalue dist2_lgrad(colvarvalue const &x1,
01346 colvarvalue const &x2) const;
01348 virtual colvarvalue dist2_rgrad(colvarvalue const &x1,
01349 colvarvalue const &x2) const;
01351 virtual void wrap(colvarvalue &x_unwrapped) const;
01352 };
01353
01354
01355 class colvar::euler_phi
01356 : public colvar::orientation
01357 {
01358 public:
01359 euler_phi(std::string const &conf);
01360 euler_phi();
01361 virtual int init(std::string const &conf);
01362 virtual ~euler_phi() {}
01363 virtual void calc_value();
01364 virtual void calc_gradients();
01365 virtual void apply_force(colvarvalue const &force);
01366 virtual cvm::real dist2(colvarvalue const &x1,
01367 colvarvalue const &x2) const;
01368 virtual colvarvalue dist2_lgrad(colvarvalue const &x1,
01369 colvarvalue const &x2) const;
01370 virtual colvarvalue dist2_rgrad(colvarvalue const &x1,
01371 colvarvalue const &x2) const;
01373 virtual void wrap(colvarvalue &x_unwrapped) const;
01374 };
01375
01376
01377 class colvar::euler_psi
01378 : public colvar::orientation
01379 {
01380 public:
01381 euler_psi(std::string const &conf);
01382 euler_psi();
01383 virtual int init(std::string const &conf);
01384 virtual ~euler_psi() {}
01385 virtual void calc_value();
01386 virtual void calc_gradients();
01387 virtual void apply_force(colvarvalue const &force);
01388 virtual cvm::real dist2(colvarvalue const &x1,
01389 colvarvalue const &x2) const;
01390 virtual colvarvalue dist2_lgrad(colvarvalue const &x1,
01391 colvarvalue const &x2) const;
01392 virtual colvarvalue dist2_rgrad(colvarvalue const &x1,
01393 colvarvalue const &x2) const;
01395 virtual void wrap(colvarvalue &x_unwrapped) const;
01396 };
01397
01398
01399 class colvar::euler_theta
01400 : public colvar::orientation
01401 {
01402 public:
01403 euler_theta(std::string const &conf);
01404 euler_theta();
01405 virtual int init(std::string const &conf);
01406 virtual ~euler_theta() {}
01407 virtual void calc_value();
01408 virtual void calc_gradients();
01409 virtual void apply_force(colvarvalue const &force);
01410
01411
01412 virtual cvm::real dist2(colvarvalue const &x1,
01413 colvarvalue const &x2) const;
01414 virtual colvarvalue dist2_lgrad(colvarvalue const &x1,
01415 colvarvalue const &x2) const;
01416 virtual colvarvalue dist2_rgrad(colvarvalue const &x1,
01417 colvarvalue const &x2) const;
01418 };
01419
01420
01425 class colvar::rmsd
01426 : public colvar::cvc
01427 {
01428 protected:
01429
01431 cvm::atom_group *atoms;
01432
01435 std::vector<cvm::atom_pos> ref_pos;
01436
01438 size_t n_permutations;
01439
01441 size_t best_perm_index;
01442 public:
01443
01445 rmsd(std::string const &conf);
01446 virtual ~rmsd() {}
01447 virtual void calc_value();
01448 virtual void calc_gradients();
01449 virtual void calc_force_invgrads();
01450 virtual void calc_Jacobian_derivative();
01451 virtual void apply_force(colvarvalue const &force);
01452 virtual cvm::real dist2(colvarvalue const &x1,
01453 colvarvalue const &x2) const;
01454 virtual colvarvalue dist2_lgrad(colvarvalue const &x1,
01455 colvarvalue const &x2) const;
01456 virtual colvarvalue dist2_rgrad(colvarvalue const &x1,
01457 colvarvalue const &x2) const;
01458 };
01459
01460
01461
01462
01463
01464 class colvar::cartesian
01465 : public colvar::cvc
01466 {
01467 protected:
01469 cvm::atom_group *atoms;
01471 std::vector<size_t> axes;
01472 public:
01473 cartesian(std::string const &conf);
01474 cartesian();
01475 virtual ~cartesian() {}
01476 virtual void calc_value();
01477 virtual void calc_gradients();
01478 virtual void apply_force(colvarvalue const &force);
01479 };
01480
01481
01482
01483
01484 class colvar::alch_lambda
01485 : public colvar::cvc
01486 {
01487 protected:
01488
01489 public:
01490 alch_lambda(std::string const &conf);
01491 alch_lambda();
01492 virtual ~alch_lambda() {}
01493 virtual void calc_value();
01494 virtual void calc_gradients();
01495 virtual void apply_force(colvarvalue const &force);
01496 virtual cvm::real dist2(colvarvalue const &x1,
01497 colvarvalue const &x2) const;
01498 virtual colvarvalue dist2_lgrad(colvarvalue const &x1,
01499 colvarvalue const &x2) const;
01500 virtual colvarvalue dist2_rgrad(colvarvalue const &x1,
01501 colvarvalue const &x2) const;
01502 };
01503
01504
01505
01506
01507 class colvar::alch_Flambda
01508 : public colvar::cvc
01509 {
01510 protected:
01511
01512 public:
01513 alch_Flambda(std::string const &conf);
01514 alch_Flambda();
01515 virtual ~alch_Flambda() {}
01516 virtual void calc_value();
01517 virtual void calc_gradients();
01518 virtual void apply_force(colvarvalue const &force);
01519 virtual cvm::real dist2(colvarvalue const &x1,
01520 colvarvalue const &x2) const;
01521 virtual colvarvalue dist2_lgrad(colvarvalue const &x1,
01522 colvarvalue const &x2) const;
01523 virtual colvarvalue dist2_rgrad(colvarvalue const &x1,
01524 colvarvalue const &x2) const;
01525 };
01526
01527
01528 class colvar::componentDisabled
01529 : public colvar::cvc
01530 {
01531 public:
01532 componentDisabled(std::string const & ) {
01533 cvm::error("Error: this component is not enabled in the current build; please see https://colvars.github.io/README-c++11.html");
01534 }
01535 virtual ~componentDisabled() {}
01536 virtual void calc_value() {}
01537 virtual void calc_gradients() {}
01538 virtual void apply_force(colvarvalue const & ) {}
01539 };
01540
01541
01542
01543 #if (__cplusplus >= 201103L)
01544 class colvar::CartesianBasedPath
01545 : public colvar::cvc
01546 {
01547 protected:
01548 virtual void computeDistanceToReferenceFrames(std::vector<cvm::real>& result);
01550 cvm::atom_group *atoms;
01552 bool has_user_defined_fitting;
01554 std::vector<std::vector<cvm::atom_pos>> reference_frames;
01555 std::vector<std::vector<cvm::atom_pos>> reference_fitting_frames;
01557 std::vector<cvm::atom_group*> comp_atoms;
01559 size_t total_reference_frames;
01560 public:
01561 CartesianBasedPath(std::string const &conf);
01562 virtual ~CartesianBasedPath();
01563 virtual void calc_value() = 0;
01564 virtual void apply_force(colvarvalue const &force) = 0;
01565 };
01566
01570 class colvar::gspath
01571 : public colvar::CartesianBasedPath, public GeometricPathCV::GeometricPathBase<cvm::atom_pos, cvm::real, GeometricPathCV::path_sz::S>
01572 {
01573 private:
01574
01575 cvm::rotation rot_v3;
01576 protected:
01577 virtual void prepareVectors();
01578 virtual void updateDistanceToReferenceFrames();
01579 public:
01580 gspath(std::string const &conf);
01581 virtual ~gspath() {}
01582 virtual void calc_value();
01583 virtual void calc_gradients();
01584 virtual void apply_force(colvarvalue const &force);
01585 };
01586
01587
01588
01591 class colvar::gzpath
01592 : public colvar::CartesianBasedPath, public GeometricPathCV::GeometricPathBase<cvm::atom_pos, cvm::real, GeometricPathCV::path_sz::Z>
01593 {
01594 private:
01595
01596 cvm::rotation rot_v3;
01597 cvm::rotation rot_v4;
01598 protected:
01599 virtual void prepareVectors();
01600 virtual void updateDistanceToReferenceFrames();
01601 public:
01602 gzpath(std::string const &conf);
01603 virtual ~gzpath() {}
01604 virtual void calc_value();
01605 virtual void calc_gradients();
01606 virtual void apply_force(colvarvalue const &force);
01607 };
01608
01610 class colvar::linearCombination
01611 : public colvar::cvc
01612 {
01613 protected:
01615 std::vector<colvar::cvc*> cv;
01617 bool use_explicit_gradients;
01618 protected:
01619 cvm::real getPolynomialFactorOfCVGradient(size_t i_cv) const;
01620 public:
01621 linearCombination(std::string const &conf);
01622 virtual ~linearCombination();
01623 virtual void calc_value();
01624 virtual void calc_gradients();
01625 virtual void apply_force(colvarvalue const &force);
01626 };
01627
01628
01630 class colvar::customColvar
01631 : public colvar::linearCombination
01632 {
01633 protected:
01634 bool use_custom_function;
01635 #ifdef LEPTON
01636
01637 std::vector<Lepton::CompiledExpression *> value_evaluators;
01639 std::vector<Lepton::CompiledExpression *> gradient_evaluators;
01641 std::vector<double *> value_eval_var_refs;
01642 std::vector<double *> grad_eval_var_refs;
01644 double dev_null;
01645 #endif
01646 public:
01647 customColvar(std::string const &conf);
01648 virtual ~customColvar();
01649 virtual void calc_value();
01650 virtual void calc_gradients();
01651 virtual void apply_force(colvarvalue const &force);
01652 };
01653
01654
01655 class colvar::CVBasedPath
01656 : public colvar::cvc
01657 {
01658 protected:
01660 std::vector<colvar::cvc*> cv;
01662 std::vector<std::vector<colvarvalue>> ref_cv;
01664 bool use_explicit_gradients;
01666 size_t total_reference_frames;
01667 protected:
01668 virtual void computeDistanceToReferenceFrames(std::vector<cvm::real>& result);
01670 virtual void computeDistanceBetweenReferenceFrames(std::vector<cvm::real>& result) const;
01671 cvm::real getPolynomialFactorOfCVGradient(size_t i_cv) const;
01672 public:
01673 CVBasedPath(std::string const &conf);
01674 virtual ~CVBasedPath();
01675 virtual void calc_value() = 0;
01676 virtual void apply_force(colvarvalue const &force) = 0;
01677 };
01678
01679
01684 class colvar::gspathCV
01685 : public colvar::CVBasedPath, public GeometricPathCV::GeometricPathBase<colvarvalue, cvm::real, GeometricPathCV::path_sz::S>
01686 {
01687 protected:
01688 virtual void updateDistanceToReferenceFrames();
01689 virtual void prepareVectors();
01690 public:
01691 gspathCV(std::string const &conf);
01692 virtual ~gspathCV();
01693 virtual void calc_value();
01694 virtual void calc_gradients();
01695 virtual void apply_force(colvarvalue const &force);
01696 };
01697
01698
01699
01700 class colvar::gzpathCV
01701 : public colvar::CVBasedPath, public GeometricPathCV::GeometricPathBase<colvarvalue, cvm::real, GeometricPathCV::path_sz::Z>
01702 {
01703 protected:
01704 virtual void updateDistanceToReferenceFrames();
01705 virtual void prepareVectors();
01706 public:
01707 gzpathCV(std::string const &conf);
01708 virtual ~gzpathCV();
01709 virtual void calc_value();
01710 virtual void calc_gradients();
01711 virtual void apply_force(colvarvalue const &force);
01712 };
01713
01714
01715
01716 class colvar::aspathCV
01717 : public colvar::CVBasedPath, public ArithmeticPathCV::ArithmeticPathBase<colvarvalue, cvm::real, ArithmeticPathCV::path_sz::S>
01718 {
01719 protected:
01720 virtual void updateDistanceToReferenceFrames();
01721 public:
01722 aspathCV(std::string const &conf);
01723 virtual ~aspathCV();
01724 virtual void calc_value();
01725 virtual void calc_gradients();
01726 virtual void apply_force(colvarvalue const &force);
01727 };
01728
01729
01730 class colvar::azpathCV
01731 : public colvar::CVBasedPath, public ArithmeticPathCV::ArithmeticPathBase<colvarvalue, cvm::real, ArithmeticPathCV::path_sz::Z>
01732 {
01733 protected:
01734 virtual void updateDistanceToReferenceFrames();
01735 public:
01736 azpathCV(std::string const &conf);
01737 virtual ~azpathCV();
01738 virtual void calc_value();
01739 virtual void calc_gradients();
01740 virtual void apply_force(colvarvalue const &force);
01741 };
01742
01743
01744 namespace neuralnetworkCV {
01745 class neuralNetworkCompute;
01746 }
01747
01748 class colvar::neuralNetwork
01749 : public linearCombination
01750 {
01751 protected:
01753 std::unique_ptr<neuralnetworkCV::neuralNetworkCompute> nn;
01755 size_t m_output_index;
01756 public:
01757 neuralNetwork(std::string const &conf);
01758 virtual ~neuralNetwork();
01759 virtual void calc_value();
01760 virtual void calc_gradients();
01761 virtual void apply_force(colvarvalue const &force);
01762 };
01763
01764 #else // if the compiler doesn't support C++11
01765
01766 class colvar::linearCombination
01767 : public colvar::componentDisabled
01768 {
01769 public:
01770 linearCombination(std::string const &conf) : componentDisabled(conf) {}
01771 };
01772
01773 class colvar::CartesianBasedPath
01774 : public colvar::componentDisabled
01775 {
01776 public:
01777 CartesianBasedPath(std::string const &conf) : componentDisabled(conf) {}
01778 };
01779
01780 class colvar::CVBasedPath
01781 : public colvar::componentDisabled
01782 {
01783 public:
01784 CVBasedPath(std::string const &conf) : componentDisabled(conf) {}
01785 };
01786
01787 class colvar::gspath
01788 : public colvar::componentDisabled
01789 {
01790 public:
01791 gspath(std::string const &conf) : componentDisabled(conf) {}
01792 };
01793
01794 class colvar::gzpath
01795 : public colvar::componentDisabled
01796 {
01797 public:
01798 gzpath(std::string const &conf) : componentDisabled(conf) {}
01799 };
01800
01801 class colvar::gspathCV
01802 : public colvar::componentDisabled
01803 {
01804 public:
01805 gspathCV(std::string const &conf) : componentDisabled(conf) {}
01806 };
01807
01808 class colvar::gzpathCV
01809 : public colvar::componentDisabled
01810 {
01811 public:
01812 gzpathCV(std::string const &conf) : componentDisabled(conf) {}
01813 };
01814
01815 class colvar::aspathCV
01816 : public colvar::componentDisabled
01817 {
01818 public:
01819 aspathCV(std::string const &conf) : componentDisabled(conf) {}
01820 };
01821
01822 class colvar::azpathCV
01823 : public colvar::componentDisabled
01824 {
01825 public:
01826 azpathCV(std::string const &conf) : componentDisabled(conf) {}
01827 };
01828
01829 class colvar::neuralNetwork
01830 : public colvar::componentDisabled
01831 {
01832 public:
01833 neuralNetwork(std::string const &conf) : componentDisabled(conf) {}
01834 };
01835
01836 #endif // C++11 checking
01837
01838
01839
01840
01841 class colvar::map_total
01842 : public colvar::cvc
01843 {
01844 public:
01845
01846 map_total();
01847 map_total(std::string const &conf);
01848 virtual ~map_total() {}
01849 virtual int init(std::string const &conf);
01850 virtual void calc_value();
01851 virtual void calc_gradients();
01852 virtual void apply_force(colvarvalue const &force);
01853
01854 protected:
01855
01857 std::string volmap_name;
01858
01860 int volmap_id;
01861
01863 int volmap_index;
01864
01866 cvm::atom_group *atoms;
01867
01869 std::vector<cvm::real> atom_weights;
01870 };
01871
01872
01873
01874
01875
01876
01877
01878
01879
01880
01881
01882 #define simple_scalar_dist_functions(TYPE) \
01883 \
01884 \
01885 cvm::real colvar::TYPE::dist2(colvarvalue const &x1, \
01886 colvarvalue const &x2) const \
01887 { \
01888 return (x1.real_value - x2.real_value)*(x1.real_value - x2.real_value); \
01889 } \
01890 \
01891 \
01892 colvarvalue colvar::TYPE::dist2_lgrad(colvarvalue const &x1, \
01893 colvarvalue const &x2) const \
01894 { \
01895 return 2.0 * (x1.real_value - x2.real_value); \
01896 } \
01897 \
01898 \
01899 colvarvalue colvar::TYPE::dist2_rgrad(colvarvalue const &x1, \
01900 colvarvalue const &x2) const \
01901 { \
01902 return this->dist2_lgrad(x2, x1); \
01903 } \
01904
01905
01906 #endif