Simpatico  v1.10
EnergyEnsemble.h
1 #ifndef UTIL_ENERGY_ENSEMBLE_H
2 #define UTIL_ENERGY_ENSEMBLE_H
3 
4 /*
5 * Util Package - C++ Utilities for Scientific Computation
6 *
7 * Copyright 2010 - 2017, The Regents of the University of Minnesota
8 * Distributed under the terms of the GNU General Public License.
9 */
10 
11 #include <util/param/ParamComposite.h>
12 #include <util/archives/serialize.h>
13 #include <util/global.h>
14 
15 namespace Simp
16 {
17 
18  using namespace Util;
19 
30  {
31 
32  public:
33 
37  enum Type{UNKNOWN, ADIABATIC, ISOTHERMAL};
38 
42  EnergyEnsemble(Type type = UNKNOWN);
43 
48 
52  void setTemperature(double temperature);
53 
60  virtual void readParameters(std::istream& in);
61 
67  virtual void loadParameters(Serializable::IArchive &ar);
68 
74  virtual void save(Serializable::OArchive &ar);
75 
77 
78 
82  bool isAdiabatic() const;
83 
87  bool isIsothermal() const;
88 
92  double temperature() const;
93 
97  double beta() const;
98 
100 
101  #ifdef UTIL_MPI
102 
105  static void commitMpiType();
106  #endif
107 
108  private:
109 
111  double temperature_;
112 
114  double beta_;
115 
117  Type type_;
118 
119  };
120 
128  std::istream& operator >> (std::istream& in, EnergyEnsemble::Type &type);
129 
137  std::ostream&
138  operator << (std::ostream& out, EnergyEnsemble::Type const & type);
139 
140  // Inline methods
141 
142  /*
143  * Return the temperature.
144  */
145  inline double EnergyEnsemble::temperature() const
146  { return temperature_; }
147 
148  /*
149  * Return the inverse temperature.
150  */
151  inline double EnergyEnsemble::beta() const
152  { return beta_; }
153 
154  /*
155  * Return true if this is an adiabatic ensemble.
156  */
157  inline bool EnergyEnsemble::isAdiabatic() const
158  { return (type_ == ADIABATIC); }
159 
160  /*
161  * Return true if this is an IsothermalEnsemble.
162  */
163  inline bool EnergyEnsemble::isIsothermal() const
164  { return (type_ == ISOTHERMAL); }
165 
173  template <class Archive>
174  inline
175  void serialize(Archive& ar, EnergyEnsemble::Type& data,
176  const unsigned int version)
177  { serializeEnum(ar, data, version); }
178 
179 }
180 
181 #ifdef UTIL_MPI
182 #include <util/mpi/MpiTraits.h>
183 namespace Util
184 {
185 
189  template <>
191  {
192  public:
193  static MPI::Datatype type;
194  static bool hasType;
195  };
196 
200  template <>
202  {
203  public:
204  static MPI::Datatype type;
205  static bool hasType;
206  };
207 
208 }
209 #endif
210 
211 #endif
static MPI::Datatype type
MPI Datatype.
void serialize(Archive &ar, const unsigned int version)
Serialize this ParamComponent as a string.
static bool hasType
Is the MPI type initialized?
File containing preprocessor macros for error handling.
Classes used by all simpatico molecular simulations.
std::istream & operator>>(std::istream &in, MonoclinicBoundary &boundary)
istream extractor for a MonoclinicBoundary.
virtual void loadParameters(Serializable::IArchive &ar)
Load internal state from an archive.
Saving / output archive for binary ostream.
A statistical ensemble for energy.
double beta() const
Return the inverse temperature.
bool isAdiabatic() const
Is this an Adiabatic ensemble?
bool isIsothermal() const
Is this an Isothermal ensemble?
Utility classes for scientific computation.
Definition: accumulators.mod:1
~EnergyEnsemble()
Destructor.
Default MpiTraits class.
Definition: MpiTraits.h:39
std::ostream & operator<<(std::ostream &out, const MonoclinicBoundary &boundary)
ostream inserter for an MonoclinicBoundary.
void serializeEnum(Archive &ar, T &data, const unsigned int version=0)
Serialize an enumeration value.
Definition: serialize.h:42
static MPI::Datatype type
MPI Datatype.
void setTemperature(double temperature)
Set the temperature.
virtual void save(Serializable::OArchive &ar)
Save internal state to an archive.
Type
Enumeration of the allowed types of EnergyEnsemble.
EnergyEnsemble(Type type=UNKNOWN)
Constructor.
Saving archive for binary istream.
virtual void readParameters(std::istream &in)
Read the type and (if necessary) temperature from file.
double temperature() const
Return the temperature.
An object that can read multiple parameters from file.
static bool hasType
Is the MPI type initialized?
static void commitMpiType()
Commit MPI data type for an EnergyEnsemble.