def compute_rates_and_committors(self): """compute the rates from A to B and vice versa""" self.minima2rates.run() self.reducer = NGT(self.minima2rates.rate_constants, self.minima2rates.A, self.minima2rates.B, weights=self.minima2rates.weights) self.reducer.compute_rates_and_committors()
def do_check(self, A, B, nnodes=20, nedges=20): np.random.seed(0) maker = _MakeRandomGraph(nnodes=20, nedges=20, node_set=A + B) maker.run() reducer = NGT(maker.rates, A, B, debug=False) reducer.compute_rates() rAB = reducer.get_rate_AB() rBA = reducer.get_rate_BA()
def do_check(self, A, B, nnodes=20, nedges=20): maker = _MakeRandomGraph(nnodes=20, nedges=20, node_set=A+B) rates = maker.make_rates() reducer = TwoStateRates(rates, A, B) reducer.compute_rates() reducer.compute_committors() from pele.rates._ngt_cpp import NGT ngt = NGT(rates, A, B) ngt.compute_rates() self.assertAlmostEqual(reducer.get_rate_AB(), ngt.get_rate_AB(), 7) self.assertAlmostEqual(reducer.get_rate_AB_SS(), ngt.get_rate_AB_SS(), 7)
class RateCalculation(object): """compute transition rates from a database of minima and transition states Parameters ---------- transition_states: iteratable list (or iterator) of transition states that define the rate network A, B : iterables groups of minima specifying the reactant and product groups. The rates returned will be the rate from A to B and vice versa. T : float temperature at which to do the the calculation. Should be in units of energy, i.e. include the factor of k_B if necessary. """ def __init__(self, transition_states, A, B, T=1., use_fvib=True): self.minima2rates = _Minima2Rates(transition_states, A, B, T=T, use_fvib=use_fvib) def compute_rates(self): """compute the rates from A to B and vice versa""" self.minima2rates.run() self.reducer = NGT(self.minima2rates.rate_constants, self.minima2rates.A, self.minima2rates.B, weights=self.minima2rates.weights) self.reducer.compute_rates() def compute_rates_and_committors(self): """compute the rates from A to B and vice versa""" self.minima2rates.run() self.reducer = NGT(self.minima2rates.rate_constants, self.minima2rates.A, self.minima2rates.B, weights=self.minima2rates.weights) self.reducer.compute_rates_and_committors() def get_rate_AB(self): return old_div(self.reducer.get_rate_AB(), self.minima2rates.rate_norm) def get_rate_BA(self): return old_div(self.reducer.get_rate_BA(), self.minima2rates.rate_norm) def get_rate_AB_SS(self): return old_div(self.reducer.get_rate_AB_SS(), self.minima2rates.rate_norm) def get_rate_BA_SS(self): return old_div(self.reducer.get_rate_BA_SS(), self.minima2rates.rate_norm) def get_committors(self): committors = self.reducer.get_committors() return committors
class RateCalculation(object): """compute transition rates from a database of minima and transition states Parameters ---------- transition_states: iteratable list (or iterator) of transition states that define the rate network A, B : iterables groups of minima specifying the reactant and product groups. The rates returned will be the rate from A to B and vice versa. T : float temperature at which to do the the calculation. Should be in units of energy, i.e. include the factor of k_B if necessary. """ def __init__(self, transition_states, A, B, T=1.0, use_fvib=True): self.minima2rates = _Minima2Rates(transition_states, A, B, T=T, use_fvib=use_fvib) def compute_rates(self): """compute the rates from A to B and vice versa""" self.minima2rates.run() self.reducer = NGT( self.minima2rates.rate_constants, self.minima2rates.A, self.minima2rates.B, weights=self.minima2rates.weights, ) self.reducer.compute_rates() def compute_rates_and_committors(self): """compute the rates from A to B and vice versa""" self.minima2rates.run() self.reducer = NGT( self.minima2rates.rate_constants, self.minima2rates.A, self.minima2rates.B, weights=self.minima2rates.weights, ) self.reducer.compute_rates_and_committors() def get_rate_AB(self): return self.reducer.get_rate_AB() / self.minima2rates.rate_norm def get_rate_BA(self): return self.reducer.get_rate_BA() / self.minima2rates.rate_norm def get_rate_AB_SS(self): return self.reducer.get_rate_AB_SS() / self.minima2rates.rate_norm def get_rate_BA_SS(self): return self.reducer.get_rate_BA_SS() / self.minima2rates.rate_norm def get_committors(self): committors = self.reducer.get_committors() return committors
def compare_linalg(self, A, B, nnodes=20, nedges=20): from pele.rates._rates_linalg import TwoStateRates maker = _MakeRandomGraph(nnodes=20, nedges=20, node_set=A + B) maker.run() reducer = NGT(maker.rates, A, B) reducer.compute_rates_and_committors() committors = reducer.get_committors() la = TwoStateRates(maker.rates, A, B) # la.compute_rates() la.compute_committors() qla = la.committor_dict for n, qla in la.committor_dict.items(): self.assertAlmostEqual(qla, committors[n], 7)
def compare_linalg(self, A, B, nnodes=20, nedges=20): from pele.rates._rates_linalg import TwoStateRates maker = _MakeRandomGraph(nnodes=20, nedges=20, node_set=A+B) maker.run() reducer = NGT(maker.rates, A, B) reducer.compute_rates_and_committors() committors = reducer.get_committors() la = TwoStateRates(maker.rates, A, B) # la.compute_rates() la.compute_committors() qla = la.committor_dict for n, qla in la.committor_dict.iteritems(): self.assertAlmostEqual(qla, committors[n], 7)
def _test_rate(self, A, B): reducer = NGT(self.rates, A, B, debug=False) reducer.compute_rates() kAB = reducer.get_rate_AB() kBA = reducer.get_rate_BA() self.assertAlmostEqual(kAB, self.true_kAB, 7) self.assertAlmostEqual(kBA, self.true_kBA, 7) rAB_SS = reducer.get_rate_AB_SS() rBA_SS = reducer.get_rate_BA_SS() self.assertAlmostEqual(rAB_SS, self.true_kAB_SS, 7) self.assertAlmostEqual(rBA_SS, self.true_kBA_SS, 7)
def _test_rate(self, i, j): reducer = NGT(self.rates, [i], [j], debug=False) reducer.compute_rates() rAB = reducer.get_rate_AB() rBA = reducer.get_rate_BA() self.assertAlmostEqual(rAB, self.final_rate, 7) self.assertAlmostEqual(rBA, self.final_rate, 7) rAB_SS = reducer.get_rate_AB_SS() rBA_SS = reducer.get_rate_BA_SS() self.assertAlmostEqual(rAB_SS, self.final_rate_SS, 7) self.assertAlmostEqual(rBA_SS, self.final_rate_SS, 7)
def do_check(self, A, B, nnodes=20, nedges=20): maker = _MakeRandomGraph(nnodes=20, nedges=20, node_set=A + B) rates = maker.make_rates() reducer = TwoStateRates(rates, A, B) reducer.compute_rates() reducer.compute_committors() from pele.rates._ngt_cpp import NGT ngt = NGT(rates, A, B) ngt.compute_rates() self.assertAlmostEqual(reducer.get_rate_AB(), ngt.get_rate_AB(), 7) self.assertAlmostEqual(reducer.get_rate_AB_SS(), ngt.get_rate_AB_SS(), 7)