Skip to content
Snippets Groups Projects
Commit b468b706 authored by Giovanni Bussi's avatar Giovanni Bussi
Browse files

Added possibility to compute torsion on a different axis

See TORSION manual.
parent f0a3576e
No related branches found
No related tags found
No related merge requests found
...@@ -12,14 +12,24 @@ namespace PLMD{ ...@@ -12,14 +12,24 @@ namespace PLMD{
//+PLUMEDOC COLVAR TORSION //+PLUMEDOC COLVAR TORSION
/** /**
Calculate the torsion between four atoms Calculate the torsion between four atoms.
\par Syntax \par Syntax
\verbatim \verbatim
TORSION ATOMS=x,y,z,t [PBC] TORSION ATOMS=a0,a1,a2,a3 [PBC]
\endverbatim \endverbatim
If the PBC flag is present, distance is computed using periodic boundary conditions. If the PBC flag is present, distance is computed using periodic boundary conditions.
Alternatively, compute the angle between two vectors projected on the plane
orthogonal to an axis, such as
\verbatim
TORSION V1=a0,a1 AXIS=a2,a3 V2=a4,a5
\endverbatim
Thus, two following variables are exactly the same one:
\verbatim
TORSION ATOMS=a0,a1,a2,a3
TORSION V1=a1,a0 AXIS=a1,a2 V2=a2,a3
\endverbatim
*/ */
//+ENDPLUMEDOC //+ENDPLUMEDOC
...@@ -38,8 +48,12 @@ ColvarTorsion::ColvarTorsion(const ActionOptions&ao): ...@@ -38,8 +48,12 @@ ColvarTorsion::ColvarTorsion(const ActionOptions&ao):
PLUMED_COLVAR_INIT(ao), PLUMED_COLVAR_INIT(ao),
pbc(true) pbc(true)
{ {
vector<AtomNumber> atoms; vector<AtomNumber> atoms,v1,v2,axis;
parseAtomList("ATOMS",atoms); parseAtomList("ATOMS",atoms);
parseAtomList("VECTOR1",v1);
parseAtomList("VECTOR2",v2);
parseAtomList("AXIS",axis);
bool nopbc=!pbc; bool nopbc=!pbc;
parseFlag("NOPBC",nopbc); parseFlag("NOPBC",nopbc);
pbc=!nopbc; pbc=!nopbc;
...@@ -47,12 +61,24 @@ pbc(true) ...@@ -47,12 +61,24 @@ pbc(true)
checkRead(); checkRead();
if(atoms.size()==4){ if(atoms.size()==4){
assert(v1.size()==0 && v2.size()==0 && axis.size()==0);
log.printf(" between atoms %d %d %d %d\n",atoms[0].serial(),atoms[1].serial(),atoms[2].serial(),atoms[3].serial()); log.printf(" between atoms %d %d %d %d\n",atoms[0].serial(),atoms[1].serial(),atoms[2].serial(),atoms[3].serial());
atoms.resize(6); atoms.resize(6);
atoms[5]=atoms[3]; atoms[5]=atoms[3];
atoms[4]=atoms[2]; atoms[4]=atoms[2];
atoms[3]=atoms[2]; atoms[3]=atoms[2];
atoms[2]=atoms[1]; atoms[2]=atoms[1];
}else if(atoms.size()==0){
assert(v1.size()==2 && v2.size()==2 && axis.size()==2);
log.printf(" between lines %d-%d and %d-%d, projected on the plane orthogonal to line %d-%d\n",
v1[0].serial(),v1[1].serial(),v2[0].serial(),v2[1].serial(),axis[0].serial(),axis[1].serial());
atoms.resize(6);
atoms[0]=v1[1];
atoms[1]=v1[0];
atoms[2]=axis[0];
atoms[3]=axis[1];
atoms[4]=v2[0];
atoms[5]=v2[1];
}else assert(0); }else assert(0);
if(pbc) log.printf(" using periodic boundary conditions\n"); if(pbc) log.printf(" using periodic boundary conditions\n");
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment