本文整理汇总了C++中Boundary::randomPosition方法的典型用法代码示例。如果您正苦于以下问题:C++ Boundary::randomPosition方法的具体用法?C++ Boundary::randomPosition怎么用?C++ Boundary::randomPosition使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Boundary
的用法示例。
在下文中一共展示了Boundary::randomPosition方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: writeRings
void RingMaker::writeRings(std::ostream& out)
{
Vector r, a, b;
double beta = 1.0, length;
int bondType = 0;
int iMol, iAtom;
out << "BOUNDARY" << std::endl;
out << std::endl;
out << "lengths " << boundary_ << std::endl;
out << std::endl;
out << "MOLECULES" << std::endl;
out << std::endl;
out << "species " << 0 << std::endl;
out << "nMolecule " << nMolecule_ << std::endl;
for (iMol = 0; iMol < nMolecule_; ++iMol) {
out << std::endl;
out << "molecule " << iMol << std::endl;
// Generate the trial bond vectors
v_[nAtom_-1].zero();
for (iAtom = 1; iAtom < nAtom_; ++iAtom) {
random_.unitVector(v_[iAtom-1]);
v_[iAtom-1] *=
bondPotential_.randomBondLength(&random_, beta, bondType);
v_[nAtom_-1] += v_[iAtom-1];
}
length = bondPotential_.randomBondLength(&random_, beta, bondType);
length = v_[nAtom_-1].abs() - length;
if (length > 0.0) {
length /= v_[nAtom_-1].abs() * double(nAtom_-1);
v_[nAtom_-1] *= length;
} else {
v_[nAtom_-1].zero();
}
// Choose first atom at random
boundary_.randomPosition(random_, r);
// Output the atom positions
out << r << std::endl;
for (iAtom = 1; iAtom < nAtom_; ++iAtom) {
v_[iAtom-1] -= v_[nAtom_-1];
r += v_[iAtom-1];
boundary_.shift(r);
out << r << std::endl;
}
}
}