本文整理汇总了C++中Bond类的典型用法代码示例。如果您正苦于以下问题:C++ Bond类的具体用法?C++ Bond怎么用?C++ Bond使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Bond类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: getPotential
double Molecule::getPotential() {
//RigidBody* rb;
Bond* bond;
Bend* bend;
Torsion* torsion;
//std::vector<RigidBody*> rbIter;
std::vector<Bond*> bondIter;;
std::vector<Bend*> bendIter;
std::vector<Torsion*> torsionIter;
double potential = 0;
//for (rb = beginRigidBody(rbIter); rb != NULL; rb = nextRigidBody(rbIter)) {
// rb->updateAtoms();
//}
for (bond = beginBond(bondIter); bond != NULL; bond = nextBond(bondIter)) {
potential += bond->getPotential();
}
for (bend = beginBend(bendIter); bend != NULL; bend = nextBend(bendIter)) {
potential += bend->getPotential();
}
for (torsion = beginTorsion(torsionIter); torsion != NULL; torsion = nextTorsion(torsionIter)) {
potential += torsion->getPotential();
}
return potential;
}
示例2: isTradable
bool BondFunctions::isTradable(const Bond& bond,
Date settlement) {
if (settlement == Date())
settlement = bond.settlementDate();
return bond.notional(settlement)!=0.0;
}
示例3: DetectAtomStereoChemistry
// handles stereochem markers set by the Mol file parser and
// converts them to the RD standard:
void DetectAtomStereoChemistry(RWMol &mol, const Conformer *conf) {
PRECONDITION(conf, "no conformer");
// make sure we've calculated the implicit valence on each atom:
for (RWMol::AtomIterator atomIt = mol.beginAtoms(); atomIt != mol.endAtoms();
++atomIt) {
(*atomIt)->calcImplicitValence(false);
}
for (RWMol::BondIterator bondIt = mol.beginBonds(); bondIt != mol.endBonds();
++bondIt) {
Bond *bond = *bondIt;
if (bond->getBondDir() != Bond::UNKNOWN) {
Bond::BondDir dir = bond->getBondDir();
// the bond is marked as chiral:
if (dir == Bond::BEGINWEDGE || dir == Bond::BEGINDASH) {
Atom *atom = bond->getBeginAtom();
if (atom->getImplicitValence() == -1) {
atom->calcExplicitValence();
atom->calcImplicitValence();
}
Atom::ChiralType code = FindAtomStereochemistry(mol, bond, conf);
atom->setChiralTag(code);
// within the RD representation, if a three-coordinate atom
// is chiral and has an implicit H, that H needs to be made explicit:
if (atom->getDegree() == 3 && !atom->getNumExplicitHs() &&
atom->getNumImplicitHs() == 1) {
atom->setNumExplicitHs(1);
// recalculated number of implicit Hs:
atom->updatePropertyCache();
}
}
}
}
}
示例4: editor
void SetBondOrderCommand::redo()
{
Bond *bond = editor()->bond(m_atomId1, m_atomId2);
assert(bond != 0);
bond->setOrder(m_finalOrder);
}
示例5: TEST
TEST(CjsonTest, saveFile)
{
CjsonFormat cjson;
Molecule savedMolecule, molecule;
bool success = cjson.readFile(std::string(AVOGADRO_DATA) +
"/data/ethane.cjson",
savedMolecule);
EXPECT_TRUE(success);
EXPECT_EQ(cjson.error(), "");
success = cjson.writeFile("ethanetmp.cjson", savedMolecule);
EXPECT_TRUE(success);
EXPECT_EQ(cjson.error(), "");
// Now read the file back in and check a few key values are still present.
success = cjson.readFile("ethanetmp.cjson", molecule);
EXPECT_TRUE(success);
EXPECT_EQ(cjson.error(), "");
EXPECT_EQ(molecule.data("name").toString(), "Ethane");
EXPECT_EQ(molecule.atomCount(), static_cast<size_t>(8));
EXPECT_EQ(molecule.bondCount(), static_cast<size_t>(7));
Atom atom = molecule.atom(7);
EXPECT_EQ(atom.atomicNumber(), static_cast<unsigned char>(1));
EXPECT_EQ(atom.position3d().x(), -1.184988);
EXPECT_EQ(atom.position3d().y(), 0.004424);
EXPECT_EQ(atom.position3d().z(), -0.987522);
Bond bond = molecule.bond(0);
EXPECT_EQ(bond.atom1().index(), static_cast<size_t>(0));
EXPECT_EQ(bond.atom2().index(), static_cast<size_t>(1));
EXPECT_EQ(bond.order(), static_cast<unsigned char>(1));
}
示例6: TEST
TEST(RWMoleculeTest, BondType)
{
Molecule m;
RWMolecule mol(m);
typedef RWMolecule::AtomType Atom;
typedef RWMolecule::BondType Bond;
Atom a0 = mol.addAtom(1);
Atom a1 = mol.addAtom(2);
Atom a2 = mol.addAtom(3);
Bond b0 = mol.addBond(a0, a1);
Bond b1 = mol.addBond(1, 2);
Bond invalid = mol.addBond(0, 9);
EXPECT_TRUE(b0.isValid());
EXPECT_FALSE(invalid.isValid());
EXPECT_FALSE(Bond().isValid());
EXPECT_FALSE(Bond(&mol, 3).isValid());
EXPECT_EQ(&mol, b0.molecule());
EXPECT_EQ(0, b0.index());
EXPECT_EQ(a0, b0.atom1());
EXPECT_EQ(a2, b1.atom2());
b1.setOrder(2);
EXPECT_EQ(2, b1.order());
EXPECT_EQ(2, mol.bondOrder(1));
Bond other(&mol, 0);
EXPECT_EQ(b0, other);
EXPECT_NE(b1, other);
}
示例7: qDebug
void FileImportExtension::processLine(QTextStream *in, Molecule *mol)
{
// First truncate the line, remove trailing white space and check
QString line = in->readLine();
QString key = line;
key = key.trimmed();
if (key == "%FLAG BONDS_WITHOUT_HYDROGEN") {
qDebug() << "Reading in bonds...";
line = in->readLine(); // Throw away this line
line = "";
QStringList list;
while (line[0] != '%') {
line = in->readLine();
list += line.split(' ', QString::SkipEmptyParts);
if (list.size() == 30) {
for (int i = 0; i <= 27; i += 3) {
Bond *bond = mol->addBond();
bond->setAtoms(list.at(i).toInt()/3, list.at(i+1).toInt()/3);
//bond->setOrder(list.at(i+2).toInt());
}
list.clear();
}
}
}
}
示例8: String
bool KCFFile::readEDGE_(KCFFile::IndexAtomMap& index_to_atom)
{
if (!getLine().hasPrefix(EDGE_TAG))
{
throw Exception::ParseError(__FILE__, __LINE__,
String("'") + getLine() + "' (line " + String(getLineNumber()) + " of " + getName() + "'",
String("Expected EDGE tag: "));
}
Size number_of_edges = getLine().getField(1).toInt();
bool ok = true;
for (Position i = 0; ok && (i < number_of_edges); i++)
{
// Get the next line
readLine();
// Make sure the line starts with a blank
ok &= getLine().hasPrefix(CONTINUED_LINE);
// ??? Comments still mising
Position first = getLine().getField(1).toInt();
Position second = getLine().getField(2).toInt();
Position order = getLine().getField(3).toInt();
// Make sure the indices refered to do exist
ok &= index_to_atom.has(first) && index_to_atom.has(second);
if (ok)
{
Bond* bond = index_to_atom[first]->createBond(*index_to_atom[second]);
bond->setOrder(order);
}
}
return (ok && readLine());
}
示例9: printf
// Perform desired function
bool BondVariable::performFunction(int i, ReturnValue& rv, TreeNode* node)
{
Messenger::enter("BondVariable::performFunction");
// Cast 'i' into Accessors enum value
if ((i < 0) || (i >= nFunctions))
{
printf("Internal Error: FunctionAccessor id %i is out of range for Bond type.\n", i);
Messenger::exit("BondVariable::performFunction");
return false;
}
// Get current data from ReturnValue
bool result = true;
Bond* ptr = (Bond*) rv.asPointer(VTypes::BondData, result);
if (result) switch (i)
{
case (BondVariable::Partner):
rv.set(VTypes::AtomData, ptr->partner( (Atom*) node->argp(0, VTypes::AtomData)));
break;
default:
printf("Internal Error: Access to function '%s' has not been defined in BondVariable.\n", qPrintable(functionData[i].name));
result = false;
break;
}
Messenger::exit("BondVariable::performFunction");
return result;
}
示例10: setNewProductBond
void setNewProductBond(const Bond &origB, RWMOL_SPTR product,
unsigned bondBeginIdx, unsigned bondEndIdx) {
unsigned bondIdx =
product->addBond(bondBeginIdx, bondEndIdx, origB.getBondType()) - 1;
Bond *newB = product->getBondWithIdx(bondIdx);
newB->setBondDir(origB.getBondDir());
}
示例11: GetIndex
/////////////////////////////////////////////////////////////////////////////
// Function: Constructor
// Purpose: Creates a bond object from an existing Bond struct
// Input: A Bond object (passed by ref)
// A vector of MIAtom structs containing the atoms in the bond
// A vector of corresponding MIAtom objects to use for the new ptrs
// Output: None
// Note: Correspondence between MIAtom is inferred from their bondOrder
// in the vector containers
/////////////////////////////////////////////////////////////////////////////
Bond::Bond(const Bond &bond,
const MIAtomList &old_atoms,
const MIAtomList &new_atoms)
{
std::string error_message;
int i1 = GetIndex(static_cast<MIAtom*> (bond.getAtom1()), old_atoms);
int i2 = GetIndex(static_cast<MIAtom*> (bond.getAtom2()), old_atoms);
if (i1 < 0 || i2 < 0)
{
error_message = "Corrupted bond.";
throw error_message;
}
bondOrder = bond.bondOrder;
atom1 = new_atoms[i1];
atom2 = new_atoms[i2];
type = bond.type;
stereo = bond.stereo;
ideal_length = bond.ideal_length;
tolerance = bond.tolerance;
dict_include = bond.dict_include;
isaromatic = bond.isaromatic;
iscyclic = bond.iscyclic;
ring_system = bond.ring_system;
smallest_ring_size = bond.smallest_ring_size;
smallest_aromatic_ring = bond.smallest_aromatic_ring;
}
示例12: QL_REQUIRE
Spread BondFunctions::zSpread(const Bond& bond,
Real cleanPrice,
const shared_ptr<YieldTermStructure>& d,
const DayCounter& dayCounter,
Compounding compounding,
Frequency frequency,
Date settlement,
Real accuracy,
Size maxIterations,
Rate guess) {
if (settlement == Date())
settlement = bond.settlementDate();
QL_REQUIRE(BondFunctions::isTradable(bond, settlement),
"non tradable at " << settlement <<
" (maturity being " << bond.maturityDate() << ")");
Real dirtyPrice = cleanPrice + bond.accruedAmount(settlement);
dirtyPrice /= 100.0 / bond.notional(settlement);
return CashFlows::zSpread(bond.cashflows(),
d,
dirtyPrice,
dayCounter, compounding, frequency,
false, settlement, settlement,
accuracy, maxIterations, guess);
}
示例13: calcForces
void Molecule::calcForces() {
RigidBody* rb;
Bond* bond;
Bend* bend;
Torsion* torsion;
std::vector<RigidBody*> rbIter;
std::vector<Bond*> bondIter;;
std::vector<Bend*> bendIter;
std::vector<Torsion*> torsionIter;
for (rb = beginRigidBody(rbIter); rb != NULL; rb = nextRigidBody(rbIter)) {
rb->updateAtoms();
}
for (bond = beginBond(bondIter); bond != NULL; bond = nextBond(bondIter)) {
bond->calcForce();
}
for (bend = beginBend(bendIter); bend != NULL; bend = nextBend(bendIter)) {
bend->calcForce();
}
for (torsion = beginTorsion(torsionIter); torsion != NULL; torsion = nextTorsion(torsionIter)) {
torsion->calcForce();
}
}
示例14: info_
DistanceFinder::DistanceFinder(SimInfo* info) : info_(info) {
nObjects_.push_back(info_->getNGlobalAtoms()+info_->getNGlobalRigidBodies());
nObjects_.push_back(info_->getNGlobalBonds());
nObjects_.push_back(info_->getNGlobalBends());
nObjects_.push_back(info_->getNGlobalTorsions());
nObjects_.push_back(info_->getNGlobalInversions());
stuntdoubles_.resize(nObjects_[STUNTDOUBLE]);
bonds_.resize(nObjects_[BOND]);
bends_.resize(nObjects_[BEND]);
torsions_.resize(nObjects_[TORSION]);
inversions_.resize(nObjects_[INVERSION]);
SimInfo::MoleculeIterator mi;
Molecule::AtomIterator ai;
Molecule::RigidBodyIterator rbIter;
Molecule::BondIterator bondIter;
Molecule::BendIterator bendIter;
Molecule::TorsionIterator torsionIter;
Molecule::InversionIterator inversionIter;
Molecule* mol;
Atom* atom;
RigidBody* rb;
Bond* bond;
Bend* bend;
Torsion* torsion;
Inversion* inversion;
for (mol = info_->beginMolecule(mi); mol != NULL;
mol = info_->nextMolecule(mi)) {
for(atom = mol->beginAtom(ai); atom != NULL;
atom = mol->nextAtom(ai)) {
stuntdoubles_[atom->getGlobalIndex()] = atom;
}
for (rb = mol->beginRigidBody(rbIter); rb != NULL;
rb = mol->nextRigidBody(rbIter)) {
stuntdoubles_[rb->getGlobalIndex()] = rb;
}
for (bond = mol->beginBond(bondIter); bond != NULL;
bond = mol->nextBond(bondIter)) {
bonds_[bond->getGlobalIndex()] = bond;
}
for (bend = mol->beginBend(bendIter); bend != NULL;
bend = mol->nextBend(bendIter)) {
bends_[bend->getGlobalIndex()] = bend;
}
for (torsion = mol->beginTorsion(torsionIter); torsion != NULL;
torsion = mol->nextTorsion(torsionIter)) {
torsions_[torsion->getGlobalIndex()] = torsion;
}
for (inversion = mol->beginInversion(inversionIter); inversion != NULL;
inversion = mol->nextInversion(inversionIter)) {
inversions_[inversion->getGlobalIndex()] = inversion;
}
}
}
示例15: nextCashFlow
Leg::const_iterator BondFunctions::nextCashFlow(const Bond& bond,
Date settlement) {
if (settlement == Date())
settlement = bond.settlementDate();
return CashFlows::nextCashFlow(bond.cashflows(),
false, settlement);
}