def test_p2(): LC = nCB("5cb_traj/run.tpr","5cb_traj/traj_comp.xtc",5,trjconv=False) pv_ = ProbeVolume_Box("5cb_traj/run.tpr","5cb_traj/traj_comp.xtc",min_,max_) LC_tilde= nCB_PV("5cb_traj/run.tpr","5cb_traj/traj_comp.xtc",5,pv_,trjconv=False) p2_list = np.zeros((len(LC),)) p2tilde_list = np.zeros((len(LC),)) p2cos_list = np.zeros((len(LC),)) for i in range(len(LC)): p2_list[i] = LC.p2(i) p2tilde_list[i] = LC_tilde.p2tilde(i) p2cos_list[i] = LC.p2_cos(i,n) p2_ref = np.load("5cb_traj/p2_ref.npy") p2tilde_ref = np.load("5cb_traj/p2tilde_ref.npy") p2cos_ref = np.load("5cb_traj/p2cos_ref.npy") err1 = np.max(np.abs(p2_ref - p2_list)/np.abs(p2_ref)) err2 = np.max(np.abs(p2tilde_ref - p2tilde_list)/np.abs(p2tilde_ref)) err3 = np.max(np.abs(p2cos_ref - p2cos_list)/np.abs(p2cos_list)) assert(err1 < 1e-10) assert(err2 < 1e-10) assert(err3 < 1e-10)
def make_reference_cylinder(): # for Cylinder base = np.array([0, 0, 0]) h = 30 radius = 20 pv_cylinder = ProbeVolume_cylinder("5cb_traj/run.tpr", "5cb_traj/traj_comp.xtc", base, h, radius, pbc=True, dir_='z') LC = nCB("5cb_traj/run.tpr", "5cb_traj/traj_comp.xtc", 5, trjconv=False) natoms = LC.natoms nresidues = LC.Nresidues_ Ntilde_ref = np.zeros((len(LC), 1)) indicator_ref = np.zeros((len(LC), natoms * nresidues, 1)) hx_ref = np.zeros((len(LC), natoms * nresidues, 3)) for i in range(len(LC)): pos = LC.pos(i) indicator, hx = pv_cylinder.calculate_Indicator(pos, i) indicator_ref[i] = indicator hx_ref[i] = hx Ntilde_ref[i] = pv_cylinder.get_Ntilde() np.save("INDUS_test/indicator_cyl_ref.npy", indicator_ref) np.save("INDUS_test/hx_cyl_ref.npy", hx_ref) np.save("INDUS_test/Ntilde_cyl_ref.npy", Ntilde_ref)
def make_ref(): LC = nCB("5cb_traj/run.tpr","5cb_traj/traj_comp.xtc",4, trjconv=False) COM_mat = np.zeros((len(LC),LC.Nresidues_,3)) for t in range(len(LC)): COM_mat[t] = LC.COM(t) np.save("unittests_data/COM_ref.npy",COM_mat)
def test_COM(): LC = nCB("5cb_traj/run.tpr","5cb_traj/traj_comp.xtc",4, trjconv=False) COM_mat = np.zeros((len(LC),LC.Nresidues_,3)) for t in range(len(LC)): COM_mat[t] = LC.COM(t) COM_ref = np.load("unittests_data/COM_ref.npy") err = np.max(np.abs(COM_mat - COM_ref)) assert err < 1e-10
def make_reference(): LC = nCB("5cb_traj/run.tpr", "5cb_traj/traj_comp.xtc", 5, trjconv=False) director_ref = np.zeros((len(LC), 3)) OP_ref = np.zeros((len(LC), )) n = np.array([1, 0, 0]) dv0_ref = np.zeros((len(LC), LC.Nresidues_, 3)) for t in range(len(LC)): director_ref[t] = LC.director(t, MOI=False) OP_ref[t] = LC.v0(t, n) dv0_ref[t] = LC.dv0_dr(t, n) np.save("5cb_traj/director_ref.npy", director_ref) np.save("5cb_traj/OP_ref.npy", OP_ref) np.save("5cb_traj/dv0_ref.npy", dv0_ref)
def make_ref(): LC = nCB("5cb_traj/run.tpr","5cb_traj/traj_comp.xtc",5,trjconv=False) pv_ = ProbeVolume_Box("5cb_traj/run.tpr","5cb_traj/traj_comp.xtc",min_,max_) LC_tilde= nCB_PV("5cb_traj/run.tpr","5cb_traj/traj_comp.xtc",5,pv_,trjconv=False) p2_list = np.zeros((len(LC),)) p2tilde_list = np.zeros((len(LC),)) p2cos_list = np.zeros((len(LC),)) for i in range(len(LC)): p2_list[i] = LC.p2(i) p2tilde_list[i] = LC_tilde.p2tilde(i) p2cos_list[i] = LC.p2_cos(i,n) print("p2 at {} is {:.5f}".format(i, p2_list[i])) print("p2tilde at {} is {:.5f}".format(i, p2tilde_list[i])) print("p2cos at {} is {:.5f}".format(i, p2cos_list[i])) np.save("5cb_traj/p2_ref.npy",p2_list) np.save("5cb_traj/p2tilde_ref.npy",p2tilde_list) np.save("5cb_traj/p2cos_ref.npy",p2cos_list)
def test_director(): LC = nCB("5cb_traj/run.tpr", "5cb_traj/traj_comp.xtc", 5, trjconv=False) director = np.zeros((len(LC), 3)) OP = np.zeros((len(LC), )) n = np.array([1, 0, 0]) dv0 = np.zeros((len(LC), LC.Nresidues_, 3)) for t in range(len(LC)): director[t] = LC.director(t, MOI=False) OP[t] = LC.v0(t, n) dv0[t] = LC.dv0_dr(t, n) director_ref = np.load("5cb_traj/director_ref.npy") OP_ref = np.load("5cb_traj/OP_ref.npy") dv0_ref = np.load("5cb_traj/dv0_ref.npy") err1 = np.max(np.abs(director_ref - director) / np.abs(director_ref)) err2 = np.max(np.abs(OP_ref - OP) / np.abs(OP_ref)) err3 = np.max(np.abs(dv0_ref - dv0) / np.abs(dv0_ref)) assert (err1 < 1e-10) assert (err2 < 1e-10) assert (err3 < 1e-10)