Esempio n. 1
0
/// Returns the polarity of the bond. This is calculated as the
/// absolute value of the difference in electronegativity between the
/// two atoms in the bond.
Real Bond::polarity() const
{
    if(atom1()->atomicNumber() == atom2()->atomicNumber()){
        return 0;
    }

    return std::abs(atom1()->electronegativity() - atom2()->electronegativity());
}
Esempio n. 2
0
/// Returns the dipole moment for the bond.
Vector3 Bond::dipoleMoment() const
{
    Point3 a = atom1()->position();
    Point3 b = atom2()->position();
    Real qa = atom1()->partialCharge();
    Real qb = atom2()->partialCharge();

    return (a - b) * (qa - qb);
}
	void SolventAccessibleSurface::createEdge(Position j)
	{
		SASEdge* edge = edges_[j];
		edge->index_ = j;
		RSEdge* rsedge = reduced_surface_->edges_[j];

		if (rsedge->face_[0] != NULL)
		{
			edge->vertex_[0] = vertices_[rsedge->face_[0]->index_];
			edge->vertex_[1] = vertices_[rsedge->face_[1]->index_];
		}
		else
		{
			edge->vertex_[0] = NULL;
			edge->vertex_[1] = NULL;
		}

		edge->face_[0] = faces_[rsedge->vertex_[0]->index_];
		edge->face_[1] = faces_[rsedge->vertex_[1]->index_];
		edge->angle_ = rsedge->angle_;
		edge->circle_.p = rsedge->center_of_torus_;
		edge->circle_.radius = rsedge->radius_of_torus_;

		TSphere3<double> atom1(reduced_surface_->atom_[rsedge->vertex_[0]->atom_]);
		TSphere3<double> atom2(reduced_surface_->atom_[rsedge->vertex_[1]->atom_]);
		
		edge->circle_.n = atom1.p-atom2.p;
	}
Esempio n. 4
0
// --- Properties ---------------------------------------------------------- //
/// Returns the atom at \p index in the bond. Index must be either
/// \c 0 or \c 1.
Atom* Bond::atom(size_t index) const
{
    return index == 0 ? atom1() : atom2();
}
Esempio n. 5
0
/// Returns the length of the bond. Length is in Angstroms.
Real Bond::length() const
{
    return atom1()->distance(atom2());
}
Esempio n. 6
0
// --- Geometry ------------------------------------------------------------ //
/// Returns the center point of the bond. The center is equal to the
/// midpoint between the two atoms in the bond.
Point3 Bond::center() const
{
    return chemkit::geometry::midpoint(atom1()->position(),
                                       atom2()->position());
}
Esempio n. 7
0
/// Returns \c true if either of the two atoms in the bond are
/// terminal.
bool Bond::isTerminal() const
{
    return atom1()->isTerminal() || atom2()->isTerminal();
}
Esempio n. 8
0
/// Returns \c true if the bond contains an atom of the element \p a
/// and an atom of the element \p b.
///
/// For example, to check if this is a carbonyl bond you could use:
/// \code
/// if(bond->containsBoth(Atom::Carbon, Atom::Oxygen) && bond->order() == Bond::Double){
///     // it is a carbonyl
/// }
/// \endcode
bool Bond::containsBoth(const Element &a, const Element &b) const
{
    return (atom1()->is(a) && atom2()->is(b)) || (atom2()->is(a) && atom1()->is(b));
}
Esempio n. 9
0
/// Returns \c true if the bond contains an atom of the given
/// \p element.
bool Bond::contains(const Element &element) const
{
    return atom1()->is(element) || atom2()->is(element);
}
Esempio n. 10
0
// --- Structure ----------------------------------------------------------- //
/// Returns \c true if the bond contains atom.
bool Bond::contains(const Atom *atom) const
{
    return atom1() == atom || atom2() == atom;
}
Esempio n. 11
0
/// Returns the fragment the bond is a part of.
Fragment* Bond::fragment() const
{
    return atom1()->fragment();
}
Esempio n. 12
0
int main(int argc, char* argv[])
{
    std::shared_ptr<Empty> blank;
    std::shared_ptr<Program> prg(new Program());

    std::shared_ptr<SharedDecl> shDecl1(new SharedDecl("y", blank));
    prg->Add(shDecl1);

    std::shared_ptr<Node> initX(new Atom("2"));
    std::shared_ptr<SharedDecl> shDecl2(new SharedDecl("x", initX));
    prg->Add(shDecl2);

    std::shared_ptr<Sub> sub1(new Sub("Main"));
    sub1->AddParam("a");
    sub1->AddParam("b");
    prg->Add(sub1);

    std::shared_ptr<Atom> atomA(new Atom("a"));
    std::shared_ptr<Atom> atomB(new Atom("b"));
    std::shared_ptr<BinaryOp> initRes(new BinaryOp("add", atomA, atomB));
    std::shared_ptr<VarDecl> resDecl(new VarDecl("res", initRes));
    sub1->Add(resDecl);

    std::shared_ptr<Atom> atom3i(new Atom("3"));
    std::shared_ptr<Atom> atom5i(new Atom("5"));
    std::shared_ptr<BinaryOp> newParam(new BinaryOp("add", atom3i, atom5i));
    std::shared_ptr<Allocation> allocat(new Allocation(newParam));
    std::shared_ptr<Atom> atomArr(new Atom("arr"));
    std::shared_ptr<Assignation> asignNew3(new Assignation(atomArr, allocat));
    sub1->Add(asignNew3);

    std::shared_ptr<Atom> atomArrBis(new Atom("arr"));
    std::shared_ptr<Deallocation> deallocat(new Deallocation(atomArrBis));
    sub1->Add(deallocat);

    std::shared_ptr<Atom> atomC(new Atom("res"));
    std::shared_ptr<BinaryOp> subCsumAB(new BinaryOp("substract", atomC, initRes));
    std::shared_ptr<Assignation> incC(new Assignation(atomC, subCsumAB));
    sub1->Add(incC);

    std::shared_ptr<Atom> atom0(new Atom("0"));
    std::shared_ptr<BinaryOp> cond1cond(new BinaryOp("equals", atomC, atom0));
    std::shared_ptr<If> cond1(new If(cond1cond, "10", "20"));
    sub1->Add(cond1);

    std::shared_ptr<Atom> atom1(new Atom("1"));
    std::shared_ptr<Atom> atom10(new Atom("10"));
    std::shared_ptr<For> for1(new For("i", atom1, atom10, atom1));
    sub1->Add(for1);

    std::shared_ptr<BinaryOp> addC1(new BinaryOp("add", atomC, atom1));
    std::shared_ptr<Assignation> incResActually(new Assignation(atomC, addC1));
    for1->Add(incResActually);

    std::shared_ptr<Loop> loop1(new Loop(cond1cond));
    loop1->Add(for1); // don't double reference ever in practice...
    loop1->Add(addC1);
    sub1->Add(loop1);

    std::shared_ptr<Call> call1(new Call("testFun", ""));
    call1->AddParam(atomA);
    call1->AddParam(addC1);
    sub1->Add(call1);

    std::shared_ptr<Return> ret1(new Return(atom0));
    sub1->Add(ret1);

    XMLDumpVisitor v;
    prg->Accept(&v);

    return 0;
}