Simpatico  v1.10
List of all members | Public Member Functions | Static Public Attributes | Protected Member Functions
McMd::SpeciesMutator Class Referenceabstract

Detailed Description

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>

Inheritance diagram for McMd::SpeciesMutator:
McMd::HomopolymerSG McMd::LinearSG

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...
 

Constructor & Destructor Documentation

McMd::SpeciesMutator::SpeciesMutator ( )

Constructor.

The constructor sets Species::isSpeciesMutator_ to true.

Definition at line 19 of file SpeciesMutator.cpp.

McMd::SpeciesMutator::~SpeciesMutator ( )
virtual

Destructor.

Definition at line 27 of file SpeciesMutator.cpp.

Member Function Documentation

void McMd::SpeciesMutator::readMoleculeState ( std::istream &  in,
Molecule molecule 
)
virtual

Read the state id for one molecule from a configuration file stream.

Parameters
ininput stream
moleculemolecule of interest

Definition at line 84 of file SpeciesMutator.cpp.

References setMoleculeState().

Referenced by McMd::McMdConfigIo::read().

void McMd::SpeciesMutator::writeMoleculeState ( std::ostream &  out,
const Molecule molecule 
) const
virtual

Write the state id for one molecule to a configuration file stream.

Parameters
outoutput stream
moleculemolecule of interest

Definition at line 75 of file SpeciesMutator.cpp.

References moleculeStateId().

Referenced by McMd::McMdConfigIo::write().

virtual void McMd::SpeciesMutator::setMoleculeState ( Molecule molecule,
int  stateId 
)
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.

Parameters
moleculereference to molecule of interest.
stateIdinteger index of new state.

Implemented in McMd::LinearSG, and McMd::HomopolymerSG.

Referenced by McMd::Generator::generate(), McMd::System::loadConfig(), McMd::HomopolymerSemiGrandMove::move(), and readMoleculeState().

void McMd::SpeciesMutator::setWeight ( int  stateId,
double  weight 
)
inline

Set the statistical weight associated with a specific state.

Parameters
stateIdinteger index of state
weightdesired 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().

int McMd::SpeciesMutator::moleculeStateId ( const Molecule molecule) const
inline

Get the state id for a specific molecule.

Parameters
moleculereference 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().

int McMd::SpeciesMutator::nState ( ) const
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().

int McMd::SpeciesMutator::stateOccupancy ( int  stateId) const
inline

Get the number of molecules with a specified state.

Parameters
stateIdindex for specific state.

Definition at line 208 of file SpeciesMutator.h.

Referenced by McMd::SemiGrandDistribution::sample(), and McMd::TypeDistribution::sample().

double McMd::SpeciesMutator::stateWeight ( int  stateId) const
inline

Get the statistical weight for a specfic molecular state.

Parameters
stateIdindex for specific state.

Definition at line 222 of file SpeciesMutator.h.

Referenced by McMd::HomopolymerSemiGrandMove::move().

void McMd::SpeciesMutator::allocateSpeciesMutator ( int  nMolecule,
int  nState 
)
protected

Allocate arrays of molecule state ids and statistical weights.

Parameters
nMoleculenumber of molecules allocated for species.
nStatenumber 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().

void McMd::SpeciesMutator::setMoleculeStateId ( const Molecule molecule,
int  stateId 
)
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.

See also
setMoleculeState
Parameters
moleculereference to molecule of interest.
stateIdinteger 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().

Member Data Documentation

const int McMd::SpeciesMutator::NullStateId = -1
static

Null value for a state index.

Definition at line 133 of file SpeciesMutator.h.

Referenced by allocateSpeciesMutator(), and setMoleculeStateId().


The documentation for this class was generated from the following files: