Simpatico  v1.10
SpeciesMutator.h
1 #ifndef MCMD_SPECIES_MUTATOR_H
2 #define MCMD_SPECIES_MUTATOR_H
3 
4 /*
5 * Simpatico - Simulation Package for Polymeric and Molecular Liquids
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/containers/DArray.h> // member template
12 #include <util/param/Label.h> // member
13 #include <mcMd/chemistry/Molecule.h> // inline function
14 
15 namespace McMd
16 {
17 
18  using namespace Util;
19 
42  {
43 
44  public:
45 
51  SpeciesMutator();
52 
56  virtual ~SpeciesMutator();
57 
59 
60 
67  virtual void readMoleculeState(std::istream& in, Molecule& molecule);
68 
75  virtual
76  void writeMoleculeState(std::ostream& out, const Molecule& molecule) const;
77 
89  virtual void setMoleculeState(Molecule& molecule, int stateId) = 0;
90 
97  void setWeight(int stateId, double weight);
98 
100  // Accessors
101 
107  int moleculeStateId(const Molecule& molecule) const;
108 
112  int nState() const;
113 
119  int stateOccupancy(int stateId) const;
120 
126  double stateWeight(int stateId) const;
127 
129 
133  static const int NullStateId = -1;
134 
135  protected:
136 
143  void allocateSpeciesMutator(int nMolecule, int nState);
144 
156  void setMoleculeStateId(const Molecule& molecule, int stateId);
157 
158  private:
159 
165  DArray<double> stateWeights_;
166 
172  DArray<int> stateOccupancies_;
173 
181  DArray<int> moleculeStateIds_;
182 
186  Label stateIdLabel_;
187 
191  int nState_;
192 
193  };
194 
195  // Inline method definitions
196 
197  /*
198  * Get the state id for a molecule.
199  */
200  inline
201  int SpeciesMutator::moleculeStateId(const Molecule& molecule) const
202  { return moleculeStateIds_[molecule.id()]; }
203 
204  /*
205  * Get the occupancy (number of molecules) in a specific internal state.
206  */
207  inline
208  int SpeciesMutator::stateOccupancy(int stateId) const
209  { return stateOccupancies_[stateId]; }
210 
211  /*
212  * Get the number of possible internal states.
213  */
214  inline
216  { return nState_; }
217 
218  /*
219  * Get the statistical weight for a specific internal state.
220  */
221  inline
222  double SpeciesMutator::stateWeight(int stateId) const
223  { return stateWeights_[stateId]; }
224 
225  /*
226  * Set the statistical weight for a specific internal state.
227  */
228  inline
229  void SpeciesMutator::setWeight(int stateId, double weight)
230  { stateWeights_[stateId] = weight; }
231 
232 }
233 #endif
int nState() const
Get the number of possible molecule states.
double stateWeight(int stateId) const
Get the statistical weight for a specfic molecular state.
void setWeight(int stateId, double weight)
Set the statistical weight associated with a specific state.
int moleculeStateId(const Molecule &molecule) const
Get the state id for a specific molecule.
int id() const
Get the index for this Molecule (unique in species).
Mix-in class for mutable subclasses of Species.
Utility classes for scientific computation.
Definition: accumulators.mod:1
int stateOccupancy(int stateId) const
Get the number of molecules with a specified state.
A label string in a file format.
Definition: Label.h:36
Single-processor Monte Carlo (MC) and molecular dynamics (MD).
A physical molecule (a set of covalently bonded Atoms).