8 #include "SpeciesMutator.h" 20 : stateIdLabel_(
"stateId"),
38 moleculeStateIds_.
allocate(nMolecule);
42 for (
int i = 0; i <
nState; ++i) {
43 stateWeights_[i] = 1.0;
45 for (
int i = 0; i <
nState; ++i) {
46 stateOccupancies_[i] = 0;
48 for (
int i = 0; i < nMolecule; ++i) {
62 int molId = molecule.
id();
63 int oldStateId = moleculeStateIds_[molId];
65 --stateOccupancies_[oldStateId];
67 moleculeStateIds_[molId] = stateId;
68 ++stateOccupancies_[stateId];
87 in >> stateIdLabel_ >> stateId;
virtual ~SpeciesMutator()
Destructor.
int nState() const
Get the number of possible molecule states.
SpeciesMutator()
Constructor.
void allocateSpeciesMutator(int nMolecule, int nState)
Allocate arrays of molecule state ids and statistical weights.
static const int NullStateId
Null value for a state index.
void setMoleculeStateId(const Molecule &molecule, int stateId)
Set the state id of a specific molecule.
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).
#define UTIL_THROW(msg)
Macro for throwing an Exception, reporting function, file and line number.
Utility classes for scientific computation.
virtual void readMoleculeState(std::istream &in, Molecule &molecule)
Read the state id for one molecule from a configuration file stream.
virtual void setMoleculeState(Molecule &molecule, int stateId)=0
Change the state of a specific molecule.
virtual void writeMoleculeState(std::ostream &out, const Molecule &molecule) const
Write the state id for one molecule to a configuration file stream.
Single-processor Monte Carlo (MC) and molecular dynamics (MD).
void allocate(int capacity)
Allocate the underlying C array.
A physical molecule (a set of covalently bonded Atoms).