8 #include "MdEnergyOutput.h" 10 #include <util/misc/FileMaster.h> 11 #include <util/format/Dbl.h> 12 #include <util/format/Int.h> 22 MdEnergyOutput::MdEnergyOutput(MdSystem& system) :
23 SystemAnalyzer<MdSystem>(system)
58 double potential = 0.0;
62 outputFile_ <<
Dbl(pair);
67 outputFile_ << Dbl(bond);
70 if (
system().hasAnglePotential()) {
73 outputFile_ << Dbl(angle);
77 if (
system().hasDihedralPotential()) {
79 potential += dihedral;
80 outputFile_ << Dbl(dihedral);
84 if (
system().hasCoulombPotential()) {
86 potential += coulombk;
87 outputFile_ << Dbl(coulombk);
91 if (
system().hasExternalPotential()) {
93 potential += external;
94 outputFile_ << Dbl(external);
98 if (
system().hasSpecialPotential()) {
99 double special =
system().specialPotential().energy();
100 potential += special;
101 outputFile_ << Dbl(special);
105 if (
system().hasLinkPotential()) {
108 outputFile_ << Dbl(link);
112 if (
system().hasTetherPotential()) {
113 double tether =
system().tetherPotential().energy();
115 outputFile_ << Dbl(tether);
118 outputFile_ << Dbl(potential);
120 outputFile_ << Dbl(kinetic);
121 double total = potential + kinetic;
122 outputFile_ << Dbl(total) << std::endl;
137 outputFile_ << std::endl;
139 outputFile_ <<
"File format:" << std::endl;
142 outputFile_ <<
"[pair] ";
145 outputFile_ <<
"[bond] ";
148 if (
system().hasAnglePotential()) {
149 outputFile_ <<
"[angle] ";
153 if (
system().hasDihedralPotential()) {
154 outputFile_ <<
"[dihedral] ";
158 if (
system().hasCoulombPotential()) {
159 outputFile_ <<
"[coulomb] ";
163 if (
system().hasExternalPotential()) {
164 outputFile_ <<
"[external] ";
168 if (
system().hasSpecialPotential()) {
169 outputFile_ <<
"[special] ";
173 if (
system().hasLinkPotential()) {
174 outputFile_ <<
"[link] ";
178 if (
system().hasTetherPotential()) {
179 outputFile_ <<
"[tether] ";
182 outputFile_ <<
"[potential] ";
183 outputFile_ <<
"[kinetic] ";
184 outputFile_ <<
"[total] ";
185 outputFile_ << std::endl;
Include this file to include all MD potentials at once.
DihedralPotential & dihedralPotential() const
Return DihedralPotential by reference.
virtual double energy(double rsq, int iAtomType, int jAtomType) const =0
Return pair energy for a single pair.
void openOutputFile(const std::string &filename, std::ofstream &out, std::ios_base::openmode mode=std::ios_base::out) const
Open an output file.
virtual void loadParameters(Serializable::IArchive &ar)
Load internal state from an archive.
MdSystem & system()
Return reference to parent system.
Wrapper for a double precision number, for formatted ostream output.
virtual void save(Serializable::OArchive &ar)
Save internal state to an archive.
void readOutputFileName(std::istream &in)
Read outputFileName from file.
ExternalPotential & externalPotential() const
Return ExternalPotential by reference.
virtual void output()
Output final summary and file format.
Saving / output archive for binary ostream.
virtual double energy(const Vector &R1, const Vector &R2, const Vector &R3, int type) const =0
Returns potential energy for one dihedral.
MdPairPotential & pairPotential() const
Return MdPairPotential by reference.
virtual void readParameters(std::istream &in)
Read output file and nStepPerSample.
virtual double energy(const Vector &position, int i) const =0
Returns external potential energy of a single particle.
virtual void writeParam(std::ostream &out)
Write all parameters to an output stream.
BondPotential & linkPotential() const
Return link potential by reference.
void readInterval(std::istream &in)
Read interval from file, with error checking.
Utility classes for scientific computation.
AnglePotential & anglePotential() const
Return AnglePotential by reference.
double kineticEnergy() const
Compute and return total kinetic energy.
virtual void sample(long iStep)
Evaluate energy and print.
virtual double energy(double cosTheta, int type) const =0
Returns potential energy for one angle.
virtual double energy(double rSq, int type) const =0
Returns potential energy for one bond.
Saving archive for binary istream.
Single-processor Monte Carlo (MC) and molecular dynamics (MD).
void setClassName(const char *className)
Set class name string.
FileMaster & fileMaster()
Get the FileMaster by reference.
void loadInterval(Serializable::IArchive &ar)
Load interval from archive, with error checking.
bool isAtInterval(long counter) const
Return true iff counter is a multiple of the interval.
const std::string & outputFileName() const
Return outputFileName string.
void loadOutputFileName(Serializable::IArchive &ar)
Load output file name from archive.
double energy()
Get total Coulomb energy.
BondPotential & bondPotential() const
Return BondPotential by reference.
MdCoulombPotential & coulombPotential() const
Return CoulombPotential by reference.