本文整理汇总了C++中Crystal::removeAtom方法的典型用法代码示例。如果您正苦于以下问题:C++ Crystal::removeAtom方法的具体用法?C++ Crystal::removeAtom怎么用?C++ Crystal::removeAtom使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Crystal
的用法示例。
在下文中一共展示了Crystal::removeAtom方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: addWyckoffAtomRandomly
bool RandSpg::addWyckoffAtomRandomly(Crystal& crystal, const wyckPos& position,
uint atomicNum, uint spg, int maxAttempts)
{
START_FT;
#ifdef RANDSPG_WYCK_DEBUG
cout << "At beginning of addWyckoffAtomRandomly(), atom info is:\n";
crystal.printAtomInfo();
cout << "Attempting to add an atom of atomicNum " << atomicNum
<< " at position " << getWyckCoords(position) << "\n";
#endif
// If this contains a unique position, we only need to try once
// Otherwise, we'd be repeatedly trying the same thing...
if (containsUniquePosition(position)) {
maxAttempts = 1;
}
int i = 0;
bool success = false;
do {
// Generate random coordinates in the wyckoff position
// Numbers are between 0 and 1
double x = getRandDouble(0,1);
double y = getRandDouble(0,1);
double z = getRandDouble(0,1);
vector<string> components = split(getWyckCoords(position), ',');
// Interpret the three components of the Wyckoff position coordinates...
double newX = interpretComponent(components[0], x, y, z);
double newY = interpretComponent(components[1], x, y, z);
double newZ = interpretComponent(components[2], x, y, z);
// interpretComponenet() returns -1 if it failed to read the component
if (newX == -1 || newY == -1 || newZ == -1) {
cout << "addWyckoffAtomRandomly() failed due to a component not being "
<< "read successfully!\n";
return false;
}
atomStruct newAtom(atomicNum, newX, newY, newZ);
crystal.addAtom(newAtom);
// Check the interatomic distances
if (crystal.areIADsOkay(newAtom)) {
// Now try to fill the cell using this new atom
if (crystal.fillCellWithAtom(spg, newAtom)) success = true;
}
if (!success) {
// Remove this atom and try again
crystal.removeAtom(newAtom);
}
i++;
} while (i < maxAttempts && !success);
if (!success) return false;
#ifdef RANDSPG_WYCK_DEBUG
cout << "After an atom with atomic num " << atomicNum << " was added and "
<< "the cell filled, the following is the atom info:\n";
crystal.printAtomInfo();
#endif
return true;
}