Пример #1
0
void Geometry::computeGasteigerCharges()
{
// This is returning zero charges for some reason
return;
    qDebug() << "Geometry::computeGasteigerCharges() not working correctly";
    OpenBabel::OBAtom* obAtom(0);
    OpenBabel::OBMol obMol;

    obMol.BeginModify();
    obMol.UnsetPartialChargesPerceived();
    for (int i = 0; i < m_atoms.size(); ++i) {
        obAtom = obMol.NewAtom();
        obAtom->SetAtomicNum(m_atoms[i]->atomicNumber());
        obAtom->SetVector(m_coordinates[i].x, m_coordinates[i].y, m_coordinates[i].z);
    }
    obMol.SetTotalCharge(m_charge);
    obMol.SetTotalSpinMultiplicity(m_multiplicity);
    obMol.EndModify();
    
    OpenBabel::OBMolAtomIter iter(&obMol);
    for (int i = 0; i < m_atoms.size(); ++i, ++iter) {
        int index(iter->GetIdx());
        qDebug() << "Setting Gasteiger Charge for" << index << "to" << iter->GetPartialCharge();
        GasteigerCharge& charge(m_atoms[i]->getProperty<GasteigerCharge>());
        charge.setValue(iter->GetPartialCharge());
    }
}
Пример #2
0
List Factory::convert(Data::Geometry& geometry)
{
   List list;
   Atoms* atoms(new Atoms());
   Bonds* bonds(new Bonds());
   list.append(atoms);
   list.append(bonds);

   unsigned nAtoms(geometry.nAtoms());
   OpenBabel::OBMol obMol;
   obMol.BeginModify();
   AtomMap atomMap;
   
   for (unsigned i = 0; i < nAtoms; ++i) {
       unsigned Z(geometry.atomicNumber(i));
       qglviewer::Vec position(geometry.position(i));

       Atom* atom(new Atom(geometry.atomicNumber(i)));
       atom->setPosition(geometry.position(i));
       atoms->appendLayer(atom);

       OpenBabel::OBAtom* obAtom(obMol.NewAtom());
       obAtom->SetAtomicNum(Z);
       obAtom->SetVector(position.x, position.y, position.z);
       atomMap.insert(obAtom, atom);
   }

   obMol.SetTotalCharge(geometry.charge());
   obMol.SetTotalSpinMultiplicity(geometry.multiplicity());
   obMol.EndModify();
   obMol.ConnectTheDots();
   obMol.PerceiveBondOrders();

   for (OpenBabel::OBMolBondIter obBond(&obMol); obBond; ++obBond) {
       Atom* begin(atomMap.value(obBond->GetBeginAtom()));
       Atom* end(atomMap.value(obBond->GetEndAtom()));
       Bond* bond(new Bond(begin, end));
       bond->setOrder(obBond->GetBondOrder());
       bonds->appendLayer(bond);
   }

   return list;
}