bool SimpleWireEngine::renderOpaque(PainterDevice *pd) { glDisable(GL_LIGHTING); Color *map = colorMap(); // possible custom color map if (!map) map = pd->colorMap(); // fall back to global color map foreach(Bond *b, bonds()) { const Atom* atom1 = b->beginAtom(); const Vector3d & v1 = *atom1->pos(); const Atom* atom2 = b->endAtom(); const Vector3d & v2 = *atom2->pos(); map->set(atom1); pd->painter()->setColor(map); if (atom1->atomicNumber() != atom2->atomicNumber()) { // compute the mid-point between the two atoms Vector3d v3((v1 + v2) / 2.0); pd->painter()->drawLine(v1, v3, 1.0); map->set(atom2); pd->painter()->setColor(map); pd->painter()->drawLine(v3, v2, 1.0); } else { // Just draw a line pd->painter()->drawLine(v1, v2, 1.0); } } glEnable(GL_LIGHTING); return true; }
int main(){ atoms(); velocities(); bonds(); angles(); dihedrals(); }
void H2OAngleBondAnalysis::Analysis () { h2os.Reload(); h2os.FindWaterSurfaceLocation (); for (Wat_it it = h2os.begin(); it != h2os.end(); it++) { double distance = system_t::Position((*it)->ReferencePoint()) - h2os.SurfaceLocation(); // calculate and bin the water OH bond lengths bonds (distance, (*it)->OH1().norm()); bonds (distance, (*it)->OH2().norm()); // calculate the angle of the water molecule and bin it double angle = (*it)->Angle(); angles (distance, acos(angle)*180.0/M_PI); } return; }
void StabilizeStepper::initialize_neighbor_list_managers() { const std::size_t num_beads(_space->num_beads()); PairList bond_pair(num_beads); std::list<std::pair<std::size_t, std::size_t> > bonds(_model->list_bonds()); for (auto itr(bonds.begin()); itr != bonds.end(); itr++) { bond_pair.add_pair(*itr); bond_pair.add_pair(std::make_pair((*itr).second, (*itr).first)); } PairList excludes(num_beads); for (std::size_t i(0); i < num_beads; ++i) { for (auto itr(bond_pair.begin(i)); itr != bond_pair.end(i); ++itr) { excludes.add_pair(std::make_pair(i, *itr)); for (auto jtr(bond_pair.begin(*itr)); jtr != bond_pair.end(*itr); ++jtr) { excludes.add_pair(std::make_pair(i, *jtr)); } } } Model::inter_potential_container inter_potentials(_model->list_inter_potentials()); for (auto itr(inter_potentials.begin()); itr != inter_potentials.end(); ++itr) { const double r_c((*itr)->get_cutoff_radius()); NeighborListManager manager(num_beads, r_c, r_c*3, std::numeric_limits<double>::infinity()); // TODO parameter fitting (*itr)->set_neighbor_list(manager.get_neighbor_list()); for (std::size_t i(0); i < num_beads-1; ++i) { std::string symbol0(_space->symbol(i)); for (std::size_t j(i+1); j < num_beads; j++) { std::string symbol1(_space->symbol(j)); if ((*itr)->is_valid_pair(symbol0, symbol1)) { bool is_exclude(false); for (auto itr2(excludes.begin(i)); itr2 != excludes.end(i); ++itr2) if (j == *itr2) { is_exclude = true; break; } if (!is_exclude) manager.add_candidate(std::make_pair(i,j)); } } } manager.update(*(_space.get())); _neighbor_list_managers.push_back(manager); } }
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; }
int main(){ char *dumpAtoms; dumpAtoms = (char*) malloc(2000); char *restartFile; restartFile = (char*) malloc(2000); char *newRestartFile; newRestartFile = (char*) malloc(2000); dumpAtoms = "atom.restart.moveLiquid"; restartFile = "restart.250000.data"; newRestartFile = "restart.250000.data.consecutive"; intro(restartFile, newRestartFile); consecutiveAtoms(dumpAtoms, newRestartFile); bonds(restartFile, newRestartFile); angles(restartFile, newRestartFile); dihedrals(restartFile, newRestartFile); }
void prepareBondInsert(int bonus=100) { if (bonds().size() == bonds().capacity()) bonds().reserve(bonds().size() + bonus); }
/// Returns the number of bonds in the residue. size_t Residue::bondCount() const { return bonds().size(); }