1 #ifndef SIMP_GENERAL_PERIODIC_EXTERNAL_H 2 #define SIMP_GENERAL_PERIODIC_EXTERNAL_H 11 #include <simp/boundary/Boundary.h> 12 #include <util/space/Dimension.h> 13 #include <util/space/Vector.h> 14 #include <util/param/ParamComposite.h> 105 void set(std::string name,
double value);
110 double get(std::string name)
const;
145 static const int MaxAtomType = 3;
151 double externalParameter_;
169 double interfaceWidth_;
189 const Vector cellLengths = boundaryPtr_->lengths();
190 double clipParameter = 1.0/(2.0*M_PI*periodicity_*interfaceWidth_);
197 for (
int i = 0; i < nWaveVectors_; ++i) {
200 a[j] = shifts_[i*Dimension + j];
204 q[0] = 2.0*M_PI*periodicity_*waveVectors_[i][0]/cellLengths[0];
205 q[1] = 2.0*M_PI*periodicity_*waveVectors_[i][1]/cellLengths[1];
206 q[2] = 2.0*M_PI*periodicity_*waveVectors_[i][2]/cellLengths[2];
207 double arg = q.
dot(r)+phases_[i];
208 cosine += prefactor_[i*nAtomType_ + type]*cos(arg);
210 cosine *= clipParameter;
211 return externalParameter_*tanh(cosine);
221 const Vector cellLengths = boundaryPtr_->lengths();
222 double clipParameter = 1.0/(2.0*M_PI*periodicity_*interfaceWidth_);
231 for (
int i = 0; i < nWaveVectors_; ++i) {
234 a[j] = shifts_[i*Dimension + j];
238 q[0] = 2.0*M_PI*periodicity_*waveVectors_[i][0]/cellLengths[0];
239 q[1] = 2.0*M_PI*periodicity_*waveVectors_[i][1]/cellLengths[1];
240 q[2] = 2.0*M_PI*periodicity_*waveVectors_[i][2]/cellLengths[2];
241 double arg = q.
dot(r)+phases_[i];
242 cosine += prefactor_[i*nAtomType_ + type]*cos(arg);
243 double sine = -1.0*sin(arg);
244 q *= prefactor_[i*nAtomType_ + type]*sine;
247 cosine *= clipParameter;
248 deriv *= clipParameter;
249 double tanH = tanh(cosine);
250 double sechSq = (1.0 - tanH*tanH);
251 double f = externalParameter_*sechSq;
virtual void save(Serializable::OArchive &ar)
Save internal state to an archive.
Vector & zero()
Set all elements of a 3D vector to zero.
const int Dimension
Dimensionality of space.
A Vector is a Cartesian vector.
virtual void loadParameters(Serializable::IArchive &ar)
Load internal state from an archive.
double dot(const Vector &v) const
Return dot product of this vector and vector v.
void readParameters(std::istream &in)
Read potential parameters, and initialize other variables.
An orthorhombic periodic unit cell.
void setNAtomType(int nAtomType)
Set nAtomType value.
File containing preprocessor macros for error handling.
Classes used by all simpatico molecular simulations.
double externalParameter() const
Returns external parameter.
Saving / output archive for binary ostream.
Utility classes for scientific computation.
std::string className() const
Return name string "GeneralPeriodicExternal".
void getForce(const Vector &position, int type, Vector &force) const
Returns force caused by the external potential.
GeneralPeriodicExternal()
Default constructor.
double energy(const Vector &position, int i) const
Returns external potential energy of a single particle.
Saving archive for binary istream.
A clipped cosine potential that induces ordering along directions specified by waveIntVectors, w_i.
An object that can read multiple parameters from file.
void setExternalParameter(double externalParameter)
Sets external parameter.
GeneralPeriodicExternal & operator=(const GeneralPeriodicExternal &other)
Assignment.
void setBoundary(Boundary &boundary)
Set pointer to Boundary.