def test_solve_intermittent(self, u, hydrogens, oxygens, nitrogens):
        hbond = HBAC(
            u,
            hydrogens=hydrogens,
            acceptors=oxygens,
            donors=nitrogens,
            bond_type='intermittent',
            sample_time=0.06,
        )

        def actual_function_int(t):
            A1 = 0.33
            A2 = 0.33
            A3 = 0.34
            tau1 = 5
            tau2 = 1
            tau3 = 0.1
            return A1 * np.exp(-t / tau1) + A2 * np.exp(
                -t / tau2) + A3 * np.exp(-t / tau3)

        hbond.solution['time'] = time = np.arange(0, 6.0, 0.01)
        hbond.solution['results'] = actual_function_int(time)

        hbond.solve()

        assert_almost_equal(
            hbond.solution['fit'],
            np.array([0.33, 0.33, 5, 1, 0.1]),
        )
    def test_solve_continuous(self, u, hydrogens, oxygens, nitrogens):
        hbond = HBAC(
            u,
            hydrogens=hydrogens,
            acceptors=oxygens,
            donors=nitrogens,
            bond_type='continuous',
            sample_time=0.06,
        )

        def actual_function_cont(t):
            A1 = 0.75
            A2 = 0.25
            tau1 = 0.5
            tau2 = 0.1
            return A1 * np.exp(-t / tau1) + A2 * np.exp(-t / tau2)

        hbond.solution['time'] = time = np.arange(0, 0.06, 0.001)
        hbond.solution['results'] = actual_function_cont(time)

        hbond.solve()

        assert_almost_equal(
            hbond.solution['fit'],
            np.array([0.75, 0.5, 0.1]),
        )
    def test_solve_intermittent(self):
        hbond = HBAC(self.u,
                     hydrogens=self.H,
                     acceptors=self.O,
                     donors=self.N,
                     bond_type='intermittent',
                     sample_time=0.06,
        )

        def actual_function_int(t):
            A1 = 0.33
            A2 = 0.33
            A3 = 0.34
            tau1 = 5
            tau2 = 1
            tau3 = 0.1
            return A1 * np.exp(-t/tau1) + A2 * np.exp(-t/tau2) + A3 * np.exp(-t/tau3)
        hbond.solution['time'] = time = np.arange(0, 6.0, 0.01)
        hbond.solution['results'] = actual_function_int(time)

        hbond.solve()

        assert_array_almost_equal(
            hbond.solution['fit'],
            np.array([0.33, 0.33, 5, 1, 0.1]),
        )
 def test_solve_before_run_VE(self, u, hydrogens, oxygens, nitrogens):
     hbond = HBAC(u,
                  hydrogens=hydrogens,
                  acceptors=oxygens,
                  donors=nitrogens,
                  bond_type='continuous',
                  sample_time=0.06,
     )
     with pytest.raises(ValueError):
         hbond.solve()
 def test_solve_before_run_VE(self, u, hydrogens, oxygens, nitrogens):
     hbond = HBAC(
         u,
         hydrogens=hydrogens,
         acceptors=oxygens,
         donors=nitrogens,
         bond_type='continuous',
         sample_time=0.06,
     )
     with pytest.raises(ValueError):
         hbond.solve()
    def test_solve_continuous(self):
        hbond = HBAC(self.u,
                     hydrogens=self.H,
                     acceptors=self.O,
                     donors=self.N,
                     bond_type='continuous',
                     sample_time=0.06,
        )

        def actual_function_cont(t):
            A1 = 0.75
            A2 = 0.25
            tau1 = 0.5
            tau2 = 0.1
            return A1 * np.exp(-t/tau1) + A2 * np.exp(-t/tau2)
        hbond.solution['time'] = time = np.arange(0, 0.06, 0.001)
        hbond.solution['results'] = actual_function_cont(time)

        hbond.solve()

        assert_array_almost_equal(
            hbond.solution['fit'],
            np.array([0.75, 0.5, 0.1]),
        )
Пример #7
0
    'O10' : u.select_atoms('bynum 18')
}

oxygens = sum(list(oxygen_dict.values()))
hydrogens = sum(list(hydrogen_dict.values()))
nitrogens = sum(list(nitrogen_dict.values()))
""

"Run HBond Autocorrelation"
hb_ac = HydrogenBondAutoCorrel(u, 
                               acceptors = oxygens,
                               hydrogens = hydrogens,
                               donors = nitrogens,
                               bond_type='continuous')
hb_ac.run()
hb_ac.solve()
tau = hb_ac.solution['tau']
time = hb_ac.solution['time']
results = hb_ac.solution['results']
estimate = hb_ac.solution['estimate']

"Max Range"
factor = 0.5
max_d = int(data[:,0].size * factor)
max_h = int(time.size * factor)
max_r = int(len(u.trajectory) * factor)

"Plot Results and Find Correlation"
fig, ax1 = plt.subplots()
color = 'red'
ax1.set_xlabel('Pull Distance ($\AA$)')