本文整理匯總了Python中pele.utils.disconnectivity_graph.DisconnectivityGraph.label_minima方法的典型用法代碼示例。如果您正苦於以下問題:Python DisconnectivityGraph.label_minima方法的具體用法?Python DisconnectivityGraph.label_minima怎麽用?Python DisconnectivityGraph.label_minima使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類pele.utils.disconnectivity_graph.DisconnectivityGraph
的用法示例。
在下文中一共展示了DisconnectivityGraph.label_minima方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: make_disconnectivity_graph
# 需要導入模塊: from pele.utils.disconnectivity_graph import DisconnectivityGraph [as 別名]
# 或者: from pele.utils.disconnectivity_graph.DisconnectivityGraph import label_minima [as 別名]
def make_disconnectivity_graph(system, database, vinputs, vtargets):
from pele.utils.disconnectivity_graph import DisconnectivityGraph, database2graph
import matplotlib.pyplot as plt
graph = database2graph(database)
dg = DisconnectivityGraph(graph, nlevels=5, center_gmin=True, Emax=50.0, subgraph_size=3)
dg.calculate()
pot = system.get_potential()
validation_energy = lambda m: pot.getValidationEnergy(m.coords, vinputs, vtargets)
vmin = min(graph.nodes(), key=lambda m: validation_energy(m))
labels = {vmin : "vmin"}
print vmin.energy, min(database.minima(), key = lambda m : validation_energy(m)).energy
# for m in graph.nodes():
# print m.energy
for t in database.transition_states():
print t.minimum1.energy, t.minimum2.energy, t.energy
if abs(t.minimum1.energy-12.1884413947)<0.1 or abs(t.minimum2.energy-12.1884413947)<0.1:
print t.minimum1.energy, t.minimum2.energy, t.energy
# for u,v,data in graph.edges(data=True):
# ts = data["ts"]
# if abs(u.energy-12.1884413947)<0.1 or abs(v.energy-12.1884413947)<0.1:
# print u.energy, v.energy, ts.energy
dg.plot()
dg.label_minima(labels)
plt.show()
示例2: test_color_value
# 需要導入模塊: from pele.utils.disconnectivity_graph import DisconnectivityGraph [as 別名]
# 或者: from pele.utils.disconnectivity_graph.DisconnectivityGraph import label_minima [as 別名]
def test_color_value(self):
dgraph = DisconnectivityGraph(self.tsgraph)
dgraph.calculate()
def minimum_to_value(m):
if m.energy < 5.:
return m.energy
else:
return None
dgraph.color_by_value(minimum_to_value)
dgraph.plot(linewidth=2.)
dgraph.label_minima({self.db.minima()[0]: "gmin",
self.db.minima()[1]: "2nd lowest"})
if _show:
from matplotlib import pyplot as plt
plt.title("color by value")
dgraph.show()
示例3: make_validation_disconnectivity_graph
# 需要導入模塊: from pele.utils.disconnectivity_graph import DisconnectivityGraph [as 別名]
# 或者: from pele.utils.disconnectivity_graph.DisconnectivityGraph import label_minima [as 別名]
def make_validation_disconnectivity_graph(system, database):
from pele.utils.disconnectivity_graph import DisconnectivityGraph, database2graph
import matplotlib.pyplot as plt
inputs, targets = get_validation_data()
""" make validation_energy a minimum object"""
pot = system.get_potential()
validation_energy = lambda m: pot.getValidationEnergy(m.coords, inputs, targets)
graph = database2graph(database)
for m in graph.nodes():
m.validation_energy = validation_energy(m)
for u,v,data in graph.edges(data=True):
ts = data["ts"]
ve = max([validation_energy(ts), u.validation_energy, v.validation_energy])
ts.validation_energy = ve
gmin = min(graph.nodes(), key=lambda m:m.energy)
# smin = graph.nodes().sort(key=lambda m:m.energy)
smin = sorted(graph.nodes(), key=lambda m:m.energy)
# gmax = max(graph.nodes(), key=lambda m:m.energy)
labels = dict()
for i,s in enumerate(smin):
if i % 10 == 0: labels[s] = str(i)
# labels = {gmin : "gmin"}
dg = DisconnectivityGraph(graph, nlevels=10, center_gmin=True, energy_attribute="validation_energy", subgraph_size=3)
dg.calculate()
# minimum_to_validation_energy = lambda m: pot.getValidationEnergy(m.coords, inputs, targets)
# dg.color_by_value(validation_energy)
dg.plot()
dg.label_minima(labels)
print labels
plt.show()