8 #include "HarmonicBond.h" 9 #include <util/random/Random.h> 23 for (
int i = 0; i < MaxNBondType; ++i) {
33 : nBondType_(other.nBondType_)
35 for (
int i = 0; i < nBondType_; ++i) {
36 kappa_[i] = other.kappa_[i];
37 length_[i] = other.length_[i];
46 nBondType_ = other.nBondType_;
47 for (
int i = 0; i < nBondType_; ++i) {
48 kappa_[i] = other.kappa_[i];
49 length_[i] = other.length_[i];
59 if (nBondType > MaxNBondType) {
60 UTIL_THROW(
"nBondType > HarmonicBond::MaxNBondType");
62 nBondType_ = nBondType;
71 readCArray<double>(in,
"kappa", kappa_, nBondType_);
72 readCArray<double>(in,
"length", length_, nBondType_);
81 loadCArray<double>(ar,
"kappa", kappa_, nBondType_);
82 loadCArray<double>(ar,
"length", length_, nBondType_);
91 ar.
pack(kappa_, nBondType_);
92 ar.
pack(length_, nBondType_);
121 Random *random,
double beta,
int type)
const 124 double sd = 1.0/sqrt( beta*kappa_[type] );
125 double x0 = length_[type];
126 double xm2 = length_[type] + 7.0*sd;
134 if ( x*x/xm2 >= random->
uniform(0.0,1.0) ) {
145 if (name ==
"kappa") {
146 kappa_[type] = value;
148 if (name ==
"length") {
149 length_[type] = value;
161 if (name ==
"kappa") {
162 value = kappa_[type];
164 if (name ==
"length") {
165 value = length_[type];
Classes used by all simpatico molecular simulations.
double uniform()
Return a random floating point number x, uniformly distributed in the range 0 <= x < 1...
Saving / output archive for binary ostream.
#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.
void setNBondType(int nBondType)
Set the number of bond types.
Utility classes for scientific computation.
HarmonicBond()
Default constructor.
double gaussian(void)
Return a Gaussian random number with zero average and unit variance.
HarmonicBond & operator=(const HarmonicBond &other)
Assignment.
virtual void save(Serializable::OArchive &ar)
Save internal state to an archive.
Saving archive for binary istream.
double randomBondLength(Random *random, double beta, int type) const
Return bond length chosen from equilibrium distribution.
A harmonic covalent bond potential.
#define UTIL_CHECK(condition)
Assertion macro suitable for serial or parallel production code.
void setClassName(const char *className)
Set class name string.
void set(std::string name, int type, double value)
Modify a parameter, identified by a string.
double get(std::string name, int type) const
Get a parameter value, identified by a string.
void readParameters(std::istream &in)
Read bond interaction parameters from input stream.
virtual void loadParameters(Serializable::IArchive &ar)
Load internal state from an archive.