1 #ifndef SIMP_PERIODIC_EXTERNAL_H 2 #define SIMP_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_;
172 double interfaceWidth_;
192 const Vector cellLengths = boundaryPtr_->lengths();
193 double clipParameter = 1.0/(2.0*M_PI*periodicity_*interfaceWidth_);
198 for (
int i = 0; i < nWaveVectors_; ++i) {
200 q[0] = 2.0*M_PI*periodicity_*waveVectors_[i][0]/cellLengths[0];
201 q[1] = 2.0*M_PI*periodicity_*waveVectors_[i][1]/cellLengths[1];
202 q[2] = 2.0*M_PI*periodicity_*waveVectors_[i][2]/cellLengths[2];
203 double arg = q.
dot(r)+phases_[i];
206 cosine *= clipParameter;
207 return prefactor_[type]*externalParameter_*tanh(C_+cosine);
217 const Vector cellLengths = boundaryPtr_->lengths();
218 double clipParameter = 1.0/(2.0*M_PI*periodicity_*interfaceWidth_);
225 for (
int i = 0; i < nWaveVectors_; ++i) {
227 q[0] = 2.0*M_PI*periodicity_*waveVectors_[i][0]/cellLengths[0];
228 q[1] = 2.0*M_PI*periodicity_*waveVectors_[i][1]/cellLengths[1];
229 q[2] = 2.0*M_PI*periodicity_*waveVectors_[i][2]/cellLengths[2];
230 double arg = q.
dot(r)+phases_[i];
232 double sine = -1.0*sin(arg);
236 cosine *= clipParameter;
237 deriv *= clipParameter;
238 double tanH = tanh(C_+cosine);
239 double sechSq = (1.0 - tanH*tanH);
240 double f = prefactor_[type]*externalParameter_*sechSq;
Vector & zero()
Set all elements of a 3D vector to zero.
A Vector is a Cartesian vector.
void setExternalParameter(double externalParameter)
Sets external parameter.
void setBoundary(Boundary &boundary)
Set pointer to Boundary.
double dot(const Vector &v) const
Return dot product of this vector and vector v.
An orthorhombic periodic unit cell.
virtual void save(Serializable::OArchive &ar)
Save internal state to an archive.
void readParameters(std::istream &in)
Read potential parameters, and initialize other variables.
double energy(const Vector &position, int i) const
Returns external potential energy of a single particle.
File containing preprocessor macros for error handling.
Classes used by all simpatico molecular simulations.
void getForce(const Vector &position, int type, Vector &force) const
Returns force caused by the external potential.
std::string className() const
Return name string "PeriodicExternal".
Saving / output archive for binary ostream.
Utility classes for scientific computation.
double externalParameter() const
Returns external parameter.
Saving archive for binary istream.
A clipped cosine potential that induces ordering along directions specified by waveIntVectors, w_i.
PeriodicExternal()
Default constructor.
void setNAtomType(int nAtomType)
Set nAtomType value.
PeriodicExternal & operator=(const PeriodicExternal &other)
Assignment.
virtual void loadParameters(Serializable::IArchive &ar)
Load internal state from an archive.
An object that can read multiple parameters from file.