10 #include <util/mpi/MpiLoader.h> 23 : maxPairCutoff_(0.0),
32 : maxPairCutoff_(other.maxPairCutoff_),
33 nAtomType_(other.nAtomType_),
34 isInitialized_(other.isInitialized_)
37 for (i = 0; i < nAtomType_; ++i) {
38 for (j = 0; j < nAtomType_; ++j) {
39 epsilon_[i][j] = other.epsilon_[i][j];
40 sigma_[i][j] = other.sigma_[i][j];
41 sigmaSq_[i][j] = other.sigmaSq_[i][j];
42 ce_[i][j] = other.ce_[i][j];
43 cf_[i][j] = other.cf_[i][j];
53 maxPairCutoff_ = other.maxPairCutoff_;
54 nAtomType_ = other.nAtomType_;
55 isInitialized_ = other.isInitialized_;
57 for (i = 0; i < nAtomType_; ++i) {
58 for (j = 0; j < nAtomType_; ++j) {
59 epsilon_[i][j] = other.epsilon_[i][j];
60 sigma_[i][j] = other.sigma_[i][j];
61 sigmaSq_[i][j] = other.sigmaSq_[i][j];
62 ce_[i][j] = other.ce_[i][j];
63 cf_[i][j] = other.cf_[i][j];
75 if (nAtomType_ <= 0) {
76 UTIL_THROW(
"nAtomType must be set before readParam");
80 readCArray2D<double> (in,
"epsilon", epsilon_[0],
81 nAtomType_, nAtomType_, MaxAtomType);
82 readCArray2D<double>(in,
"sigma", sigma_[0],
83 nAtomType_, nAtomType_, MaxAtomType);
88 for (i = 0; i < nAtomType_; ++i) {
89 for (j = 0; j < nAtomType_; ++j) {
90 sigmaSq_[i][j] = sigma_[i][j]*sigma_[i][j];
91 if (sigma_[i][j] > maxPairCutoff_) {
92 maxPairCutoff_ = sigma_[i][j];
94 cf_[i][j] = epsilon_[i][j]/sigmaSq_[i][j];
95 ce_[i][j] = 0.5*cf_[i][j];
99 isInitialized_ =
true;
108 if (nAtomType_ <= 0) {
109 UTIL_THROW(
"nAtomType must be set before loadParameters");
113 loadCArray2D<double> (ar,
"epsilon", epsilon_[0],
114 nAtomType_, nAtomType_, MaxAtomType);
115 loadCArray2D<double>(ar,
"sigma", sigma_[0],
116 nAtomType_, nAtomType_, MaxAtomType);
120 loader.load(sigmaSq_[0], nAtomType_, nAtomType_, MaxAtomType);
121 loader.load(cf_[0], nAtomType_, nAtomType_, MaxAtomType);
122 loader.load(ce_[0], nAtomType_, nAtomType_, MaxAtomType);
123 loader.load(maxPairCutoff_);
125 ar.unpack(sigmaSq_[0], nAtomType_, nAtomType_, MaxAtomType);
126 ar.unpack(cf_[0], nAtomType_, nAtomType_, MaxAtomType);
127 ar.unpack(ce_[0], nAtomType_, nAtomType_, MaxAtomType);
128 ar >> maxPairCutoff_;
130 isInitialized_ =
true;
138 ar.
pack(epsilon_[0], nAtomType_, nAtomType_, MaxAtomType);
139 ar.
pack(sigma_[0], nAtomType_, nAtomType_, MaxAtomType);
140 ar.
pack(sigmaSq_[0], nAtomType_, nAtomType_, MaxAtomType);
141 ar.
pack(cf_[0], nAtomType_, nAtomType_, MaxAtomType);
142 ar.
pack(ce_[0], nAtomType_, nAtomType_, MaxAtomType);
143 ar << maxPairCutoff_;
151 if (nAtomType <= 0) {
154 if (nAtomType > MaxAtomType) {
155 UTIL_THROW(
"nAtomType > DpdPair::MaxAtomType");
157 nAtomType_ = nAtomType;
167 if (!isInitialized_) {
168 UTIL_THROW(
"Cannot modify epsilon before DpdPair is initialized");
170 if (i < 0 || i >= nAtomType_) {
173 if (j < 0 || j >= nAtomType_) {
178 cf_[i][j] = epsilon_[i][j]/sigmaSq_[i][j];
179 ce_[i][j] = 0.5*cf_[i][j];
183 cf_[j][i] = cf_[i][j];
184 ce_[j][i] = ce_[i][j];
195 if (!isInitialized_) {
196 UTIL_THROW(
"Cannot modify sigma before DpdPair is initialized");
198 if (i < 0 || i >= nAtomType_) {
201 if (j < 0 || j >= nAtomType_) {
205 sigma_[i][j] =
sigma;
206 sigmaSq_[i][j] = sigma*
sigma;
207 cf_[i][j] = epsilon_[i][j]/sigmaSq_[i][j];
208 ce_[i][j] = 0.5*cf_[i][j];
212 sigma_[j][i] =
sigma;
213 sigmaSq_[j][i] = sigmaSq_[i][j];
214 cf_[j][i] = cf_[i][j];
215 ce_[j][i] = ce_[i][j];
225 assert(i >= 0 && i < nAtomType_);
226 assert(j >= 0 && j < nAtomType_);
227 return epsilon_[i][j];
235 assert(i >= 0 && i < nAtomType_);
236 assert(j >= 0 && j < nAtomType_);
244 {
return maxPairCutoff_; }
251 if (name ==
"epsilon") {
252 epsilon_[i][j] = value;
253 epsilon_[j][i] = value;
255 if (name ==
"sigma") {
256 sigma_[i][j] = value;
257 sigma_[j][i] = value;
269 if (name ==
"epsilon") {
270 value = epsilon_[i][j];
272 if (name ==
"sigma") {
273 value = sigma_[i][j];
double get(std::string name, int i, int j) const
Get a parameter value, identified by a string.
void setEpsilon(int i, int j, double epsilon)
Set LJ interaction energy for a specific pair of Atom types.
Soft pair potential used in dissipative particle dynamics (DPD) simulations of Groot, Warren et al.
Classes used by all simpatico molecular simulations.
Saving / output archive for binary ostream.
double sigma(int i, int j) const
Get range for a specific pair of Atom types.
DpdPair & operator=(const DpdPair &other)
Assignment.
#define UTIL_THROW(msg)
Macro for throwing an Exception, reporting function, file and line number.
void pack(const T &data)
Pack one object of type T.
virtual void save(Serializable::OArchive &ar)
Save internal state to an archive.
Utility classes for scientific computation.
void set(std::string name, int i, int j, double value)
Modify a parameter, identified by a string.
void readParameters(std::istream &in)
Read epsilon and sigma, initialize other variables.
Saving archive for binary istream.
Provides methods for MPI-aware loading of data from input archive.
void setClassName(const char *className)
Set class name string.
void setSigma(int i, int j, double sigma)
Get LJ range for a specific pair of Atom types.
double epsilon(int i, int j) const
Get interaction energy for a specific pair of Atom types.
double maxPairCutoff() const
Get maximum of pair cutoff distance, for all atom type pairs.
virtual void loadParameters(Serializable::IArchive &ar)
Load internal state from an archive.
void setNAtomType(int nAtomType)
Set nAtomType value.