24 #include "tools/Torsion.h"
63 virtual void calculate();
64 static void registerKeywords(
Keywords& keys);
67 PLUMED_REGISTER_ACTION(
Torsion,
"TORSION")
70 Colvar::registerKeywords( keys );
71 keys.add(
"atoms-1",
"ATOMS",
"the four atoms involved in the torsional angle");
72 keys.add(
"atoms-2",
"AXIS",
"two atoms that define an axis. You can use this to find the angle in the plane perpendicular to the axis between the vectors specified using the VECTOR1 and VECTOR2 keywords.");
73 keys.add(
"atoms-2",
"VECTOR1",
"two atoms that define a vector. You can use this in combination with VECTOR2 and AXIS");
74 keys.add(
"atoms-2",
"VECTOR2",
"two atoms that define a vector. You can use this in combination with VECTOR1 and AXIS");
75 keys.addFlag(
"COSINE",
false,
"calculate cosine instead of dihedral");
83 vector<AtomNumber>
atoms,v1,v2,axis;
97 if(!(v1.empty()) && (v2.empty()) && (axis.empty()))
98 error(
"ATOMS keyword is not compatible with VECTOR1, VECTOR2 and AXIS keywords");
99 log.
printf(
" between atoms %d %d %d %d\n",atoms[0].serial(),atoms[1].serial(),atoms[2].serial(),atoms[3].serial());
105 }
else if(atoms.empty()){
106 if(!(v1.size()==2 && v2.size()==2 && axis.size()==2))
107 error(
"VECTOR1, VECTOR2 and AXIS should specify 2 atoms each");
108 log.
printf(
" between lines %d-%d and %d-%d, projected on the plane orthogonal to line %d-%d\n",
109 v1[0].serial(),v1[1].serial(),v2[0].serial(),v2[1].serial(),axis[0].serial(),axis[1].serial());
117 }
else error(
"ATOMS should specify 4 atoms");
119 if(
pbc)
log.
printf(
" using periodic boundary conditions\n");
120 else log.
printf(
" without periodic boundary conditions\n");
145 double torsion=t.
compute(d0,d1,d2,dd0,dd1,dd2);
147 dd0 *= -sin(torsion);
148 dd1 *= -sin(torsion);
149 dd2 *= -sin(torsion);
150 torsion = cos(torsion);
Class to compute torsional angles.
const Vector & getPosition(int) const
Get position of i-th atom.
void parseFlag(const std::string &key, bool &t)
Parse one keyword as boolean flag.
void setNotPeriodic()
Set your default value to have no periodicity.
Log & log
Reference to the log stream.
double compute(const Vector &v1, const Vector &v2, const Vector &v3) const
Compute the angle between the projections of v1 and v3 on the plane orthogonal to v2...
Class implementing fixed size vectors of doubles.
void setAtomsDerivatives(int, const Vector &)
void error(const std::string &msg) const
Crash calculation and print documentation.
Provides the keyword TORSION
void checkRead()
Check if Action was properly read.
void parseAtomList(const std::string &key, std::vector< AtomNumber > &t)
Parse a list of atoms without a numbered keyword.
void addValueWithDerivatives()
Add a value with the name label that has derivatives.
void requestAtoms(const std::vector< AtomNumber > &a)
#define PLUMED_COLVAR_INIT(ao)
void setBoxDerivatives(const Tensor &)
This class holds the keywords and their documentation.
This class is used to bring the relevant information to the Action constructor.
void setPeriodic(const std::string &min, const std::string &max)
Set the value to be periodic with a particular domain.
int printf(const char *fmt,...)
Formatted output with explicit format - a la printf.
This is the abstract base class to use for implementing new collective variables, within it there is ...
VectorGeneric< n > delta(const VectorGeneric< n > &v1, const VectorGeneric< n > &v2)
void setValue(const double &d)
Set the default value (the one without name)
TensorGeneric< n, m > extProduct(const VectorGeneric< n > &v1, const VectorGeneric< m > &v2)
Vector pbcDistance(const Vector &, const Vector &) const
Compute the pbc distance between two positions.
virtual void calculate()
Calculate an Action.