本文整理汇总了Python中pele.storage.Database.transition_states方法的典型用法代码示例。如果您正苦于以下问题:Python Database.transition_states方法的具体用法?Python Database.transition_states怎么用?Python Database.transition_states使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pele.storage.Database
的用法示例。
在下文中一共展示了Database.transition_states方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: TestOptimCollagen
# 需要导入模块: from pele.storage import Database [as 别名]
# 或者: from pele.storage.Database import transition_states [as 别名]
class TestOptimCollagen(unittest.TestCase):
"""test a known value for a large database"""
def setUp(self):
from pele.utils.optim_compatibility import OptimDBConverter
from pele.storage import Database
ndof = 10 # wrong, but who cares.
self.db = Database()
current_dir = os.path.dirname(__file__)
converter = OptimDBConverter(self.db, ndof=ndof, mindata=current_dir+"/collagen.min.data",
tsdata=current_dir+"/collagen.ts.data", assert_coords=False)
converter.convert_no_coords()
def test1(self):
m1 = self.db.getMinimum(1)
m2 = self.db.getMinimum(2)
m3 = self.db.getMinimum(3)
m4 = self.db.getMinimum(4)
rcalc = RateCalculation(self.db.transition_states(), [m1], [m2], T=0.592)
rcalc.compute_rates()
self.assertAlmostEqual(rcalc.get_rate_AB(), 7106337458., delta=1e4)
self.assertAlmostEqual(rcalc.get_rate_BA(), 1955395816., delta=1e4)
rcalc = RateCalculation(self.db.transition_states(), [m1,m3], [m2, m4], T=0.592)
rcalc.compute_rates()
self.assertAlmostEqual(rcalc.get_rate_AB(), 8638736600., delta=1e4)
self.assertAlmostEqual(rcalc.get_rate_BA(), 3499625167., delta=1e4)
rla = RatesLinalg(self.db.transition_states(), [m1], [m2], T=0.592)
rAB = rla.compute_rates()
self.assertAlmostEqual(rAB, 7106337458., delta=1e4)
rla = RatesLinalg(self.db.transition_states(), [m1, m3], [m2, m4], T=0.592)
rAB = rla.compute_rates()
self.assertAlmostEqual(rAB, 8638736600., delta=1e4)
示例2: test1
# 需要导入模块: from pele.storage import Database [as 别名]
# 或者: from pele.storage.Database import transition_states [as 别名]
def test1(self):
current_dir = os.path.dirname(__file__)
db = Database()
converter = OptimDBConverter(db,
mindata=os.path.join(current_dir, "min.data"),
tsdata=os.path.join(current_dir, "ts.data"),
pointsmin=os.path.join(current_dir, "points.min"),
pointsts=os.path.join(current_dir, "points.ts"),
endianness="<")
converter.convert()
self.assertEqual(db.number_of_minima(), 2)
self.assertEqual(db.number_of_transition_states(), 1)
ts = db.transition_states()[0]
self.assertAlmostEqual(ts.coords[0], 1.548324, 5)
self.assertAlmostEqual(ts.coords[2], 0.18178001, 5)
self.assertAlmostEqual(ts.coords[-1], -0.50953229, 5)
self.assertEqual((180,), ts.coords.shape)
m = db.minima()[0]
print(repr(m.coords))
self.assertAlmostEqual(m.coords[0], 1.53700142, 5)
self.assertAlmostEqual(m.coords[2], 0.87783657, 5)
self.assertAlmostEqual(m.coords[-1], -0.50953229, 5)
self.assertEqual((180,), m.coords.shape)
示例3: test2
# 需要导入模块: from pele.storage import Database [as 别名]
# 或者: from pele.storage.Database import transition_states [as 别名]
def test2(self):
from pele.utils.tests.test_disconnectivity_graph import create_random_database
db = create_random_database(nmin=20, nts=15)
delete=False
mdata = tempfile.NamedTemporaryFile(delete=delete, suffix=".min.data")
tsdata = tempfile.NamedTemporaryFile(delete=delete, suffix=".ts.data")
pm = tempfile.NamedTemporaryFile(delete=delete)
pts = tempfile.NamedTemporaryFile(delete=delete)
print(mdata.name, tsdata.name)
writer = WritePathsampleDB(db,
mindata=mdata.name,
tsdata=tsdata.name,
pointsmin=pm.name,
pointsts=pts.name,
endianness="<")
writer.write_db()
newdb = Database()
reader = OptimDBConverter(newdb,
mindata=mdata.name,
tsdata=tsdata.name,
pointsmin=pm.name,
pointsts=pts.name,
endianness="<")
reader.convert()
for m1, m2 in zip(db.minima(), newdb.minima()):
self.assertAlmostEqual(m1.energy, m2.energy)
_base_test.assert_arrays_almost_equal(self, m1.coords, m2.coords)
for ts1, ts2 in zip(db.transition_states(), newdb.transition_states()):
self.assertAlmostEqual(ts1.energy, ts2.energy)
_base_test.assert_arrays_almost_equal(self, ts1.coords, ts2.coords)
self.assertAlmostEqual(ts1.minimum1.energy, ts2.minimum1.energy)
self.assertAlmostEqual(ts1.minimum2.energy, ts2.minimum2.energy)
示例4: len
# 需要导入模块: from pele.storage import Database [as 别名]
# 或者: from pele.storage.Database import transition_states [as 别名]
print len(A), "A minima"
print len(B), "B minima"
print A[0].energy
print B[0].energy
#rate_constants = reduce_rates(rate_constants, B, A=A)
print "computing rates from minima data"
T = .05
print "temperature", T
pele_rates = RateCalculation(db.transition_states(), A, B, T=T, use_fvib=True)
pele_rates._make_kmc_graph()
rates = pele_rates.rate_constants
weights = pele_rates._get_equilibrium_occupation_probabilities()
rate_norm = np.exp(-pele_rates.max_log_rate)
#Peq = pele_rates._get_equilibrium_occupation_probabilities()
print "reducing rates"
rate_constants = reduce_rates(rates, B, A=A)
print "max rate constant", max(rates.itervalues())
print "min rate constant", min(rates.itervalues())
if False:
示例5: TestDB
# 需要导入模块: from pele.storage import Database [as 别名]
# 或者: from pele.storage.Database import transition_states [as 别名]
class TestDB(unittest.TestCase):
def setUp(self):
self.db = Database()
self.nminima = 10
for i in range(self.nminima):
e = float(i)
self.db.addMinimum(e, [e])
self.nts = 3
self.db.addTransitionState(0., [0.], self.db.minima()[0], self.db.minima()[1], eigenval=0., eigenvec=[0.])
self.db.addTransitionState(0., [0.], self.db.minima()[1], self.db.minima()[2], eigenval=0., eigenvec=[0.])
self.db.addTransitionState(0., [0.], self.db.minima()[0], self.db.minima()[2], eigenval=0., eigenvec=[0.])
def test_size(self):
self.assertEqual(len(self.db.minima()), self.nminima)
def test_energy(self):
m = self.db.minima()[0]
self.assertEqual(m.energy, 0.)
def test_coords(self):
m = self.db.minima()[0]
self.assertEqual(m.coords, [0.])
def test_sizets(self):
self.assertEqual(len(self.db.transition_states()), self.nts)
def test_energyts(self):
ts = self.db.transition_states()[0]
self.assertEqual(ts.energy, 0.)
def test_coordsts(self):
ts = self.db.transition_states()[0]
self.assertEqual(ts.coords, [0.])
def test_remove_minimum(self):
m = self.db.minima()[0]
self.db.removeMinimum(m)
self.assertEqual(len(self.db.minima()), self.nminima-1)
self.assertNotIn(m, self.db.minima())
# m should have 2 minima. both of those should be gone
self.assertEqual(len(self.db.transition_states()), self.nts-2)
def test_remove_ts(self):
ts = self.db.transition_states()[0]
self.db.remove_transition_state(ts)
self.assertEqual(self.db.number_of_transition_states(), self.nts-1)
self.assertNotIn(ts, self.db.transition_states())
# m should have 2 minima. both of those should be gone
self.assertEqual(self.db.number_of_minima(), self.nminima)
def test_getTransitionState(self):
m1 = self.db.minima()[0]
m2 = self.db.minima()[1]
m3 = self.db.minima()[-1]
self.assertIsNotNone(self.db.getTransitionState(m1, m2))
self.assertIsNone(self.db.getTransitionState(m1, m3))
def test_getMinimum(self):
m = self.db.minima()[0]
self.assertEqual(m, self.db.getMinimum(m._id))
def test_minimum_adder(self):
ma = self.db.minimum_adder()
ma(101., [101.])
self.assertEqual(len(self.db.minima()), self.nminima+1)
def test_merge_minima(self):
m1 = self.db.minima()[0]
m2 = self.db.minima()[1]
self.db.mergeMinima(m1, m2)
self.assertEqual(len(self.db.minima()), self.nminima-1)
# transition states shouldn't be deleted
self.assertEqual(len(self.db.transition_states()), self.nts)
def test_number_of_minima(self):
self.assertEqual(self.nminima, self.db.number_of_minima())
def test_number_of_transition_states(self):
self.assertEqual(self.nts, self.db.number_of_transition_states())
def test_highest_energy_minimum(self):
m1 = self.db._highest_energy_minimum()
m2 = self.db.minima()[-1]
self.assertEqual(m1, m2)
def test_maximum_number_of_minima(self):
m = self.db.addMinimum(-1., [-1.], max_n_minima=self.nminima)
self.assertEqual(self.nminima, self.db.number_of_minima())
self.assertIn(m, self.db.minima())
def test_maximum_number_of_minima_largestE(self):
e = float(self.nminima + 1)
m = self.db.addMinimum(e, [e], max_n_minima=self.nminima)
self.assertEqual(self.nminima, self.db.number_of_minima())
self.assertIsNone(m)
#.........这里部分代码省略.........
示例6: Database
# 需要导入模块: from pele.storage import Database [as 别名]
# 或者: from pele.storage.Database import transition_states [as 别名]
db = Database(db="tip4p_8.sqlite", createdb=False)
graph = TSGraph(db)
dg = DisconnectivityGraph(graph.graph, db.minima(), subgraph_size=20)
dg.calculate()
dg.plot()
for m in db.minima():
if m.pgorder != 2:
print m.pgorder
m.free_energy = m.energy + kbT * 0.5*m.fvib + kbT*np.log(m.pgorder)
for ts in db.transition_states():
# if ts.pgorder != 2:
print ts.pgorder
#assert ts.pgorder == 2
ts.free_energy = ts.energy + kbT * 0.5*ts.fvib + kbT*np.log(ts.pgorder) + kbT*np.log(kbT)
if ts.free_energy > ts.minimum1.free_energy or ts.free_energy > ts.minimum2.free_energy:
print "warning, free energy of transition state lower than minimum"
print ts.free_energy, ts.minimum1.free_energy, ts.minimum2.free_energy
print ts.energy, ts.minimum1.energy, ts.minimum2.energy
dg_F = DisconnectivityGraph(graph.graph, db.minima(), energy_attribute="free_energy", subgraph_size=20)
dg_F.calculate()
dg_F.plot()