本文整理汇总了C++中Species::isMutable方法的典型用法代码示例。如果您正苦于以下问题:C++ Species::isMutable方法的具体用法?C++ Species::isMutable怎么用?C++ Species::isMutable使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Species
的用法示例。
在下文中一共展示了Species::isMutable方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: readParameters
/*
* Read parameter speciesId.
*/
void EndSwapMove::readParameters(std::istream& in)
{
readProbability(in);
read<int>(in, "speciesId", speciesId_);
Species* speciesPtr = &(simulation().species(speciesId_));
int nAtom = speciesPtr->nAtom();
// Preconditions
if (speciesPtr->isMutable()) {
UTIL_THROW("EndSwapMove on mutable Species");
}
Linear* linearPtr = dynamic_cast<Linear*>(speciesPtr);
if (linearPtr == 0) {
UTIL_THROW("EndSwapMove on Species that is not a Linear");
}
// Allocate memory
atomTypeIds_.allocate(nAtom);
positions_.allocate(nAtom);
// Set array of atom type ids
for (int i = 0; i < nAtom; ++i) {
atomTypeIds_[i] = speciesPtr->atomTypeId(i);
}
}
示例2: generate
/*
* Generate random molecules
*/
bool Generator::generate(int nMolecule,
const DArray<double>& diameters,
CellList& cellList)
{
// Preconditions
UTIL_CHECK(nMolecule <= species().capacity());
UTIL_CHECK(cellList.atomCapacity() == simulation().atomCapacity());
// Attempt to place all molecules in Species
int speciesId = species().id();
int maxAttempt = 200;
int iAttempt;
bool success;
bool isMutable;
Species* speciesPtr;
for (int iMol = 0; iMol < nMolecule; ++iMol) {
Molecule &newMolecule= simulation().getMolecule(speciesId);
system().addMolecule(newMolecule);
speciesPtr = &system().simulation().species(speciesId);
isMutable = speciesPtr->isMutable();
if (isMutable) {
speciesPtr->mutator().setMoleculeState(newMolecule, 0);
}
success = false;
iAttempt = 0;
while (!success && iAttempt < maxAttempt) {
success = attemptPlaceMolecule(newMolecule,
diameters, cellList);
++iAttempt;
}
if (!success) {
system().removeMolecule(newMolecule);
Log::file() << "Failed to insert Linear molecule "
<< iMol << "\n";
return false;
}
}
return true;
}
示例3: loadParameters
/*
* Load from archive.
*/
void EndSwapMove::loadParameters(Serializable::IArchive& ar)
{
McMove::loadParameters(ar);
loadParameter<int>(ar, "speciesId", speciesId_);
ar & atomTypeIds_;
// Validate
Species* speciesPtr = &(simulation().species(speciesId_));
int nAtom = speciesPtr->nAtom();
if (speciesPtr->isMutable()) {
UTIL_THROW("EndSwapMove applied to mutable species");
}
Linear* linearPtr = dynamic_cast<Linear*>(speciesPtr);
if (linearPtr == 0) {
UTIL_THROW("EndSwapMove applied to species that is not Linear");
}
if (nAtom != atomTypeIds_.capacity()) {
UTIL_THROW("Inconsistent capacity for atomTypeIds array");
}
positions_.allocate(nAtom);
}
示例4: write
/*
* Write the configuration file.
*/
void McMdConfigIo::write(std::ostream &out)
{
using std::endl;
// Write Boundary dimensions
out << "BOUNDARY" << endl << endl;
out << boundary() << endl;
// Write atomic positions
System::ConstMoleculeIterator molIter;
Molecule::ConstAtomIterator atomIter;
Species* speciesPtr;
int iSpecies, iMolecule;
out << endl << "MOLECULES" << endl;
for (iSpecies = 0; iSpecies < simulation().nSpecies(); ++iSpecies) {
out << endl;
out << "species " << iSpecies << endl;
out << "nMolecule " << system().nMolecule(iSpecies) << endl;
speciesPtr = &simulation().species(iSpecies);
iMolecule = 0;
system().begin(iSpecies, molIter);
for ( ; molIter.notEnd(); ++molIter) {
out << endl;
out << "molecule " << iMolecule << endl;
if (speciesPtr->isMutable()) {
speciesPtr->mutator().writeMoleculeState(out, *molIter);
}
for (molIter->begin(atomIter); atomIter.notEnd(); ++atomIter) {
//out << atomIter->position() << endl;
writeAtom(out, *atomIter);
}
++iMolecule;
}
}
#ifdef INTER_TETHER
{ // Scope for local variables
// Write Tethers
Tether* tetherPtr;
Atom* atomPtr;
Molecule* molPtr;
int iTether, nTether, iAtom;
out << std::endl;
out << "TETHERS" << endl << endl;
nTether = system().tetherMaster().nTether();
out << Label("nTether") << nTether << std::endl;
for (iTether = 0; iTether < nTether; ++iTether) {
tetherPtr = &(system().tetherMaster().tether(iTether));
atomPtr = &tetherPtr->atom();
molPtr = &atomPtr->molecule();
iAtom = atomPtr->indexInMolecule();
iMolecule = system().moleculeId(*molPtr);
iSpecies = molPtr->species().id();
out << Int(iSpecies,5) << Int(iMolecule,9) << Int(iAtom,6)
<< tetherPtr->anchor() << std::endl;
}
}
#endif
#ifdef MCMD_LINK
{ // Scope for local variables
// Write Links
Link* linkPtr;
Atom* atomPtr;
Molecule* molPtr;
int iLink, nLink, iAtom;
out << std::endl;
out << "LINKS" << endl << endl;
nLink = system().linkMaster().nLink();
out << Label("nLink") << nLink << std::endl;
for (iLink = 0; iLink < nLink; ++iLink) {
linkPtr = &(system().linkMaster().link(iLink));
// Output species, molecule, atom ids for atom 0
atomPtr = &(linkPtr->atom0());
molPtr = &atomPtr->molecule();
iAtom = atomPtr->indexInMolecule();
iMolecule = system().moleculeId(*molPtr);
iSpecies = molPtr->species().id();
out << Int(iSpecies,8) << Int(iMolecule,8) << Int(iAtom,8);
out << " ";
// Output species, molecule, atom ids for atom 1
atomPtr = &(linkPtr->atom1());
molPtr = &atomPtr->molecule();
iAtom = atomPtr->indexInMolecule();
iMolecule = system().moleculeId(*molPtr);
iSpecies = molPtr->species().id();
out << Int(iSpecies,8) << Int(iMolecule,8) << Int(iAtom,8);
out << " ";
out << Int(linkPtr->typeId(),8) << std::endl;
}
//.........这里部分代码省略.........