コード例 #1
0
    def setUp(self):
        p = np.zeros(10)
        q = np.zeros(10)
        p[0:-1] = 0.5
        q[1:] = 0.5
        p[4] = 0.01
        q[6] = 0.1

        self.A = [0, 1]
        self.B = [8, 9]
        self.a = 1
        self.b = 8

        self.bdc = BirthDeathChain(q, p)
        T_dense = self.bdc.transition_matrix()
        T_sparse = csr_matrix(T_dense)
        self.T = T_sparse

        self.mu = self.bdc.stationary_distribution()
        self.qminus = self.bdc.committor_backward(self.a, self.b)
        self.qplus = self.bdc.committor_forward(self.a, self.b)

        # present results
        self.fluxn = flux.flux_matrix(self.T,
                                      self.mu,
                                      self.qminus,
                                      self.qplus,
                                      netflux=False)
        self.netfluxn = flux.flux_matrix(self.T,
                                         self.mu,
                                         self.qminus,
                                         self.qplus,
                                         netflux=True)
        self.totalfluxn = flux.total_flux(self.netfluxn, self.A)
        self.raten = flux.rate(self.totalfluxn, self.mu, self.qminus)
コード例 #2
0
    def test_with_almost_converged_stat_dist(self):
        """ test for #106 """
        from msmtools.analysis import committor, is_reversible
        from msmtools.flux import tpt, flux_matrix, to_netflux, ReactiveFlux

        T = np.array([[
            0.2576419223095193, 0.2254214623509954, 0.248270708174756,
            0.2686659071647294
        ],
                      [
                          0.2233847186210225, 0.2130434781715344,
                          0.2793477268264001, 0.284224076381043
                      ],
                      [
                          0.2118717275169231, 0.2405661227681972,
                          0.2943396213976011, 0.2532225283172787
                      ],
                      [
                          0.2328617711043517, 0.2485926610067547,
                          0.2571819311236834, 0.2613636367652102
                      ]])
        mu = np.array([
            0.2306979668517676, 0.2328013892993006, 0.2703312416016573,
            0.2661694022472743
        ])
        assert is_reversible(T)
        np.testing.assert_allclose(mu.dot(T), mu)
        np.testing.assert_equal(mu.dot(T), T.T.dot(mu))
        A = [0]
        B = [1]

        # forward committor
        qplus = committor(T, A, B, forward=True, mu=mu)
        # backward committor
        if is_reversible(T, mu=mu):
            qminus = 1.0 - qplus
        else:
            qminus = committor(T, A, B, forward=False, mu=mu)

        tpt_obj = tpt(T, A, B)
        tpt_obj.major_flux(1.0)
        # gross flux
        grossflux = flux_matrix(T, mu, qminus, qplus, netflux=False)
        # net flux
        netflux = to_netflux(grossflux)
        F = ReactiveFlux(A,
                         B,
                         netflux,
                         mu=mu,
                         qminus=qminus,
                         qplus=qplus,
                         gross_flux=grossflux)
        F.pathways(1.0)