8 #include "PeriodicExternal.h" 20 : externalParameter_(),
34 : externalParameter_(other.externalParameter_),
35 nWaveVectors_(other.nWaveVectors_),
37 periodicity_(other.periodicity_),
38 interfaceWidth_(other.interfaceWidth_),
39 boundaryPtr_(other.boundaryPtr_),
40 nAtomType_(other.nAtomType_),
41 isInitialized_(other.isInitialized_)
44 for (
int i=0; i < nAtomType_; ++i) {
45 prefactor_[i] = other.prefactor_[i];
47 waveVectors_.allocate(nWaveVectors_);
49 for (
int i=0; i < nWaveVectors_; ++i) {
50 waveVectors_[i][j] = other.waveVectors_[i][j];
54 for (
int i=0; i < nWaveVectors_; ++i) {
55 phases_[i] = other.phases_[i];
58 shift_[i] = other.shift_[i];
67 externalParameter_ = other.externalParameter_;
68 nWaveVectors_ = other.nWaveVectors_;
70 periodicity_ = other.periodicity_;
71 interfaceWidth_ = other.interfaceWidth_;
72 boundaryPtr_ = other.boundaryPtr_;
73 nAtomType_ = other.nAtomType_;
74 isInitialized_ = other.isInitialized_;
75 for (
int i=0; i < nAtomType_; ++i) {
76 prefactor_[i] = other.prefactor_[i];
79 for (
int i=0; i < nWaveVectors_; ++i) {
80 waveVectors_[i][j] = other.waveVectors_[i][j];
84 for (
int i=0; i < nWaveVectors_; ++i) {
85 phases_[i] = other.phases_[i];
88 shift_[i] = other.shift_[i];
101 if (nAtomType > MaxAtomType) {
102 UTIL_THROW(
"nAtomType > PeriodicExternal::MaxAtomType");
104 nAtomType_ = nAtomType;
110 if (!isInitialized_) {
111 UTIL_THROW(
"PeriodicExternal potential is not initialized");
122 { boundaryPtr_ = &boundary; }
134 readDArray<double>(in,
"prefactor", prefactor_, nAtomType_);
135 read<double>(in,
"externalParameter", externalParameter_);
136 read<int>(in,
"nWaveVectors", nWaveVectors_);
137 read<double>(in,
"C", C_);
138 waveVectors_.allocate(nWaveVectors_);
139 readDArray<Vector>(in,
"waveVectors", waveVectors_, nWaveVectors_);
141 readDArray<double>(in,
"phases", phases_, nWaveVectors_);
142 read<Vector>(in,
"shift", shift_);
143 read<double>(in,
"interfaceWidth", interfaceWidth_);
144 read<int>(in,
"periodicity", periodicity_);
146 isInitialized_ =
true;
156 loadDArray<double>(ar,
"prefactor", prefactor_, nAtomType_);
157 loadParameter<double>(ar,
"externalParameter", externalParameter_);
158 loadParameter<int>(ar,
"nWavevectors", nWaveVectors_);
159 loadParameter<double>(ar,
"C", C_);
160 waveVectors_.allocate(nWaveVectors_);
161 loadDArray<Vector>(ar,
"waveVectors", waveVectors_, nWaveVectors_);
163 loadDArray<double>(ar,
"phases", phases_, nWaveVectors_);
164 loadParameter<Vector>(ar,
"shift", shift_);
165 loadParameter<double>(ar,
"interfaceWidth", interfaceWidth_);
166 loadParameter<int>(ar,
"periodicity", periodicity_);
167 isInitialized_ =
true;
176 ar << externalParameter_;
182 ar << interfaceWidth_;
189 void PeriodicExternal::set(std::string name,
double value)
191 if (name ==
"externalParameter") {
192 externalParameter_ = value;
197 if (name ==
"interfaceWidth") {
198 interfaceWidth_ = value;
200 if (name ==
"periodicity") {
201 periodicity_ = value;
210 double PeriodicExternal::get(std::string name)
const 213 if (name ==
"externalParameter") {
214 value = externalParameter_;
219 if (name ==
"interfaceWidth") {
220 value = interfaceWidth_;
222 if (name ==
"periodicity") {
223 value = periodicity_;
232 return externalParameter_;
239 {
return std::string(
"PeriodicExternal"); }
const int Dimension
Dimensionality of space.
void setExternalParameter(double externalParameter)
Sets external parameter.
void setBoundary(Boundary &boundary)
Set pointer to Boundary.
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.
Classes used by all simpatico molecular simulations.
std::string className() const
Return name string "PeriodicExternal".
Saving / output archive for binary ostream.
#define UTIL_THROW(msg)
Macro for throwing an Exception, reporting function, file and line number.
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.
#define UTIL_CHECK(condition)
Assertion macro suitable for serial or parallel production code.
void setClassName(const char *className)
Set class name string.
PeriodicExternal()
Default constructor.
void setNAtomType(int nAtomType)
Set nAtomType value.
void allocate(int capacity)
Allocate the underlying C array.
PeriodicExternal & operator=(const PeriodicExternal &other)
Assignment.
virtual void loadParameters(Serializable::IArchive &ar)
Load internal state from an archive.