9 #include "CosineAngle.h" 10 #include <util/math/Constants.h> 11 #include <util/random/Random.h> 25 for (
int i = 0; i < MaxNAngleType; ++i) {
34 : nAngleType_(other.nAngleType_)
36 assert(other.nAngleType_ > 0);
37 for (
int i = 0; i < nAngleType_; ++i) {
38 kappa_[i] = other.kappa_[i];
53 assert(other.nAngleType_ > 0);
55 nAngleType_ = other.nAngleType_;
56 for (
int i = 0; i < nAngleType_; ++i) {
57 kappa_[i] = other.kappa_[i];
67 if (nAngleType > MaxNAngleType) {
68 UTIL_THROW(
"nAngleType > CosineAngle::MaxNAngleType");
70 nAngleType_ = nAngleType;
79 readCArray<double>(in,
"kappa", kappa_, nAngleType_);
88 loadCArray<double> (ar,
"kappa", kappa_, nAngleType_);
97 ar.
pack(kappa_, nAngleType_);
108 double Theta, Theta_min;
113 U_min =
energy(cos(Theta_min), type);
115 while (chosen ==
false) {
117 U =
energy(cos(Theta), type);
118 if (random->
uniform() < exp(-beta*(U-U_min))*cos(Theta)/cos(Theta_min))
133 double CosineTheta, CosineTheta_min;
138 U_min =
energy(CosineTheta_min, type);
140 while (chosen ==
false) {
141 CosineTheta = random->
uniform(-1, 1);
142 U =
energy(CosineTheta, type);
143 if (random->
uniform() < exp(-beta*(U-U_min)))
155 if (name ==
"kappa") {
156 kappa_[type] = value;
168 if (name ==
"kappa") {
169 value = kappa_[type];
180 {
return std::string(
"CosineAngle"); }
std::string className() const
Return name string "CosineAngle" for this evaluator class.
CosineAngle & operator=(const CosineAngle &other)
Assignment.
void setNAngleType(int nAngleType)
Set the number of angle types.
double randomAngle(Random *random, double beta, int type) const
Return bond angle chosen from equilibrium distribution.
A three body angle potential, as a function of angle cosine.
File containing preprocessor macros for error handling.
Classes used by all simpatico molecular simulations.
double uniform()
Return a random floating point number x, uniformly distributed in the range 0 <= x < 1...
double energy(double cosTheta, int type) const
Returns potential energy for one angle.
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.
virtual void loadParameters(Serializable::IArchive &ar)
Load internal state from an archive.
Utility classes for scientific computation.
double randomCosineAngle(Random *random, double beta, int type) const
Return bond angle cosine chosen from equilibrium distribution.
virtual void save(Serializable::OArchive &ar)
Save internal state to an archive.
~CosineAngle()
Destructor.
Saving archive for binary istream.
CosineAngle()
Default constructor.
static const double Pi
Trigonometric constant Pi.
void readParameters(std::istream &in)
Read angle interaction parameters from input stream.
#define UTIL_CHECK(condition)
Assertion macro suitable for serial or parallel production code.
double get(std::string name, int type) const
Get a parameter value, identified by a string.
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.