git-svn-id: svn://svn.icms.temple.edu/lammps-ro/trunk@10118 f3b2605a-c512-4ea7-a41b-209d697bcdaa
This commit is contained in:
@ -1,6 +1,16 @@
|
||||
#ifndef COLVARCOMP_H
|
||||
#define COLVARCOMP_H
|
||||
|
||||
// Declaration of colvar::cvc base class and derived ones.
|
||||
//
|
||||
// Future cvc's could be declared on additional header files.
|
||||
// After the declaration of a new derived class, its metric
|
||||
// functions must be reimplemented as well.
|
||||
// If the new cvc has no symmetry or periodicity,
|
||||
// this can be done straightforwardly by using the macro:
|
||||
// simple_scalar_dist_functions (derived_class)
|
||||
|
||||
|
||||
#include <fstream>
|
||||
#include <cmath>
|
||||
|
||||
@ -40,7 +50,7 @@
|
||||
/// 2. add a call to the parser in colvar.C, within the function colvar::colvar() \par
|
||||
/// 3. declare the class in colvarcomp.h \par
|
||||
/// 4. implement the class in one of the files colvarcomp_*.C
|
||||
///
|
||||
///
|
||||
/// </b>
|
||||
/// The cvm::atom and cvm::atom_group classes are available to
|
||||
/// transparently communicate with the simulation program. However,
|
||||
@ -58,7 +68,7 @@ public:
|
||||
std::string name;
|
||||
|
||||
/// \brief Description of the type of collective variable
|
||||
///
|
||||
///
|
||||
/// Normally this string is set by the parent \link colvar \endlink
|
||||
/// object within its constructor, when all \link cvc \endlink
|
||||
/// objects are initialized; therefore the main "config string"
|
||||
@ -94,7 +104,7 @@ public:
|
||||
|
||||
/// \brief Within the constructor, make a group parse its own
|
||||
/// options from the provided configuration string
|
||||
void parse_group (std::string const &conf,
|
||||
void parse_group (std::string const &conf,
|
||||
char const *group_key,
|
||||
cvm::atom_group &group,
|
||||
bool optional = false);
|
||||
@ -164,7 +174,7 @@ public:
|
||||
/// \brief Square distance between x1 and x2 (can be redefined to
|
||||
/// transparently implement constraints, symmetries and
|
||||
/// periodicities)
|
||||
///
|
||||
///
|
||||
/// colvar::cvc::dist2() and the related functions are
|
||||
/// declared as "const" functions, but not "static", because
|
||||
/// additional parameters defining the metrics (e.g. the
|
||||
@ -182,7 +192,7 @@ public:
|
||||
/// to provide a gradient which is compatible with the constraint,
|
||||
/// i.e. already deprived of its component normal to the constraint
|
||||
/// hypersurface.
|
||||
///
|
||||
///
|
||||
/// Finally, another useful application, if you are performing very
|
||||
/// many operations with these functions, could be to override the
|
||||
/// \link colvarvalue \endlink member functions and access directly
|
||||
@ -591,7 +601,7 @@ protected:
|
||||
std::vector<cvm::atom_pos> ref_pos;
|
||||
|
||||
/// Geometric center of the reference coordinates
|
||||
cvm::rvector ref_pos_center;
|
||||
cvm::atom_pos ref_pos_center;
|
||||
|
||||
/// Eigenvector (of a normal or essential mode): will always have zero center
|
||||
std::vector<cvm::rvector> eigenvec;
|
||||
@ -691,7 +701,7 @@ protected:
|
||||
/// \brief Compute system force on first site only to avoid unwanted
|
||||
/// coupling to other colvars (see e.g. Ciccotti et al., 2005)
|
||||
bool b_1site_force;
|
||||
|
||||
|
||||
public:
|
||||
|
||||
/// Initialize by parsing the configuration
|
||||
@ -759,7 +769,7 @@ public:
|
||||
static cvm::real switching_function (cvm::real const &r0,
|
||||
int const &exp_num, int const &exp_den,
|
||||
cvm::atom &A1, cvm::atom &A2);
|
||||
|
||||
|
||||
template<bool b_gradients>
|
||||
/// \brief Calculate a coordination number through the function
|
||||
/// (1-x**n)/(1-x**m), x = |(A1-A2)*(r0_vec)^-|1 \param r0_vec
|
||||
@ -808,7 +818,7 @@ public:
|
||||
static cvm::real switching_function (cvm::real const &r0,
|
||||
int const &exp_num, int const &exp_den,
|
||||
cvm::atom &A1, cvm::atom &A2);
|
||||
|
||||
|
||||
virtual cvm::real dist2 (colvarvalue const &x1,
|
||||
colvarvalue const &x2) const;
|
||||
virtual colvarvalue dist2_lgrad (colvarvalue const &x1,
|
||||
@ -822,7 +832,7 @@ public:
|
||||
/// \brief Colvar component: hydrogen bond, defined as the product of
|
||||
/// a colvar::coordnum and 1/2*(1-cos((180-ang)/ang_tol))
|
||||
/// (colvarvalue::type_scalar type, range [0:1])
|
||||
class colvar::h_bond
|
||||
class colvar::h_bond
|
||||
: public colvar::cvc
|
||||
{
|
||||
protected:
|
||||
@ -887,7 +897,7 @@ public:
|
||||
// alpha_dihedrals();
|
||||
// virtual inline ~alpha_dihedrals() {}
|
||||
// virtual void calc_value();
|
||||
// virtual void calc_gradients();
|
||||
// virtual void calc_gradients();
|
||||
// virtual void apply_force (colvarvalue const &force);
|
||||
// virtual cvm::real dist2 (colvarvalue const &x1,
|
||||
// colvarvalue const &x2) const;
|
||||
@ -921,7 +931,7 @@ protected:
|
||||
/// List of hydrogen bonds
|
||||
std::vector<h_bond *> hb;
|
||||
|
||||
/// Contribution of the hb terms
|
||||
/// Contribution of the hb terms
|
||||
cvm::real hb_coeff;
|
||||
|
||||
public:
|
||||
@ -1140,6 +1150,62 @@ public:
|
||||
};
|
||||
|
||||
|
||||
|
||||
// metrics functions for cvc implementations
|
||||
|
||||
// simple definitions of the distance functions; these are useful only
|
||||
// for optimization (the type check performed in the default
|
||||
// colvarcomp functions is skipped)
|
||||
|
||||
// definitions assuming the scalar type
|
||||
|
||||
#define simple_scalar_dist_functions(TYPE) \
|
||||
\
|
||||
inline cvm::real colvar::TYPE::dist2 (colvarvalue const &x1, \
|
||||
colvarvalue const &x2) const \
|
||||
{ \
|
||||
return (x1.real_value - x2.real_value)*(x1.real_value - x2.real_value); \
|
||||
} \
|
||||
\
|
||||
inline colvarvalue colvar::TYPE::dist2_lgrad (colvarvalue const &x1, \
|
||||
colvarvalue const &x2) const \
|
||||
{ \
|
||||
return 2.0 * (x1.real_value - x2.real_value); \
|
||||
} \
|
||||
\
|
||||
inline colvarvalue colvar::TYPE::dist2_rgrad (colvarvalue const &x1, \
|
||||
colvarvalue const &x2) const \
|
||||
{ \
|
||||
return this->dist2_lgrad (x2, x1); \
|
||||
} \
|
||||
\
|
||||
inline cvm::real colvar::TYPE::compare (colvarvalue const &x1, \
|
||||
colvarvalue const &x2) const \
|
||||
{ \
|
||||
return this->dist2_lgrad (x1, x2); \
|
||||
} \
|
||||
\
|
||||
|
||||
simple_scalar_dist_functions (distance)
|
||||
// NOTE: distance_z has explicit functions, see below
|
||||
simple_scalar_dist_functions (distance_xy)
|
||||
simple_scalar_dist_functions (distance_inv)
|
||||
simple_scalar_dist_functions (angle)
|
||||
simple_scalar_dist_functions (coordnum)
|
||||
simple_scalar_dist_functions (selfcoordnum)
|
||||
simple_scalar_dist_functions (h_bond)
|
||||
simple_scalar_dist_functions (gyration)
|
||||
simple_scalar_dist_functions (inertia)
|
||||
simple_scalar_dist_functions (inertia_z)
|
||||
simple_scalar_dist_functions (rmsd)
|
||||
simple_scalar_dist_functions (orientation_angle)
|
||||
simple_scalar_dist_functions (tilt)
|
||||
simple_scalar_dist_functions (eigenvector)
|
||||
// simple_scalar_dist_functions (alpha_dihedrals)
|
||||
simple_scalar_dist_functions (alpha_angles)
|
||||
simple_scalar_dist_functions (dihedPC)
|
||||
|
||||
|
||||
// metrics functions for cvc implementations with a periodicity
|
||||
|
||||
inline cvm::real colvar::dihedral::dist2 (colvarvalue const &x1,
|
||||
@ -1177,12 +1243,12 @@ inline void colvar::dihedral::wrap (colvarvalue &x) const
|
||||
if ((x.real_value - wrap_center) >= 180.0) {
|
||||
x.real_value -= 360.0;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if ((x.real_value - wrap_center) < -180.0) {
|
||||
x.real_value += 360.0;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
@ -1222,68 +1288,16 @@ inline void colvar::spin_angle::wrap (colvarvalue &x) const
|
||||
if ((x.real_value - wrap_center) >= 180.0) {
|
||||
x.real_value -= 360.0;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if ((x.real_value - wrap_center) < -180.0) {
|
||||
x.real_value += 360.0;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
// simple definitions of the distance functions; these are useful only
|
||||
// for optimization (the type check performed in the default
|
||||
// colvarcomp functions is skipped)
|
||||
|
||||
// definitions assuming the scalar type
|
||||
|
||||
#define simple_scalar_dist_functions(TYPE) \
|
||||
\
|
||||
inline cvm::real colvar::TYPE::dist2 (colvarvalue const &x1, \
|
||||
colvarvalue const &x2) const \
|
||||
{ \
|
||||
return (x1.real_value - x2.real_value)*(x1.real_value - x2.real_value); \
|
||||
} \
|
||||
\
|
||||
inline colvarvalue colvar::TYPE::dist2_lgrad (colvarvalue const &x1, \
|
||||
colvarvalue const &x2) const \
|
||||
{ \
|
||||
return 2.0 * (x1.real_value - x2.real_value); \
|
||||
} \
|
||||
\
|
||||
inline colvarvalue colvar::TYPE::dist2_rgrad (colvarvalue const &x1, \
|
||||
colvarvalue const &x2) const \
|
||||
{ \
|
||||
return this->dist2_lgrad (x2, x1); \
|
||||
} \
|
||||
\
|
||||
inline cvm::real colvar::TYPE::compare (colvarvalue const &x1, \
|
||||
colvarvalue const &x2) const \
|
||||
{ \
|
||||
return this->dist2_lgrad (x1, x2); \
|
||||
} \
|
||||
\
|
||||
|
||||
simple_scalar_dist_functions (distance)
|
||||
// NOTE: distance_z has explicit functions, see below
|
||||
simple_scalar_dist_functions (distance_xy)
|
||||
simple_scalar_dist_functions (distance_inv)
|
||||
simple_scalar_dist_functions (angle)
|
||||
simple_scalar_dist_functions (coordnum)
|
||||
simple_scalar_dist_functions (selfcoordnum)
|
||||
simple_scalar_dist_functions (h_bond)
|
||||
simple_scalar_dist_functions (gyration)
|
||||
simple_scalar_dist_functions (inertia)
|
||||
simple_scalar_dist_functions (inertia_z)
|
||||
simple_scalar_dist_functions (rmsd)
|
||||
simple_scalar_dist_functions (orientation_angle)
|
||||
simple_scalar_dist_functions (tilt)
|
||||
simple_scalar_dist_functions (eigenvector)
|
||||
// simple_scalar_dist_functions (alpha_dihedrals)
|
||||
simple_scalar_dist_functions (alpha_angles)
|
||||
simple_scalar_dist_functions (dihedPC)
|
||||
|
||||
|
||||
// Projected distance
|
||||
// Differences should always be wrapped around 0 (ignoring wrap_center)
|
||||
@ -1422,9 +1436,6 @@ inline cvm::real colvar::orientation::compare (colvarvalue const &x1,
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user