Simpatico
v1.10
|
Mix-in class for mutable subclasses of Species.
A mutable species is a class that is derived from both Species and SpeciesMutator. A mutable species models a species in which each molecule can be in any of an enumerable number of internal states. This may be used to represent, for example, homopolymers that can change type within a semi-grand canonical simulation, or polymers that can grow or shrink within some extended ensemble simulations. Changes in internal states may change the types of atoms and bonds, and may temporarily erase, or deactivate, certain atoms and bonds.
Each molecule in a mutable species is assigned an integer state id, to specify its internal state. Each state is assigned a floating point statistical weight. The statistical weights are unnormalized, i.e., they need not add to unity. The SpeciesMutator class provides arrays that store these state variables and statistical weights, and methods to access them.
Definition at line 41 of file SpeciesMutator.h.
#include <SpeciesMutator.h>
Public Member Functions | |
SpeciesMutator () | |
Constructor. More... | |
virtual | ~SpeciesMutator () |
Destructor. More... | |
Mutators | |
virtual void | readMoleculeState (std::istream &in, Molecule &molecule) |
Read the state id for one molecule from a configuration file stream. More... | |
virtual void | writeMoleculeState (std::ostream &out, const Molecule &molecule) const |
Write the state id for one molecule to a configuration file stream. More... | |
virtual void | setMoleculeState (Molecule &molecule, int stateId)=0 |
Change the state of a specific molecule. More... | |
void | setWeight (int stateId, double weight) |
Set the statistical weight associated with a specific state. More... | |
int | moleculeStateId (const Molecule &molecule) const |
Get the state id for a specific molecule. More... | |
int | nState () const |
Get the number of possible molecule states. More... | |
int | stateOccupancy (int stateId) const |
Get the number of molecules with a specified state. More... | |
double | stateWeight (int stateId) const |
Get the statistical weight for a specfic molecular state. More... | |
Static Public Attributes | |
static const int | NullStateId = -1 |
Null value for a state index. More... | |
Protected Member Functions | |
void | allocateSpeciesMutator (int nMolecule, int nState) |
Allocate arrays of molecule state ids and statistical weights. More... | |
void | setMoleculeStateId (const Molecule &molecule, int stateId) |
Set the state id of a specific molecule. More... | |
McMd::SpeciesMutator::SpeciesMutator | ( | ) |
Constructor.
The constructor sets Species::isSpeciesMutator_ to true.
Definition at line 19 of file SpeciesMutator.cpp.
|
virtual |
Destructor.
Definition at line 27 of file SpeciesMutator.cpp.
|
virtual |
Read the state id for one molecule from a configuration file stream.
in | input stream |
molecule | molecule of interest |
Definition at line 84 of file SpeciesMutator.cpp.
References setMoleculeState().
Referenced by McMd::McMdConfigIo::read().
|
virtual |
Write the state id for one molecule to a configuration file stream.
out | output stream |
molecule | molecule of interest |
Definition at line 75 of file SpeciesMutator.cpp.
References moleculeStateId().
Referenced by McMd::McMdConfigIo::write().
|
pure virtual |
Change the state of a specific molecule.
The method should be used to implement MC moves that change the internal state of a molecule, after the previous stateId and bead positions are known. The method can use knowledge of the previous stateId and previous bead positions to implement transitions between a specific pairs of states.
molecule | reference to molecule of interest. |
stateId | integer index of new state. |
Implemented in McMd::LinearSG, and McMd::HomopolymerSG.
Referenced by McMd::Generator::generate(), McMd::System::loadConfig(), McMd::HomopolymerSemiGrandMove::move(), and readMoleculeState().
|
inline |
Set the statistical weight associated with a specific state.
stateId | integer index of state |
weight | desired statistical weight |
Definition at line 229 of file SpeciesMutator.h.
Referenced by McMd::HomopolymerSG::loadSpeciesParam(), McMd::LinearSG::loadSpeciesParam(), McMd::HomopolymerSG::readSpeciesParam(), and McMd::LinearSG::readSpeciesParam().
|
inline |
Get the state id for a specific molecule.
molecule | reference to molecule of interest. |
Definition at line 201 of file SpeciesMutator.h.
References McMd::Molecule::id().
Referenced by McMd::HomopolymerSemiGrandMove::move(), McMd::System::saveConfig(), and writeMoleculeState().
|
inline |
Get the number of possible molecule states.
Definition at line 215 of file SpeciesMutator.h.
Referenced by allocateSpeciesMutator(), McMd::TypeDistribution::loadParameters(), and McMd::TypeDistribution::readParameters().
|
inline |
Get the number of molecules with a specified state.
stateId | index for specific state. |
Definition at line 208 of file SpeciesMutator.h.
Referenced by McMd::SemiGrandDistribution::sample(), and McMd::TypeDistribution::sample().
|
inline |
Get the statistical weight for a specfic molecular state.
stateId | index for specific state. |
Definition at line 222 of file SpeciesMutator.h.
Referenced by McMd::HomopolymerSemiGrandMove::move().
|
protected |
Allocate arrays of molecule state ids and statistical weights.
nMolecule | number of molecules allocated for species. |
nState | number of possible internal states. |
Definition at line 33 of file SpeciesMutator.cpp.
References Util::DArray< Data >::allocate(), nState(), and NullStateId.
Referenced by McMd::HomopolymerSG::loadSpeciesParam(), McMd::LinearSG::loadSpeciesParam(), McMd::HomopolymerSG::readSpeciesParam(), and McMd::LinearSG::readSpeciesParam().
|
protected |
Set the state id of a specific molecule.
This method should be called by the public method setMoleculeState. to set the state id for a molecule. It does not modify the molecule.
molecule | reference to molecule of interest. |
stateId | integer index of new state. |
Definition at line 57 of file SpeciesMutator.cpp.
References McMd::Molecule::id(), NullStateId, and UTIL_THROW.
Referenced by McMd::HomopolymerSG::setMoleculeState(), and McMd::LinearSG::setMoleculeState().
|
static |
Null value for a state index.
Definition at line 133 of file SpeciesMutator.h.
Referenced by allocateSpeciesMutator(), and setMoleculeStateId().