24 #include "tools/Vector.h"
25 #include "tools/Exception.h"
65 static void registerKeywords(
Keywords& keys );
68 PLUMED_REGISTER_ACTION(
Ghost,
"GHOST")
71 ActionWithVirtualAtom::registerKeywords(keys);
72 keys.add(
"atoms",
"COORDINATES",
"coordinates of the ghost atom in the local reference frame");
79 vector<AtomNumber>
atoms;
81 if(atoms.size()!=3)
error(
"ATOMS should contain a list of three atoms");
84 if(
coord.size()!=3)
error(
"COORDINATES should be a list of three real numbers");
88 for(
unsigned i=0;i<atoms.size();++i)
log.
printf(
" %d",atoms[i].serial());
90 log<<
" WARNING: GHOST does not include virial contributions, please avoid using it with constant pressure molecular dynamics\n";
101 n.push_back(n01/n01.
modulo());
108 double n03_norm = n03.
modulo();
109 n.push_back(n03/n03_norm);
117 for(
unsigned i=0;i<3;++i){
118 pos +=
coord[i] * n[i];
132 Tensor dn1d0, dn1d1, dn1d2;
135 for(
unsigned j=0;j<3;++j){
137 Vector tmp00 =
Vector( dn0d0(j,0), dn0d0(j,1), dn0d0(j,2));
138 Vector tmp020 =
Vector(dn02d0(j,0), dn02d0(j,1), dn02d0(j,2));
142 Vector tmp01 =
Vector( dn0d1(j,0), dn0d1(j,1), dn0d1(j,2));
146 Vector tmp022 =
Vector(dn02d2(j,0), dn02d2(j,1), dn02d2(j,2));
150 for(
unsigned i=0;i<3;++i) {
151 dn1d0(j,i) = ( tmp0[i] - aux0[j] * n[1][i] ) / n03_norm;
152 dn1d1(j,i) = ( tmp1[i] - aux1[j] * n[1][i] ) / n03_norm;
153 dn1d2(j,i) = ( tmp2[i] - aux2[j] * n[1][i] ) / n03_norm;
160 Vector dn0_n02d0, dn0_n02d1, dn0_n02d2;
162 for(
unsigned j=0;j<3;++j){
163 for(
unsigned i=0;i<3;++i){
164 dn0_n02d0[j] += dn0d0(j,i)*n02[i] + n[0][i]*dn02d0(j,i);
165 dn0_n02d1[j] += dn0d1(j,i)*n02[i];
166 dn0_n02d2[j] += n[0][i]*dn02d2(j,i);
170 Tensor dn2d0, dn2d1, dn2d2;
171 for(
unsigned j=0;j<3;++j){
172 for(
unsigned i=0;i<3;++i){
173 dn2d0(j,i) = ( dn0d0(j,i) * n0_n02 + n[0][i] * dn0_n02d0[j] - dn02d0(j,i) - ( n[0][i] * n0_n02 - n02[i] ) * aux0[j] / n03_norm ) / n03_norm;
174 dn2d1(j,i) = ( dn0d1(j,i) * n0_n02 + n[0][i] * dn0_n02d1[j] - ( n[0][i] * n0_n02 - n02[i] ) * aux1[j] / n03_norm ) / n03_norm;
175 dn2d2(j,i) = ( n[0][i] * dn0_n02d2[j] - dn02d2(j,i) - ( n[0][i] * n0_n02 - n02[i] ) * aux2[j] / n03_norm ) / n03_norm;
const Vector & getPosition(int) const
Get position of i-th atom.
Log & log
Reference to the log stream.
double modulo() const
Compute the modulo.
VectorGeneric< 3 > crossProduct(const VectorGeneric< 3 > &v1, const VectorGeneric< 3 > &v2)
Class implementing fixed size matrices of doubles.
void setPosition(const Vector &)
Set position of the virtual atom.
Class implementing fixed size vectors of doubles.
void error(const std::string &msg) const
Crash calculation and print documentation.
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 setMass(double)
Set its mass.
void requestAtoms(const std::vector< AtomNumber > &a)
Request atoms on which the calculation depends.
static TensorGeneric< n, n > identity()
return an identity tensor
This class holds the keywords and their documentation.
void setAtomsDerivatives(const std::vector< Tensor > &d)
Set the derivatives of virtual atom coordinate wrt atoms on which it dependes.
This class is used to bring the relevant information to the Action constructor.
int printf(const char *fmt,...)
Formatted output with explicit format - a la printf.
Base class for all the input Actions.
void parseVector(const std::string &key, std::vector< T > &t)
Parse one keyword as std::vector.
Inherit from here if you are calculating the position of a virtual atom (eg a center of mass) ...
VectorGeneric< n > delta(const VectorGeneric< n > &v1, const VectorGeneric< n > &v2)
T dotProduct(const std::vector< T > &A, const std::vector< T > &B)
Calculate the dot product between two vectors.
void calculate()
Calculate an Action.
void setCharge(double)
Set its charge.
unsigned getNumberOfAtoms() const
Get number of available atoms.
Vector3d Vector
Alias for three dimensional vectors.
Provides the keyword GHOST