Simpatico  v1.10
SpeciesEnsemble.h
1 #ifndef UTIL_SPECIES_ENSEMBLE_H
2 #define UTIL_SPECIES_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 
29  {
30 
31  public:
32 
36  enum Type{UNKNOWN, CLOSED, GRAND};
37 
41  SpeciesEnsemble(Type type = UNKNOWN);
42 
47 
51  void setMu(double mu);
52 
59  virtual void readParam(std::istream& in);
60 
62 
63 
67  bool isClosed() const;
68 
72  bool isGrand() const;
73 
77  double mu() const;
78 
80 
81  #ifdef UTIL_MPI
82 
85  static void commitMpiType();
86  #endif
87 
88  private:
89 
91  double mu_;
92 
94  Type type_;
95 
96  };
97 
105  std::istream& operator>>(std::istream& in, SpeciesEnsemble::Type &type);
106 
114  std::ostream& operator<<(std::ostream& out, const SpeciesEnsemble::Type &type);
115 
116  // Inline methods
117 
121  inline double SpeciesEnsemble::mu() const
122  { return mu_; }
123 
124  // Return true if this is an Closed ensemble.
125  inline bool SpeciesEnsemble::isClosed() const
126  { return (type_ == CLOSED); }
127 
128  // Return true if this is an Grand Ensemble.
129  inline bool SpeciesEnsemble::isGrand() const
130  { return (type_ == GRAND); }
131 
139  template <class Archive>
140  inline void serialize(Archive& ar, SpeciesEnsemble::Type& data, const unsigned int version)
141  { serializeEnum(ar, data, version); }
142 
143 }
144 
145 #ifdef UTIL_MPI
146 #include <util/mpi/MpiTraits.h>
147 namespace Util
148 {
149 
153  template <>
155  {
156  public:
157  static MPI::Datatype type;
158  static bool hasType;
159  };
160 
164  template <>
166  {
167  public:
168  static MPI::Datatype type;
169  static bool hasType;
170  };
171 
172 }
173 #endif
174 
175 #endif
An ensemble for the number of molecules of one Species.
double mu() const
Return the chemical potential mu.
void serialize(Archive &ar, const unsigned int version)
Serialize this ParamComponent as a string.
static MPI::Datatype type
MPI Datatype.
bool isGrand() const
Is this a Grand ensemble?
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.
SpeciesEnsemble(Type type=UNKNOWN)
Constructor.
void setMu(double mu)
Set the chemical potential mu.
static void commitMpiType()
Commit associated MPI DataType.
Utility classes for scientific computation.
Definition: accumulators.mod:1
virtual void readParam(std::istream &in)
Read the type and (if appropriate) mu from file.
Default MpiTraits class.
Definition: MpiTraits.h:39
static MPI::Datatype type
MPI Datatype.
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
Type
Enumeration of the allowed types of SpeciesEnsemble.
~SpeciesEnsemble()
Destructor.
static bool hasType
Is the MPI type initialized?
static bool hasType
Is the MPI type initialized?
An object that can read multiple parameters from file.
bool isClosed() const
Is this a Closed ensemble?