8 #include "HarmonicAngle.h" 9 #include <util/math/Constants.h> 10 #include <util/random/Random.h> 25 for (
int i = 0; i < MaxNAngleType; ++i) {
35 : nAngleType_(other.nAngleType_)
37 for (
int i = 0; i < MaxNAngleType; ++i) {
38 kappa_[i] = other.kappa_[i];
39 theta0_[i] = other.theta0_[i];
48 nAngleType_ = other.nAngleType_;
49 for (
int i = 0; i < MaxNAngleType; ++i) {
50 kappa_[i] = other.kappa_[i];
51 theta0_[i] = other.theta0_[i];
61 if (nAngleType > MaxNAngleType) {
62 UTIL_THROW(
"nAngleType > HarmonicAngle::MaxNAngleType");
64 nAngleType_ = nAngleType;
76 readCArray<double>(in,
"kappa", kappa_, nAngleType_);
77 readCArray<double>(in,
"theta0", theta0_, nAngleType_);
80 for (
int i = 0; i < nAngleType_; ++i) {
91 loadCArray<double> (ar,
"kappa", kappa_, nAngleType_);
92 loadCArray<double>(ar,
"theta0", theta0_, nAngleType_);
101 ar.
pack(kappa_, nAngleType_);
102 ar.
pack(theta0_, nAngleType_);
112 Random *random,
double beta,
int type)
const 114 double Theta, Theta_min;
118 Theta_min = theta0_[type];
119 U_min =
energy(cos(Theta_min), type);
121 while (chosen ==
false) {
123 U =
energy(cos(Theta), type);
124 if (random->
uniform() < exp(-beta*(U-U_min))*cos(Theta)/cos(Theta_min))
138 Random *random,
double beta,
int type)
const 140 double CosineTheta, CosineTheta_min;
144 CosineTheta_min = cos(theta0_[type]);
145 U_min =
energy(CosineTheta_min, type);
147 while (chosen ==
false) {
148 CosineTheta = random->
uniform(-1, 1);
149 U =
energy(CosineTheta, type);
150 if (random->
uniform() < exp(-beta*(U-U_min)))
162 if (name ==
"kappa") {
163 kappa_[type] = value;
165 if (name ==
"theta0") {
166 theta0_[type] = value;
178 if (name ==
"kappa") {
179 value = kappa_[type];
181 if (name ==
"theta0") {
182 value = theta0_[type];
193 {
return std::string(
"HarmonicAngle"); }
double get(std::string name, int type) const
Get a parameter value, identified by a string.
void readParameters(std::istream &in)
Read angle interaction parameters from input stream.
HarmonicAngle & operator=(const HarmonicAngle &other)
Assignment.
double randomCosineAngle(Random *random, double beta, int type) const
Return bond angle cosine chosen from equilibrium distribution.
Classes used by all simpatico molecular simulations.
A angle potential that is harmonic in the angle.
double uniform()
Return a random floating point number x, uniformly distributed in the range 0 <= x < 1...
HarmonicAngle()
Default constructor.
virtual void loadParameters(Serializable::IArchive &ar)
Load internal state from an archive.
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.
double energy(double cosTheta, int type) const
Returns potential energy for one angle.
Utility classes for scientific computation.
double randomAngle(Random *random, double beta, int type) const
Return bond angle chosen from equilibrium distribution.
Saving archive for binary istream.
virtual void save(Serializable::OArchive &ar)
Save internal state to an archive.
static const double Pi
Trigonometric constant Pi.
std::string className() const
Return name string "HarmonicAngle" for this evaluator class.
#define UTIL_CHECK(condition)
Assertion macro suitable for serial or parallel production code.
void setClassName(const char *className)
Set class name string.
void setNAngleType(int nAngleType)
Set the number of angle types.
void set(std::string name, int type, double value)
Modify a parameter, identified by a string.