本文整理汇总了C++中Species::nBond方法的典型用法代码示例。如果您正苦于以下问题:C++ Species::nBond方法的具体用法?C++ Species::nBond怎么用?C++ Species::nBond使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Species
的用法示例。
在下文中一共展示了Species::nBond方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: initializeSpeciesBonds
/*
* Initialize all Bond objects for Molecules of one Species. (private)
*
* This functions assigns pointers to Atoms and bond types ids within a
* contiguous block of Bond objects, and sets a pointer in each Molecule
* to the first Bond in the associated block.
*/
void Simulation::initializeSpeciesBonds(int iSpecies)
{
if (nBondType_ <= 0) {
UTIL_THROW("nBondType_ must be positive");
}
Species* speciesPtr = 0;
Molecule* moleculePtr = 0;
Bond* bondPtr = 0;
Atom* firstAtomPtr;
Atom* atom0Ptr;
Atom* atom1Ptr;
int iMol, iBond, atom0Id, atom1Id, type;
int capacity, nBond;
speciesPtr = &species(iSpecies);
nBond = speciesPtr->nBond();
capacity = speciesPtr->capacity();
// Initialize pointers before loop
moleculePtr = &molecules_[firstMoleculeIds_[iSpecies]];
bondPtr = &bonds_[firstBondIds_[iSpecies]];
// Loop over molecules in Species
for (iMol = 0; iMol < capacity; ++iMol) {
firstAtomPtr = &(moleculePtr->atom(0));
moleculePtr->setFirstBond(*bondPtr);
moleculePtr->setNBond(nBond);
if (nBond > 0) {
// Create bonds for a molecule
for (iBond = 0; iBond < nBond; ++iBond) {
// Get pointers to bonded atoms and bond type
atom0Id = speciesPtr->speciesBond(iBond).atomId(0);
atom1Id = speciesPtr->speciesBond(iBond).atomId(1);
type = speciesPtr->speciesBond(iBond).typeId();
atom0Ptr = firstAtomPtr + atom0Id;
atom1Ptr = firstAtomPtr + atom1Id;
// Set fields of the Bond object
bondPtr->setAtom(0, *atom0Ptr);
bondPtr->setAtom(1, *atom1Ptr);
bondPtr->setTypeId(type);
// If MaskBonded, add each bonded atom to its partners Mask
if (maskedPairPolicy_ == MaskBonded) {
atom0Ptr->mask().append(*atom1Ptr);
atom1Ptr->mask().append(*atom0Ptr);
}
++bondPtr;
}
}
++moleculePtr;
}
}
示例2: initialize
/*
* Allocate and initialize all private data (private method).
*
* Allocates global arrays (molecules_, atoms_, bonds_, angles_) and the
* arrays first<class>Ids_ of integers to species blocks. Initializes:
*
* - Capacity values and first<class>Ptr_ addresses.
* - Integer ids for Species and Molecule objects.
* - Pointers between Species, Molecule, and Atom objects
* - Atom typeIds and all Bond and Angle objects.
*/
void Simulation::initialize()
{
//Preconditions
assert(nSpecies() > 0);
if (nSpecies() <= 0) {
UTIL_THROW("Error: nSpecies() <= 0 in Simulation::initialize()");
}
if (nBondType_ < 0) {
UTIL_THROW("Error: nBondType < 0 in Simulation::initialize()");
}
#ifdef INTER_ANGLE
if (nAngleType_ < 0) {
UTIL_THROW("Error: nAngleType < 0 in Simulation::initialize()");
}
#endif
#ifdef INTER_DIHEDRAL
if (nDihedralType_ < 0) {
UTIL_THROW("Error: nDihedralType < 0 in Simulation::initialize()");
}
#endif
#ifdef MCMD_LINK
if (nLinkType_ < 0) {
UTIL_THROW("Error: nLinkType_ < 0 in Simulation::initialize()");
}
#endif
Species *speciesPtr;
int nAtom, nBond, iSpecies;
int capacity;
#ifdef INTER_ANGLE
int nAngle;
#endif
#ifdef INTER_DIHEDRAL
int nDihedral;
#endif
// Allocate arrays of pointers to first object in a species block.
firstMoleculeIds_.allocate(nSpecies());
firstAtomIds_.allocate(nSpecies());
if (nBondType_ > 0) {
firstBondIds_.allocate(nSpecies());
}
#ifdef INTER_ANGLE
if (nAngleType_ > 0) {
firstAngleIds_.allocate(nSpecies());
}
#endif
#ifdef INTER_DIHEDRAL
if (nDihedralType_ > 0) {
firstDihedralIds_.allocate(nSpecies());
}
#endif
// Count Molecules, Atoms and Groups.
moleculeCapacity_ = 0;
atomCapacity_ = 0;
bondCapacity_ = 0;
#ifdef INTER_ANGLE
angleCapacity_ = 0;
#endif
#ifdef INTER_DIHEDRAL
dihedralCapacity_ = 0;
#endif
for (iSpecies = 0; iSpecies < nSpecies(); ++iSpecies) {
speciesPtr = &species(iSpecies);
// Check species id
if (speciesPtr->id() != iSpecies) {
UTIL_THROW("Inconsistent species ids");
}
//speciesPtr->setId(iSpecies);
// Set indexes of first objects of the blocks for this species
firstMoleculeIds_[iSpecies] = moleculeCapacity_;
firstAtomIds_[iSpecies] = atomCapacity_;
if (nBondType_ > 0) {
firstBondIds_[iSpecies] = bondCapacity_;
}
#ifdef INTER_ANGLE
if (nAngleType_ > 0) {
firstAngleIds_[iSpecies] = angleCapacity_;
}
#endif
#ifdef INTER_DIHEDRAL
if (nDihedralType_ > 0) {
firstDihedralIds_[iSpecies] = dihedralCapacity_;
}
#endif
//.........这里部分代码省略.........