Exemplo n.º 1
0
    def one_step(self, q_list0, p_list0, l_list):

        # update p0 -> p1
        p_input0 = self.force_function.prepare_p_input(q_list0, p_list0,
                                                       l_list)
        q_input0 = self.force_function.prepare_q_input(0, q_list0, p_list0,
                                                       l_list)
        p_input_list = [p_input0]
        q_input_list = [q_input0]
        p_list1 = p_list0 + self.force_function.eval(q_input_list,
                                                     p_input_list)

        # update q0 -> q1
        p_input1 = self.force_function.prepare_p_input(
            q_list0, p_list1,
            l_list)  ##### note, use q_list0 instead of q_list1
        p_input_list.append(p_input1)
        q_list1 = q_list0 + self.force_function.eval(q_input_list,
                                                     p_input_list)
        #q_list1.retain_grad()
        q_list1 = pbc(q_list1, l_list)

        # update p1 -> p2
        q_input1 = self.force_function.prepare_q_input(1, q_list1, p_list1,
                                                       l_list)
        q_input_list.append(q_input1)
        p_list2 = p_list1 + self.force_function.eval(q_input_list,
                                                     p_input_list)

        # update q1 -> q2
        p_input2 = self.force_function.prepare_p_input(
            q_list1, p_list2,
            l_list)  ##### note, use q_list1 instead of q_list2
        p_input_list.append(p_input2)
        q_list2 = q_list1 + self.force_function.eval(q_input_list,
                                                     p_input_list)
        #q_list2.retain_grad()
        q_list2 = pbc(q_list2, l_list)

        # update p2 -> p3
        q_input2 = self.force_function.prepare_q_input(2, q_list2, p_list2,
                                                       l_list)
        q_input_list.append(q_input2)
        p_list3 = p_list2 + self.force_function.eval(q_input_list,
                                                     p_input_list)

        # update q2 -> q3
        p_input3 = self.force_function.prepare_p_input(
            q_list2, p_list3,
            l_list)  ##### note, use q_list2 instead of q_list3
        p_input_list.append(p_input3)
        q_list3 = q_list2 + self.force_function.eval(q_input_list,
                                                     p_input_list)
        #q_list3.retain_grad()
        q_list3 = pbc(q_list3, l_list)

        assert_nan(p_list3)
        assert_nan(q_list3)
        return q_list3, p_list3, l_list
 def one_step(self,q_list,p_list,l_list,tau):
     #f1 = self.force_function.eval1(q_list,p_list,l_list,tau)
     p_list_2 = p_list + 0.5*tau*self.force_function.eval1(q_list,p_list,l_list,tau)
     q_list_2 = q_list + tau*p_list_2
     q_list_2.retain_grad()
     q_list_new = pbc(q_list_2,l_list)
     p_list_new = p_list_2 + 0.5*tau*self.force_function.eval2(q_list_new,p_list_2,l_list,tau)
     #f2 = self.force_function.eval2(q_list_new,p_list_2,l_list,tau)
     assert_nan(p_list_new)
     assert_nan(q_list_new)
     return q_list_new,p_list_new,l_list
    def one_step(self,q_list,p_list,l_list,tau):

        p_list_1 = p_list + 0.5*tau*self.force_function.eval1(q_list,p_list,l_list,tau)

        q_list_1 = q_list + 0.5*tau*self.momentum_function.eval1(q_list,p_list_1,l_list,tau)
        q_list_1.retain_grad()
        q_list_1 = pbc(q_list_1,l_list)

        q_list_2 = q_list_1 + 0.5*tau*self.momentum_function.eval2(q_list_1,p_list_1,l_list,tau)
        q_list_2.retain_grad()
        q_list_2 = pbc(q_list_2,l_list)

        p_list_2 = p_list_1 + 0.5*tau*self.force_function.eval2(q_list_2,p_list_1,l_list,tau)

        assert_nan(p_list_2)
        assert_nan(q_list_2)
        return q_list_2,p_list_2,l_list
    def one_step(self, q_list0, p_list0, l_list):

        p_input0 = self.force_function.prepare_p_input(q_list0, p_list0,
                                                       l_list)
        q_input0 = self.force_function.prepare_q_input(0, q_list0, p_list0,
                                                       l_list)

        p_input_list = [p_input0]
        q_input_list = [q_input0]

        p_list_pre = p_list0
        q_list_pre = q_list0

        for s in range(velocity_verletx.neval):

            p_list_cur = p_list_pre + self.force_function.eval(
                q_input_list, p_input_list)
            p_input_next = self.force_function.prepare_p_input(
                q_list_pre, p_list_cur, l_list)
            p_input_list.append(p_input_next)

            tau = self.force_function.get_tau(2 * s + 1)
            q_list_cur = q_list_pre + tau * p_list_cur + self.force_function.eval(
                q_input_list, p_input_list)
            #q_list_cur = q_list_pre + self.force_function.eval(q_input_list,p_input_list)
            q_list_cur = pbc(q_list_cur, l_list)
            net_idx = s
            q_input_next = self.force_function.prepare_q_input(
                net_idx, q_list_cur, p_list_cur, l_list)
            q_input_list.append(q_input_next)
            p_list_pre = p_list_cur
            q_list_pre = q_list_cur

        assert_nan(p_list_cur)
        assert_nan(q_list_cur)
        return q_list_cur, p_list_cur, l_list