def test2(self): from pele.storage import Database from pele.systems import LJCluster np.random.seed(0) natoms = 13 system = LJCluster(natoms) pot = system.get_potential() mindist = system.get_mindist(niter=1) db = Database() db.addMinimum(pot.getEnergy(_x1), _x1) db.addMinimum(pot.getEnergy(_x2), _x2) m1, m2 = db.minima() connect = DoubleEndedConnect(m1, m2, pot, mindist, db, verbosity=10) connect.connect() self.assertTrue(connect.success()) path = connect.returnPath()
if (myconnect.graph.areConnected(min1, min2)): print "ALERT: The minima are already connected in the database file", dbfile print " Delete it for a fresh run." myconnect.connect() print "" print "found a path!" #the path is now saved in the database. Lets retrieve it and #print it in a more visual format #now retrieve the path for printing print "" mints, S, energies = myconnect.returnPath() nmin = (len(mints)-1)/2 + 1 nts = nmin-1 print "the path has %d minima and %d transition states" % (nmin, nts) eofs = "path.EofS" print "saving energies to", eofs with open(eofs, "w") as fout: for i in range(len(S)): fout.write("%f %f\n" % (S[i], energies[i])) xyzfile = "path.xyz" print "saving path in xyz format to", xyzfile with open(xyzfile, "w") as fout: for m in mints: write_xyz(fout, m.coords, title=str(m.energy))
if (myconnect.graph.areConnected(min1, min2)): print "ALERT: The minima are already connected in the database file", dbfile print " Delete it for a fresh run." myconnect.connect() print "" print "found a path!" # the path is now saved in the database. Lets retrieve it and # print it in a more visual format # now retrieve the path for printing print "" mints, S, energies = myconnect.returnPath() nmin = (len(mints) - 1) / 2 + 1 nts = nmin - 1 print "the path has %d minima and %d transition states" % (nmin, nts) eofs = "path.EofS" print "saving energies to", eofs with open(eofs, "w") as fout: for i in range(len(S)): fout.write("%f %f\n" % (S[i], energies[i])) xyzfile = "path.xyz" print "saving path in xyz format to", xyzfile with open(xyzfile, "w") as fout: for m in mints: write_xyz(fout, m.coords, title=str(m.energy))