8 #include "MultiHarmonicDihedral.h" 9 #include <util/format/Int.h> 10 #include <util/format/Dbl.h> 31 : nDihedralType_(other.nDihedralType_)
34 const Parameter* otherPtr;
35 if (nDihedralType_ > 0) {
36 parameters_.allocate(nDihedralType_);
37 for (
int i = 0; i < nDihedralType_; ++i) {
38 ptr = &(parameters_[i]);
39 otherPtr = &(other.parameters_[i]);
40 ptr->k0 = otherPtr->k0;
41 ptr->k1 = otherPtr->k1;
42 ptr->k2 = otherPtr->k2;
43 ptr->k3 = otherPtr->k3;
44 ptr->k4 = otherPtr->k4;
56 if (!parameters_.isAllocated()) {
57 nDihedralType_ = other.nDihedralType_;
58 if (nDihedralType_ > 0) {
59 parameters_.allocate(nDihedralType_);
62 if (nDihedralType_ != other.nDihedralType_) {
63 UTIL_THROW(
"Unequal values of nDihedralType_");
66 if (nDihedralType_ > 0) {
68 const Parameter* otherPtr;
69 for (
int i = 0; i < nDihedralType_; ++i) {
70 ptr = &(parameters_[i]);
71 otherPtr = &(other.parameters_[i]);
72 ptr->k0 = otherPtr->k0;
73 ptr->k1 = otherPtr->k1;
74 ptr->k2 = otherPtr->k2;
75 ptr->k3 = otherPtr->k3;
76 ptr->k4 = otherPtr->k4;
88 if (nDihedralType <= 0) {
91 nDihedralType_ = nDihedralType;
92 parameters_.allocate(nDihedralType_);
100 if (nDihedralType_ <= 0) {
101 UTIL_THROW(
"nDihedralType must be set before readParam");
105 for (
int i = 0; i < nDihedralType_; ++i) {
107 if (i != j)
UTIL_THROW(
"Inconsistent dihedral type index");
108 ptr = &(parameters_[i]);
109 in >> ptr->k0 >> ptr->k1 >> ptr->k2
110 >> ptr->k3 >> ptr->k4;
121 out.setf(std::ios_base::fixed);
122 for (
int i = 0; i < nDihedralType_; ++i) {
123 ptr = ¶meters_[i];
124 out <<
Int(i, 5) <<
" " << std::setprecision(6)
125 << std::setw(10) << ptr->k0 <<
" " 126 << std::setw(10) << ptr->k1 <<
" " 127 << std::setw(10) << ptr->k2 <<
" " 128 << std::setw(10) << ptr->k3 <<
" " 129 << std::setw(10) << ptr->k4 <<
" " 139 ar >> nDihedralType_;
140 if (nDihedralType_ <= 0) {
141 UTIL_THROW(
"nDihedralType must be positive");
143 parameters_.allocate(nDihedralType_);
145 for (
int i = 0; i < nDihedralType_; ++i) {
146 ptr = &(parameters_[i]);
168 ar << nDihedralType_;
170 for (
int i = 0; i < nDihedralType_; ++i) {
171 ptr = &(parameters_[i]);
193 Parameter* ptr = &(parameters_[type]);
220 const Parameter* ptr = &(parameters_[type]);
245 {
return std::string(
"MultiHarmonicDihedral"); }
void setNDihedralType(int nDihedralType)
Set the number of dihedral types.
Classes used by all simpatico molecular simulations.
void readParameters(std::istream &in)
Read dihedral interaction parameters from input stream.
double get(std::string name, int type) const
Get a parameter value, identified by a string.
Saving / output archive for binary ostream.
#define UTIL_THROW(msg)
Macro for throwing an Exception, reporting function, file and line number.
std::string className() const
Return name string "MultiHarmonicDihedral".
Utility classes for scientific computation.
A truncated Fourier series dihedral potential.
Wrapper for an int, for formatted ostream output.
Saving archive for binary istream.
virtual void loadParameters(Serializable::IArchive &ar)
Load internal state from an archive.
MultiHarmonicDihedral & operator=(const MultiHarmonicDihedral &other)
Assignment.
void setClassName(const char *className)
Set class name string.
virtual void save(Serializable::OArchive &ar)
Save internal state to an archive.
void writeParam(std::ostream &out)
Write Fourier coefficients to output stream.
MultiHarmonicDihedral()
Default constructor.
void set(std::string name, int type, double value)
Modify a parameter, identified by a string.