Ejemplo n.º 1
0
run_name = 'run5'
data_path = os.getcwd()+'/data'
traj = md.load_trr(data_path+'/nvt-pr_'+run_name+'.trr', top = data_path+'/water-sol_'+run_name+'.gro')
print ('here is some info about the trajectory we are looking at:')
print traj
ws = WaterStats(traj,run_name)
cut_off = 0.5
frame_ind = 1

half_box = ws.traj.unitcell_lengths[0][0]/2.*10

inds = range(1001)[101:]
count = 33897
for frame_ind in inds:
    nbs = ws.find_nearest_nbs(cut_off,frame_ind,3)
    xyz_pos = ws.traj[frame_ind].xyz
    
    with open(os.getcwd()+'/output_data/tthd_pdb_1000.pdb','a') as f:
        for this_nb in nbs:
            
            r1 = xyz_pos[0,this_nb[0],:]*10
            r2 = xyz_pos[0,this_nb[1],:]*10
            r3 = xyz_pos[0,this_nb[2],:]*10
            r4 = xyz_pos[0,this_nb[3],:]*10
        
            dr = r1-r2
            for ii in range(3):
                if np.abs(dr[ii]) > half_box:
                    if r2[ii]<r1[ii]:
                        r2[ii] = r2[ii]+half_box*2.