Collective Variables Module - Developer Documentation
colvarcomp.h
1 // -*- c++ -*-
2 
3 #ifndef COLVARCOMP_H
4 #define COLVARCOMP_H
5 
6 // Declaration of colvar::cvc base class and derived ones.
7 //
8 // Future cvc's could be declared on additional header files.
9 // After the declaration of a new derived class, its metric
10 // functions must be reimplemented as well.
11 // If the new cvc has no symmetry or periodicity,
12 // this can be done straightforwardly by using the macro:
13 // simple_scalar_dist_functions (derived_class)
14 
15 
16 #include "colvarmodule.h"
17 #include "colvar.h"
18 #include "colvaratoms.h"
19 
20 
58 
60  : public colvarparse, public colvardeps
61 {
62 public:
63 
66  std::string name;
67 
76  std::string function_type;
77 
81  int sup_np;
82 
84  bool b_periodic;
85 
88 
91 
98  cvc(std::string const &conf);
99 
103  cvm::atom_group *parse_group(std::string const &conf,
104  char const *group_key,
105  bool optional = false);
106 
108  virtual int init_total_force_params(std::string const &conf);
109 
111  int setup();
112 
115  cvc();
116 
118  virtual ~cvc();
119 
121  static std::vector<feature *> cvc_features;
122 
124  virtual const std::vector<feature *> &features()
125  {
126  return cvc_features;
127  }
128  virtual std::vector<feature *> &modify_features()
129  {
130  return cvc_features;
131  }
132  static void delete_features() {
133  for (size_t i=0; i < cvc_features.size(); i++) {
134  delete cvc_features[i];
135  }
136  cvc_features.clear();
137  }
138 
140  virtual void read_data();
141 
143  virtual void calc_value() = 0;
144 
147  virtual void calc_gradients() {}
148 
150  void calc_fit_gradients();
151 
153  virtual void debug_gradients();
154 
157  virtual void calc_force_invgrads();
158 
160  virtual void calc_Jacobian_derivative();
161 
162 
164  colvarvalue const & value() const;
165 
167  colvarvalue const & total_force() const;
168 
171  colvarvalue const & Jacobian_derivative() const;
172 
182  virtual void apply_force(colvarvalue const &cvforce) = 0;
183 
212  virtual cvm::real dist2(colvarvalue const &x1,
213  colvarvalue const &x2) const;
214 
218  virtual colvarvalue dist2_lgrad(colvarvalue const &x1,
219  colvarvalue const &x2) const;
220 
224  virtual colvarvalue dist2_rgrad(colvarvalue const &x1,
225  colvarvalue const &x2) const;
226 
228  virtual void wrap(colvarvalue &x) const;
229 
232  std::vector<cvm::atom_group *> atom_groups;
233 
236  atom_groups.push_back(ag);
237  add_child((colvardeps *) ag);
238  }
239 
242 
243 protected:
244 
247 
250 
256 
260 };
261 
262 
263 inline colvarvalue const & colvar::cvc::value() const
264 {
265  return x;
266 }
267 
268 
269 inline colvarvalue const & colvar::cvc::total_force() const
270 {
271  return ft;
272 }
273 
274 
276 {
277  return jd;
278 }
279 
280 
281 
284 
286  : public colvar::cvc
287 {
288 protected:
296  bool b_no_PBC;
297 public:
298  distance(std::string const &conf);
299  distance();
300  virtual ~distance() {}
301  virtual void calc_value();
302  virtual void calc_gradients();
303  virtual void calc_force_invgrads();
304  virtual void calc_Jacobian_derivative();
305  virtual void apply_force(colvarvalue const &force);
306  virtual cvm::real dist2(colvarvalue const &x1,
307  colvarvalue const &x2) const;
308  virtual colvarvalue dist2_lgrad(colvarvalue const &x1,
309  colvarvalue const &x2) const;
310  virtual colvarvalue dist2_rgrad(colvarvalue const &x1,
311  colvarvalue const &x2) const;
312 };
313 
314 
315 
316 // \brief Colvar component: distance vector between centers of mass
317 // of two groups (\link colvarvalue::type_3vector \endlink type,
318 // range (-*:*)x(-*:*)x(-*:*))
320  : public colvar::distance
321 {
322 public:
323  distance_vec(std::string const &conf);
324  distance_vec();
325  virtual ~distance_vec() {}
326  virtual void calc_value();
327  virtual void calc_gradients();
328  virtual void apply_force(colvarvalue const &force);
330  virtual cvm::real dist2(colvarvalue const &x1,
331  colvarvalue const &x2) const;
333  virtual colvarvalue dist2_lgrad(colvarvalue const &x1,
334  colvarvalue const &x2) const;
336  virtual colvarvalue dist2_rgrad(colvarvalue const &x1,
337  colvarvalue const &x2) const;
338 };
339 
340 
341 
346  : public colvar::distance
347 {
348 public:
349  distance_dir(std::string const &conf);
350  distance_dir();
351  virtual ~distance_dir() {}
352  virtual void calc_value();
353  virtual void calc_gradients();
354  virtual void apply_force(colvarvalue const &force);
356  virtual cvm::real dist2(colvarvalue const &x1,
357  colvarvalue const &x2) const;
359  virtual colvarvalue dist2_lgrad(colvarvalue const &x1,
360  colvarvalue const &x2) const;
362  virtual colvarvalue dist2_rgrad(colvarvalue const &x1,
363  colvarvalue const &x2) const;
364 };
365 
366 
367 
371  : public colvar::cvc
372 {
373 protected:
381  bool b_no_PBC;
390 public:
391  distance_z(std::string const &conf);
392  distance_z();
393  virtual ~distance_z() {}
394  virtual void calc_value();
395  virtual void calc_gradients();
396  virtual void calc_force_invgrads();
397  virtual void calc_Jacobian_derivative();
398  virtual void apply_force(colvarvalue const &force);
399  virtual cvm::real dist2(colvarvalue const &x1,
400  colvarvalue const &x2) const;
401  virtual colvarvalue dist2_lgrad(colvarvalue const &x1,
402  colvarvalue const &x2) const;
403  virtual colvarvalue dist2_rgrad(colvarvalue const &x1,
404  colvarvalue const &x2) const;
406  virtual void wrap(colvarvalue &x) const;
407 };
408 
409 
410 
414  : public colvar::distance_z
415 {
416 protected:
421 public:
422  distance_xy(std::string const &conf);
423  distance_xy();
424  virtual ~distance_xy() {}
425  virtual void calc_value();
426  virtual void calc_gradients();
427  virtual void calc_force_invgrads();
428  virtual void calc_Jacobian_derivative();
429  virtual void apply_force(colvarvalue const &force);
430  virtual cvm::real dist2(colvarvalue const &x1,
431  colvarvalue const &x2) const;
432  virtual colvarvalue dist2_lgrad(colvarvalue const &x1,
433  colvarvalue const &x2) const;
434  virtual colvarvalue dist2_rgrad(colvarvalue const &x1,
435  colvarvalue const &x2) const;
436 };
437 
438 
442  : public colvar::cvc
443 {
444 public:
445  polar_phi(std::string const &conf);
446  polar_phi();
447  virtual ~polar_phi() {}
448 protected:
449  cvm::atom_group *atoms;
450  cvm::real r, theta, phi;
451 public:
452  virtual void calc_value();
453  virtual void calc_gradients();
454  virtual void apply_force(colvarvalue const &force);
456  virtual cvm::real dist2(colvarvalue const &x1,
457  colvarvalue const &x2) const;
459  virtual colvarvalue dist2_lgrad(colvarvalue const &x1,
460  colvarvalue const &x2) const;
462  virtual colvarvalue dist2_rgrad(colvarvalue const &x1,
463  colvarvalue const &x2) const;
465  virtual void wrap(colvarvalue &x) const;
466 };
467 
468 
472  : public colvar::cvc
473 {
474 public:
475  polar_theta(std::string const &conf);
476  polar_theta();
477  virtual ~polar_theta() {}
478 protected:
479  cvm::atom_group *atoms;
480  cvm::real r, theta, phi;
481 public:
482  virtual void calc_value();
483  virtual void calc_gradients();
484  virtual void apply_force(colvarvalue const &force);
486  virtual cvm::real dist2(colvarvalue const &x1,
487  colvarvalue const &x2) const;
489  virtual colvarvalue dist2_lgrad(colvarvalue const &x1,
490  colvarvalue const &x2) const;
492  virtual colvarvalue dist2_rgrad(colvarvalue const &x1,
493  colvarvalue const &x2) const;
494 };
495 
499  : public colvar::cvc
500 {
501 protected:
507  int exponent;
509  bool b_no_PBC;
510 public:
511  distance_inv(std::string const &conf);
512  distance_inv();
513  virtual ~distance_inv() {}
514  virtual void calc_value();
515  virtual void calc_gradients();
516  virtual void apply_force(colvarvalue const &force);
517  virtual cvm::real dist2(colvarvalue const &x1,
518  colvarvalue const &x2) const;
519  virtual colvarvalue dist2_lgrad(colvarvalue const &x1,
520  colvarvalue const &x2) const;
521  virtual colvarvalue dist2_rgrad(colvarvalue const &x1,
522  colvarvalue const &x2) const;
523 };
524 
525 
526 
530  : public colvar::cvc
531 {
532 protected:
538  bool b_no_PBC;
539 public:
540  distance_pairs(std::string const &conf);
541  distance_pairs();
542  virtual ~distance_pairs() {}
543  virtual void calc_value();
544  virtual void calc_gradients();
545  virtual void apply_force(colvarvalue const &force);
546 };
547 
548 
549 
553  : public colvar::cvc
554 {
555 protected:
558 public:
560  gyration(std::string const &conf);
561  gyration();
562  virtual ~gyration() {}
563  virtual void calc_value();
564  virtual void calc_gradients();
565  virtual void calc_force_invgrads();
566  virtual void calc_Jacobian_derivative();
567  virtual void apply_force(colvarvalue const &force);
568  virtual cvm::real dist2(colvarvalue const &x1,
569  colvarvalue const &x2) const;
570  virtual colvarvalue dist2_lgrad(colvarvalue const &x1,
571  colvarvalue const &x2) const;
572  virtual colvarvalue dist2_rgrad(colvarvalue const &x1,
573  colvarvalue const &x2) const;
574 };
575 
576 
577 
581  : public colvar::gyration
582 {
583 public:
585  inertia(std::string const &conf);
586  inertia();
587  virtual ~inertia() {}
588  virtual void calc_value();
589  virtual void calc_gradients();
590  virtual void apply_force(colvarvalue const &force);
591  virtual cvm::real dist2(colvarvalue const &x1,
592  colvarvalue const &x2) const;
593  virtual colvarvalue dist2_lgrad(colvarvalue const &x1,
594  colvarvalue const &x2) const;
595  virtual colvarvalue dist2_rgrad(colvarvalue const &x1,
596  colvarvalue const &x2) const;
597 };
598 
599 
600 
604  : public colvar::inertia
605 {
606 protected:
609 public:
611  inertia_z(std::string const &conf);
612  inertia_z();
613  virtual ~inertia_z() {}
614  virtual void calc_value();
615  virtual void calc_gradients();
616  virtual void apply_force(colvarvalue const &force);
617  virtual cvm::real dist2(colvarvalue const &x1,
618  colvarvalue const &x2) const;
619  virtual colvarvalue dist2_lgrad(colvarvalue const &x1,
620  colvarvalue const &x2) const;
621  virtual colvarvalue dist2_rgrad(colvarvalue const &x1,
622  colvarvalue const &x2) const;
623 };
624 
625 
626 
630  : public colvar::cvc
631 {
632 protected:
633 
636 
638  std::vector<cvm::atom_pos> ref_pos;
639 
642 
644  std::vector<cvm::rvector> eigenvec;
645 
648 
649 public:
650 
652  eigenvector(std::string const &conf);
653  virtual ~eigenvector() {}
654  virtual void calc_value();
655  virtual void calc_gradients();
656  virtual void calc_force_invgrads();
657  virtual void calc_Jacobian_derivative();
658  virtual void apply_force(colvarvalue const &force);
659  virtual cvm::real dist2(colvarvalue const &x1,
660  colvarvalue const &x2) const;
661  virtual colvarvalue dist2_lgrad(colvarvalue const &x1,
662  colvarvalue const &x2) const;
663  virtual colvarvalue dist2_rgrad(colvarvalue const &x1,
664  colvarvalue const &x2) const;
665 };
666 
667 
668 
672  : public colvar::cvc
673 {
674 protected:
675 
682 
689 
694 public:
695 
697  angle(std::string const &conf);
699  angle(cvm::atom const &a1, cvm::atom const &a2, cvm::atom const &a3);
700  angle();
701  virtual ~angle() {}
702  virtual void calc_value();
703  virtual void calc_gradients();
704  virtual void calc_force_invgrads();
705  virtual void calc_Jacobian_derivative();
706  virtual void apply_force(colvarvalue const &force);
707  virtual cvm::real dist2(colvarvalue const &x1,
708  colvarvalue const &x2) const;
709  virtual colvarvalue dist2_lgrad(colvarvalue const &x1,
710  colvarvalue const &x2) const;
711  virtual colvarvalue dist2_rgrad(colvarvalue const &x1,
712  colvarvalue const &x2) const;
713 };
714 
715 
716 
720  : public colvar::cvc
721 {
722 protected:
723 
730 
737 
742 public:
743 
745  dipole_angle (std::string const &conf);
747  dipole_angle (cvm::atom const &a1, cvm::atom const &a2, cvm::atom const &a3);
748  dipole_angle();
749  virtual ~dipole_angle() {}
750  virtual void calc_value();
751  virtual void calc_gradients();
752  virtual void apply_force (colvarvalue const &force);
753  virtual cvm::real dist2 (colvarvalue const &x1,
754  colvarvalue const &x2) const;
755  virtual colvarvalue dist2_lgrad (colvarvalue const &x1,
756  colvarvalue const &x2) const;
757  virtual colvarvalue dist2_rgrad (colvarvalue const &x1,
758  colvarvalue const &x2) const;
759 };
760 
761 
762 
766  : public colvar::cvc
767 {
768 protected:
769 
779  cvm::rvector r12, r23, r34;
780 
784 
785 public:
786 
788  dihedral(std::string const &conf);
790  dihedral(cvm::atom const &a1, cvm::atom const &a2, cvm::atom const &a3, cvm::atom const &a4);
791  dihedral();
792  virtual ~dihedral() {}
793  virtual void calc_value();
794  virtual void calc_gradients();
795  virtual void calc_force_invgrads();
796  virtual void calc_Jacobian_derivative();
797  virtual void apply_force(colvarvalue const &force);
798 
800  virtual cvm::real dist2(colvarvalue const &x1,
801  colvarvalue const &x2) const;
803  virtual colvarvalue dist2_lgrad(colvarvalue const &x1,
804  colvarvalue const &x2) const;
806  virtual colvarvalue dist2_rgrad(colvarvalue const &x1,
807  colvarvalue const &x2) const;
809  virtual void wrap(colvarvalue &x) const;
810 };
811 
812 
813 
817  : public colvar::cvc
818 {
819 protected:
832  int en;
834  int ed;
838 public:
840  coordnum(std::string const &conf);
841  coordnum();
842  virtual ~coordnum() {}
843  virtual void calc_value();
844  virtual void calc_gradients();
845  virtual void apply_force(colvarvalue const &force);
846  template<bool b_gradients>
851  static cvm::real switching_function(cvm::real const &r0,
852  int const &exp_num, int const &exp_den,
853  cvm::atom &A1, cvm::atom &A2);
854 
855  template<bool b_gradients>
861  static cvm::real switching_function(cvm::rvector const &r0_vec,
862  int const &exp_num, int const &exp_den,
863  cvm::atom &A1, cvm::atom &A2);
864 
865  virtual cvm::real dist2(colvarvalue const &x1,
866  colvarvalue const &x2) const;
867  virtual colvarvalue dist2_lgrad(colvarvalue const &x1,
868  colvarvalue const &x2) const;
869  virtual colvarvalue dist2_rgrad(colvarvalue const &x1,
870  colvarvalue const &x2) const;
871 };
872 
873 
874 
878  : public colvar::cvc
879 {
880 protected:
886  int en;
888  int ed;
889 public:
891  selfcoordnum(std::string const &conf);
892  selfcoordnum();
893  virtual ~selfcoordnum() {}
894  virtual void calc_value();
895  virtual void calc_gradients();
896  virtual void apply_force(colvarvalue const &force);
897  template<bool b_gradients>
902  static cvm::real switching_function(cvm::real const &r0,
903  int const &exp_num, int const &exp_den,
904  cvm::atom &A1, cvm::atom &A2);
905 
906  virtual cvm::real dist2(colvarvalue const &x1,
907  colvarvalue const &x2) const;
908  virtual colvarvalue dist2_lgrad(colvarvalue const &x1,
909  colvarvalue const &x2) const;
910  virtual colvarvalue dist2_rgrad(colvarvalue const &x1,
911  colvarvalue const &x2) const;
912 };
913 
914 
915 
919  : public colvar::distance
920 {
921 protected:
930  int en;
932  int ed;
933 public:
935  groupcoordnum(std::string const &conf);
936  groupcoordnum();
937  virtual ~groupcoordnum() {}
938  virtual void calc_value();
939  virtual void calc_gradients();
940  virtual void apply_force(colvarvalue const &force);
941  template<bool b_gradients>
946  static cvm::real switching_function(cvm::real const &r0,
947  int const &exp_num, int const &exp_den,
948  cvm::atom &A1, cvm::atom &A2);
949 
950  /*
951  template<bool b_gradients>
957  static cvm::real switching_function(cvm::rvector const &r0_vec,
958  int const &exp_num, int const &exp_den,
959  cvm::atom &A1, cvm::atom &A2);
960  */
961 
962  virtual cvm::real dist2(colvarvalue const &x1,
963  colvarvalue const &x2) const;
964  virtual colvarvalue dist2_lgrad(colvarvalue const &x1,
965  colvarvalue const &x2) const;
966  virtual colvarvalue dist2_rgrad(colvarvalue const &x1,
967  colvarvalue const &x2) const;
968 };
969 
970 
971 
976  : public colvar::cvc
977 {
978 protected:
982  int en;
984  int ed;
985 public:
986  h_bond(std::string const &conf);
988  h_bond(cvm::atom const &acceptor,
989  cvm::atom const &donor,
990  cvm::real r0, int en, int ed);
991  h_bond();
992  virtual ~h_bond();
993  virtual void calc_value();
994  virtual void calc_gradients();
995  virtual void apply_force(colvarvalue const &force);
996 
997  virtual cvm::real dist2(colvarvalue const &x1,
998  colvarvalue const &x2) const;
999  virtual colvarvalue dist2_lgrad(colvarvalue const &x1,
1000  colvarvalue const &x2) const;
1001  virtual colvarvalue dist2_rgrad(colvarvalue const &x1,
1002  colvarvalue const &x2) const;
1003 };
1004 
1005 
1006 
1011 // class colvar::alpha_dihedrals
1012 // : public colvar::cvc
1013 // {
1014 // protected:
1015 
1016 // /// Alpha-helical reference phi value
1017 // cvm::real phi_ref;
1018 
1019 // /// Alpha-helical reference psi value
1020 // cvm::real psi_ref;
1021 
1022 // /// List of phi dihedral angles
1023 // std::vector<dihedral *> phi;
1024 
1025 // /// List of psi dihedral angles
1026 // std::vector<dihedral *> psi;
1027 
1028 // /// List of hydrogen bonds
1029 // std::vector<h_bond *> hb;
1030 
1031 // public:
1032 
1033 // alpha_dihedrals (std::string const &conf);
1034 // alpha_dihedrals();
1035 // virtual ~alpha_dihedrals() {}
1036 // virtual void calc_value();
1037 // virtual void calc_gradients();
1038 // virtual void apply_force (colvarvalue const &force);
1039 // virtual cvm::real dist2 (colvarvalue const &x1,
1040 // colvarvalue const &x2) const;
1041 // virtual colvarvalue dist2_lgrad (colvarvalue const &x1,
1042 // colvarvalue const &x2) const;
1043 // virtual colvarvalue dist2_rgrad (colvarvalue const &x1,
1044 // colvarvalue const &x2) const;
1045 // };
1046 
1047 
1048 
1054  : public colvar::cvc
1055 {
1056 protected:
1057 
1060 
1063 
1065  std::vector<angle *> theta;
1066 
1068  std::vector<h_bond *> hb;
1069 
1072 
1073 public:
1074 
1075  alpha_angles(std::string const &conf);
1076  alpha_angles();
1077  virtual ~alpha_angles();
1078  void calc_value();
1079  void calc_gradients();
1080  void apply_force(colvarvalue const &force);
1081  virtual cvm::real dist2(colvarvalue const &x1,
1082  colvarvalue const &x2) const;
1083  virtual colvarvalue dist2_lgrad(colvarvalue const &x1,
1084  colvarvalue const &x2) const;
1085  virtual colvarvalue dist2_rgrad(colvarvalue const &x1,
1086  colvarvalue const &x2) const;
1087 };
1088 
1089 
1090 
1096  : public colvar::cvc
1097 {
1098 protected:
1099 
1100  std::vector<dihedral *> theta;
1101  std::vector<cvm::real> coeffs;
1102 
1103 public:
1104 
1105  dihedPC(std::string const &conf);
1106  dihedPC();
1107  virtual ~dihedPC();
1108  void calc_value();
1109  void calc_gradients();
1110  void apply_force(colvarvalue const &force);
1111  virtual cvm::real dist2(colvarvalue const &x1,
1112  colvarvalue const &x2) const;
1113  virtual colvarvalue dist2_lgrad(colvarvalue const &x1,
1114  colvarvalue const &x2) const;
1115  virtual colvarvalue dist2_rgrad(colvarvalue const &x1,
1116  colvarvalue const &x2) const;
1117 };
1118 
1119 
1120 
1126  : public colvar::cvc
1127 {
1128 protected:
1129 
1134 
1136  std::vector<cvm::atom_pos> ref_pos;
1137 
1140 
1144 
1145 public:
1146 
1147  orientation(std::string const &conf);
1148  orientation();
1149  virtual ~orientation() {}
1150  virtual void calc_value();
1151  virtual void calc_gradients();
1152  virtual void apply_force(colvarvalue const &force);
1153  virtual cvm::real dist2(colvarvalue const &x1,
1154  colvarvalue const &x2) const;
1155  virtual colvarvalue dist2_lgrad(colvarvalue const &x1,
1156  colvarvalue const &x2) const;
1157  virtual colvarvalue dist2_rgrad(colvarvalue const &x1,
1158  colvarvalue const &x2) const;
1159 };
1160 
1161 
1162 
1167  : public colvar::orientation
1168 {
1169 public:
1170 
1171  orientation_angle(std::string const &conf);
1173  virtual ~orientation_angle() {}
1174  virtual void calc_value();
1175  virtual void calc_gradients();
1176  virtual void apply_force(colvarvalue const &force);
1177  virtual cvm::real dist2(colvarvalue const &x1,
1178  colvarvalue const &x2) const;
1179  virtual colvarvalue dist2_lgrad(colvarvalue const &x1,
1180  colvarvalue const &x2) const;
1181  virtual colvarvalue dist2_rgrad(colvarvalue const &x1,
1182  colvarvalue const &x2) const;
1183 };
1184 
1185 
1186 
1191  : public colvar::orientation
1192 {
1193 public:
1194 
1195  orientation_proj(std::string const &conf);
1196  orientation_proj();
1197  virtual ~orientation_proj() {}
1198  virtual void calc_value();
1199  virtual void calc_gradients();
1200  virtual void apply_force(colvarvalue const &force);
1201  virtual cvm::real dist2(colvarvalue const &x1,
1202  colvarvalue const &x2) const;
1203  virtual colvarvalue dist2_lgrad(colvarvalue const &x1,
1204  colvarvalue const &x2) const;
1205  virtual colvarvalue dist2_rgrad(colvarvalue const &x1,
1206  colvarvalue const &x2) const;
1207 };
1208 
1209 
1210 
1214  : public colvar::orientation
1215 {
1216 protected:
1217 
1218  cvm::rvector axis;
1219 
1220 public:
1221 
1222  tilt(std::string const &conf);
1223  tilt();
1224  virtual ~tilt() {}
1225  virtual void calc_value();
1226  virtual void calc_gradients();
1227  virtual void apply_force(colvarvalue const &force);
1228  virtual cvm::real dist2(colvarvalue const &x1,
1229  colvarvalue const &x2) const;
1230  virtual colvarvalue dist2_lgrad(colvarvalue const &x1,
1231  colvarvalue const &x2) const;
1232  virtual colvarvalue dist2_rgrad(colvarvalue const &x1,
1233  colvarvalue const &x2) const;
1234 };
1235 
1236 
1237 
1241  : public colvar::orientation
1242 {
1243 protected:
1244 
1245  cvm::rvector axis;
1246 
1247 public:
1248 
1249  spin_angle(std::string const &conf);
1250  spin_angle();
1251  virtual ~spin_angle() {}
1252  virtual void calc_value();
1253  virtual void calc_gradients();
1254  virtual void apply_force(colvarvalue const &force);
1256  virtual cvm::real dist2(colvarvalue const &x1,
1257  colvarvalue const &x2) const;
1259  virtual colvarvalue dist2_lgrad(colvarvalue const &x1,
1260  colvarvalue const &x2) const;
1262  virtual colvarvalue dist2_rgrad(colvarvalue const &x1,
1263  colvarvalue const &x2) const;
1265  virtual void wrap(colvarvalue &x) const;
1266 };
1267 
1268 
1269 
1275  : public colvar::cvc
1276 {
1277 protected:
1278 
1281 
1283  std::vector<cvm::atom_pos> ref_pos;
1284 
1285 public:
1286 
1288  rmsd(std::string const &conf);
1289  virtual ~rmsd() {}
1290  virtual void calc_value();
1291  virtual void calc_gradients();
1292  virtual void calc_force_invgrads();
1293  virtual void calc_Jacobian_derivative();
1294  virtual void apply_force(colvarvalue const &force);
1295  virtual cvm::real dist2(colvarvalue const &x1,
1296  colvarvalue const &x2) const;
1297  virtual colvarvalue dist2_lgrad(colvarvalue const &x1,
1298  colvarvalue const &x2) const;
1299  virtual colvarvalue dist2_rgrad(colvarvalue const &x1,
1300  colvarvalue const &x2) const;
1301 };
1302 
1303 
1304 
1305 // \brief Colvar component: flat vector of Cartesian coordinates
1306 // Mostly useful to compute scripted colvar values
1308  : public colvar::cvc
1309 {
1310 protected:
1314  std::vector<size_t> axes;
1315 public:
1316  cartesian(std::string const &conf);
1317  cartesian();
1318  virtual ~cartesian() {}
1319  virtual void calc_value();
1320  virtual void calc_gradients();
1321  virtual void apply_force(colvarvalue const &force);
1322 };
1323 
1324 
1325 // metrics functions for cvc implementations
1326 
1327 // simple definitions of the distance functions; these are useful only
1328 // for optimization (the type check performed in the default
1329 // colvarcomp functions is skipped)
1330 
1331 // definitions assuming the scalar type
1332 
1333 #define simple_scalar_dist_functions(TYPE) \
1334  \
1335  \
1336  cvm::real colvar::TYPE::dist2(colvarvalue const &x1, \
1337  colvarvalue const &x2) const \
1338  { \
1339  return (x1.real_value - x2.real_value)*(x1.real_value - x2.real_value); \
1340  } \
1341  \
1342  \
1343  colvarvalue colvar::TYPE::dist2_lgrad(colvarvalue const &x1, \
1344  colvarvalue const &x2) const \
1345  { \
1346  return 2.0 * (x1.real_value - x2.real_value); \
1347  } \
1348  \
1349  \
1350  colvarvalue colvar::TYPE::dist2_rgrad(colvarvalue const &x1, \
1351  colvarvalue const &x2) const \
1352  { \
1353  return this->dist2_lgrad(x2, x1); \
1354  } \
1355  \
1356 
1357 #endif
Colvar component: average distance between two groups of atoms, weighted as the sixth power...
Definition: colvarcomp.h:498
Colvar component: moment of inertia of an atom group (colvarvalue::type_scalar type, range [0:*))
Definition: colvarcomp.h:580
virtual void calc_value()=0
Calculate the variable.
int en
Integer exponent of the function numerator.
Definition: colvarcomp.h:982
1-dimensional vector of real numbers with four components and a quaternion algebra ...
Definition: colvartypes.h:1020
void register_atom_group(cvm::atom_group *ag)
Store a pointer to new atom group, and list as child for dependencies.
Definition: colvarcomp.h:235
cvm::rvector r0_vec
"Cutoff vector" for anisotropic calculation
Definition: colvarcomp.h:925
bool b_try_scalable
Whether or not this CVC will be computed in parallel whenever possible.
Definition: colvarcomp.h:241
bool b_periodic
Is this a periodic component?
Definition: colvarcomp.h:84
int ed
Integer exponent of the function denominator.
Definition: colvarcomp.h:888
cvm::real axis_norm
Norm of the axis.
Definition: colvarcomp.h:385
cvm::atom_group * group2
Atom group.
Definition: colvarcomp.h:727
bool b_no_PBC
Use absolute positions, ignoring PBCs when present.
Definition: colvarcomp.h:296
cvm::atom_group * atoms
Atom group.
Definition: colvarcomp.h:1280
Colvar component: hydrogen bond, defined as the product of a colvar::coordnum and 1/2*(1-cos((180-ang...
Definition: colvarcomp.h:975
Colvar component: orientation in space of an atom group, with respect to a set of reference coordinat...
Definition: colvarcomp.h:1125
std::vector< angle * > theta
List of Calpha-Calpha angles.
Definition: colvarcomp.h:1065
Definition: colvarcomp.h:319
virtual colvarvalue dist2_rgrad(colvarvalue const &x1, colvarvalue const &x2) const
Gradient(with respect to x2) of the square distance (can be redefined to transparently implement cons...
Definition: colvarcomp.cpp:344
std::vector< size_t > axes
Which Cartesian coordinates to include.
Definition: colvarcomp.h:1314
cvm::atom_group * group1
First atom group.
Definition: colvarcomp.h:821
cvm::rvector v12
Vector distances.
Definition: colvarcomp.h:420
Colvar component: polar coordinate theta of a group (colvarvalue::type_scalar type, range [0:180])
Definition: colvarcomp.h:471
int ed
Integer exponent of the function denominator.
Definition: colvarcomp.h:984
cvm::real r0
"Cutoff" distance between acceptor and donor
Definition: colvarcomp.h:980
int ed
Integer exponent of the function denominator.
Definition: colvarcomp.h:834
int exponent
Components of the distance vector orthogonal to the axis.
Definition: colvarcomp.h:507
cvm::rvector r0_vec
"Cutoff vector" for anisotropic calculation
Definition: colvarcomp.h:827
colvarvalue const & total_force() const
Return the previously calculated total force.
Definition: colvarcomp.h:269
cvm::atom_group * group1
First atom group.
Definition: colvarcomp.h:503
cvm::atom_group * group1
First atom group.
Definition: colvarcomp.h:290
Stores numeric id, mass and all mutable data for an atom, mostly used by a cvc.
Definition: colvaratoms.h:21
cvc()
Default constructor (used when cvc objects are declared within other ones)
Definition: colvarcomp.cpp:10
Colvar component: coordination number between two groups (colvarvalue::type_scalar type...
Definition: colvarcomp.h:816
cvm::atom_group * ref2
Optional, second ref atom group.
Definition: colvarcomp.h:379
cvm::atom_group * main
Main atom group.
Definition: colvarcomp.h:375
static std::vector< feature * > cvc_features
Implementation of the feature list for colvar.
Definition: colvarcomp.h:121
colvarvalue jd
Calculated Jacobian derivative (divergence of the inverse gradients): serves to calculate the phase s...
Definition: colvarcomp.h:259
cvm::rvector dxdr1
Derivatives wrt group centers of mass.
Definition: colvarcomp.h:688
Colvar component: cosine of the angle of rotation with respect to a set of reference coordinates (col...
Definition: colvarcomp.h:1190
cvm::real period
Period of this cvc value, (default: 0.0, non periodic)
Definition: colvarcomp.h:87
bool b_no_PBC
Use absolute positions, ignoring PBCs when present.
Definition: colvarcomp.h:538
vector of real numbers with three components
Definition: colvartypes.h:714
cvm::rotation rot
Rotation object.
Definition: colvarcomp.h:1139
cvm::atom_group * group3
Atom group.
Definition: colvarcomp.h:681
bool b_1site_force
Definition: colvarcomp.h:741
virtual void calc_force_invgrads()
Calculate the total force from the system using the inverse atomic gradients.
Definition: colvarcomp.cpp:187
cvm::atom_group * atoms
Atoms involved.
Definition: colvarcomp.h:557
bool b_anisotropic
Wheter dist/r0 or {dist}*{1/r0_vec} should ne be used.
Definition: colvarcomp.h:928
cvm::atom_group * atoms
Atom group.
Definition: colvarcomp.h:1312
virtual ~cvc()
Destructor.
Definition: colvarcomp.cpp:156
Colvar component: projection of the distance vector on a plane (colvarvalue::type_scalar type...
Definition: colvarcomp.h:413
cvm::atom_group * group1
Dipole atom group.
Definition: colvarcomp.h:725
Colvar component: projection of the distance vector along an axis(colvarvalue::type_scalar type...
Definition: colvarcomp.h:370
virtual void read_data()
Obtain data needed for the calculation for the backend.
Definition: colvarcomp.cpp:165
cvm::rvector axis
Vector on which the inertia tensor is projected.
Definition: colvarcomp.h:608
cvm::real r0
"Cutoff" for isotropic calculation (default)
Definition: colvarcomp.h:884
cvm::atom_group * ref1
Reference atom group.
Definition: colvarcomp.h:377
Collective variables main module.
Colvar component: projection of the orientation vector onto a predefined axis (colvarvalue::type_scal...
Definition: colvarcomp.h:1213
cvm::real eigenvec_invnorm2
Inverse square norm of the eigenvector.
Definition: colvarcomp.h:647
Definition: colvarcomp.h:1307
double real
Defining an abstract real number allows to switch precision.
Definition: colvarmodule.h:76
cvm::real r0
"Cutoff" for isotropic calculation (default)
Definition: colvarcomp.h:923
virtual colvarvalue dist2_lgrad(colvarvalue const &x1, colvarvalue const &x2) const
Gradient(with respect to x1) of the square distance (can be redefined to transparently implement cons...
Definition: colvarcomp.cpp:337
cvm::rvector r21
Inter site vectors.
Definition: colvarcomp.h:684
bool b_1site_force
Compute total force on first site only to avoid unwanted coupling to other colvars (see e...
Definition: colvarcomp.h:783
cvm::atom_group * group3
Atom group.
Definition: colvarcomp.h:775
cvm::atom_group * group2
Second atom group.
Definition: colvarcomp.h:505
cvm::rvector dist_v
Vector distance, cached to be recycled.
Definition: colvarcomp.h:387
Colvar component: moment of inertia of an atom group around a user-defined axis (colvarvalue::type_sc...
Definition: colvarcomp.h:603
Colvar component: alpha helix content of a contiguous segment of 5 or more residues, implemented as a sum of phi/psi dihedral angles and hydrogen bonds (colvarvalue::type_scalar type, range [0:1])
Definition: colvarcomp.h:1053
virtual void apply_force(colvarvalue const &cvforce)=0
Apply the collective variable force, by communicating the atomic forces to the simulation program (No...
cvm::rvector dist_v_ortho
Components of the distance vector orthogonal to the axis.
Definition: colvarcomp.h:418
Colvar component: projection of 3N coordinates onto an eigenvector(colvarvalue::type_scalar type...
Definition: colvarcomp.h:629
Value of a collective variable: this is a metatype which can be set at runtime. By default it is set ...
Definition: colvarvalue.h:34
std::vector< cvm::rvector > eigenvec
Eigenvector (of a normal or essential mode): will always have zero center.
Definition: colvarcomp.h:644
cvm::real theta_ref
Reference Calpha-Calpha angle (default: 88 degrees)
Definition: colvarcomp.h:1059
std::vector< cvm::atom_group * > atom_groups
Pointers to all atom groups, to let colvars collect info e.g. atomic gradients.
Definition: colvarcomp.h:232
cvm::real wrap_center
If the component is periodic, wrap around this value (default: 0.0)
Definition: colvarcomp.h:90
colvarvalue ft
Calculated total force (Note: this is calculated from the total atomic forces read from the program...
Definition: colvarcomp.h:255
Colvar component: dihedral between the centers of mass of four groups (colvarvalue::type_scalar type...
Definition: colvarcomp.h:765
std::vector< h_bond * > hb
List of hydrogen bonds.
Definition: colvarcomp.h:1068
Colvar component: polar coordinate phi of a group (colvarvalue::type_scalar type, range [-180:180]) ...
Definition: colvarcomp.h:441
std::vector< cvm::atom_pos > ref_pos
Reference coordinates.
Definition: colvarcomp.h:1136
colvarvalue const & value() const
Return the previously calculated value.
Definition: colvarcomp.h:263
cvm::real hb_coeff
Contribution of the hb terms.
Definition: colvarcomp.h:1071
int sup_np
Exponent in the polynomial combination (default: 1)
Definition: colvarcomp.h:81
cvm::atom_group * parse_group(std::string const &conf, char const *group_key, bool optional=false)
Within the constructor, make a group parse its own options from the provided configuration string Ret...
Definition: colvarcomp.cpp:96
cvm::atom_group * group1
Atom group.
Definition: colvarcomp.h:677
cvm::atom_pos ref_pos_center
Geometric center of the reference coordinates.
Definition: colvarcomp.h:641
int en
Integer exponent of the function numerator.
Definition: colvarcomp.h:886
cvm::rvector dist_v
Vector distance, cached to be recycled.
Definition: colvarcomp.h:294
cvm::real r21l
Inter site vector norms.
Definition: colvarcomp.h:686
cvm::atom_group * group4
Atom group.
Definition: colvarcomp.h:777
int ed
Integer exponent of the function denominator.
Definition: colvarcomp.h:932
Colvar component: angle between the centers of mass of three groups (colvarvalue::type_scalar type...
Definition: colvarcomp.h:671
Colvar component: self-coordination number within a group (colvarvalue::type_scalar type...
Definition: colvarcomp.h:877
int en
Integer exponent of the function numerator.
Definition: colvarcomp.h:832
cvm::atom_group * group2
Second atom group.
Definition: colvarcomp.h:292
cvm::atom_pos atoms_cog
Center of geometry of the group.
Definition: colvarcomp.h:1133
Colvar component: distance unit vector (direction) between centers of mass of two groups (colvarvalue...
Definition: colvarcomp.h:345
virtual void calc_Jacobian_derivative()
Calculate the divergence of the inverse atomic gradients.
Definition: colvarcomp.cpp:195
cvm::real sup_coeff
Coefficient in the polynomial combination (default: 1.0)
Definition: colvarcomp.h:79
colvarvalue x
Cached value.
Definition: colvarcomp.h:246
int en
Integer exponent of the function numerator.
Definition: colvarcomp.h:930
virtual int init_total_force_params(std::string const &conf)
Parse options pertaining to total force calculation.
Definition: colvarcomp.cpp:66
cvm::atom_group * group1
First atom group.
Definition: colvarcomp.h:882
cvm::atom_group * group2
Atom group.
Definition: colvarcomp.h:679
virtual cvm::real dist2(colvarvalue const &x1, colvarvalue const &x2) const
Square distance between x1 and x2 (can be redefined to transparently implement constraints, symmetries and periodicities)
Definition: colvarcomp.cpp:330
cvm::rvector r21
Inter site vectors.
Definition: colvarcomp.h:732
Colvar component: angle between the dipole of a molecule and an axis formed by two groups of atoms(co...
Definition: colvarcomp.h:719
colvarvalue const & Jacobian_derivative() const
Return the previously calculated divergence of the inverse atomic gradients.
Definition: colvarcomp.h:275
cvm::atom_group * group2
Second atom group.
Definition: colvarcomp.h:536
Colvar component: Radius of gyration of an atom group (colvarvalue::type_scalar type, range [0:*))
Definition: colvarcomp.h:552
Parent class for a member object of a bias, cv or cvc etc. containing features and their dependencies...
Definition: colvardeps.h:23
virtual void calc_gradients()
Calculate the atomic gradients, to be reused later in order to apply forces.
Definition: colvarcomp.h:147
Colvar component: distance between the centers of mass of two groups (colvarvalue::type_scalar type...
Definition: colvarcomp.h:285
Colvar component: angle of rotation around a predefined axis (colvarvalue::type_scalar type...
Definition: colvarcomp.h:1240
cvm::real r21l
Inter site vector norms.
Definition: colvarcomp.h:734
cvm::atom_group * group1
First atom group.
Definition: colvarcomp.h:534
cvm::rvector dxdr1
Derivatives wrt group centers of mass.
Definition: colvarcomp.h:736
bool b_no_PBC
Use absolute positions, ignoring PBCs when present.
Definition: colvarcomp.h:509
Colvar component (base class for collective variables)
Definition: colvarcomp.h:59
cvm::atom_group * group2
Atom group.
Definition: colvarcomp.h:773
cvm::atom_group * group3
Atom group.
Definition: colvarcomp.h:729
cvm::atom_group * group2
Second atom group.
Definition: colvarcomp.h:823
Colvar component: dihedPC Projection of the config onto a dihedral principal component See e...
Definition: colvarcomp.h:1095
cvm::quaternion ref_quat
This is used to remove jumps in the sign of the quaternion, which may be annoying in the colvars traj...
Definition: colvarcomp.h:1143
Colvar component: root mean square deviation (RMSD) of a group with respect to a set of reference coo...
Definition: colvarcomp.h:1274
virtual void debug_gradients()
Calculate finite-difference gradients alongside the analytical ones, for each Cartesian component...
Definition: colvarcomp.cpp:211
cvm::rvector r12
Inter site vectors.
Definition: colvarcomp.h:779
std::vector< cvm::atom_pos > ref_pos
Reference coordinates.
Definition: colvarcomp.h:638
Base class containing parsing functions; all objects which need to parse input inherit from this...
Definition: colvarparse.h:18
virtual const std::vector< feature * > & features()
Implementation of the feature list accessor for colvar.
Definition: colvarcomp.h:124
Colvar component: coordination number between two groups (colvarvalue::type_scalar type...
Definition: colvarcomp.h:918
A rotation between two sets of coordinates (for the moment a wrapper for colvarmodule::quaternion) ...
Definition: colvartypes.h:1369
Colvar component: angle of rotation with respect to a set of reference coordinates (colvarvalue::type...
Definition: colvarcomp.h:1166
bool b_anisotropic
Wheter dist/r0 or {dist}*{1/r0_vec} should ne be used.
Definition: colvarcomp.h:830
cvm::atom_group * group1
Atom group.
Definition: colvarcomp.h:771
cvm::real r0
"Cutoff" for isotropic calculation (default)
Definition: colvarcomp.h:825
cvm::rvector axis
Vector on which the distance vector is projected.
Definition: colvarcomp.h:383
std::vector< cvm::atom_pos > ref_pos
Reference coordinates (for RMSD calculation only)
Definition: colvarcomp.h:1283
virtual void wrap(colvarvalue &x) const
Wrapp value (for periodic/symmetric cvcs)
Definition: colvarcomp.cpp:351
void calc_fit_gradients()
Calculate the atomic fit gradients.
Definition: colvarcomp.cpp:203
cvm::real theta_tol
Tolerance on the Calpha-Calpha angle.
Definition: colvarcomp.h:1062
cvm::atom_group * atoms
Atom group.
Definition: colvarcomp.h:635
std::string name
The name of the object (helps to identify this cvc instance when debugging)
Definition: colvarcomp.h:66
bool b_no_PBC
Use absolute positions, ignoring PBCs when present.
Definition: colvarcomp.h:381
std::string function_type
Description of the type of collective variable.
Definition: colvarcomp.h:76
int setup()
After construction, set data related to dependency handling.
Definition: colvarcomp.cpp:149
cvm::atom_group * atoms
Atom group.
Definition: colvarcomp.h:1131
Colvar component: N1xN2 vector of pairwise distances (colvarvalue::type_vector type, range (0:*) for each component)
Definition: colvarcomp.h:529
bool fixed_axis
Flag: using a fixed axis vector?
Definition: colvarcomp.h:389
colvarvalue x_old
Value at the previous step.
Definition: colvarcomp.h:249
bool b_group2_center_only
If true, group2 will be treated as a single atom (default: loop over all pairs of atoms in group1 and...
Definition: colvarcomp.h:837
Group of atom objects, mostly used by a cvc object to gather all atomic data.
Definition: colvaratoms.h:142
bool b_1site_force
Definition: colvarcomp.h:693