def getTranslation(file, frame1_no, frame2_no, part1='ring', part2='track', type='absolute', method='trans_com', part1_atom_list=[], part2_atom_list=[], unit='m'): assert frame2_no >= frame1_no, 'Invalid Frame Numbers' frame1_cords = io.readFileMd(file, frame1_no, frame_no_pos=config.frame_no_pos) frame2_cords = io.readFileMd(file, frame2_no, frame_no_pos=config.frame_no_pos) return _getTranslation(frame1_cords, frame2_cords, part1=part1, part2=part2, type=type, method=method, part1_atom_list=part1_atom_list, part2_atom_list=part2_atom_list, unit=unit)
def getNetRotation(file,start_frame_no,end_frame_no,step_size=1,part1='ring',part2='track',type='absolute',method='rot_atomic_r_t_2',part1_atom_list=[],part2_atom_list=[]): net_rotation=0 data={'frame_no':[],'rotation':[]} assert end_frame_no>=start_frame_no,'Invalid Frame Numbers' prev_frame_no=start_frame_no prev_frame_cords=io.readFileMd(file,prev_frame_no,frame_no_pos=config.frame_no_pos) for curr_frame_no in tqdm(range(start_frame_no+step_size,end_frame_no+1,step_size)): curr_frame_cords=io.readFileMd(file,curr_frame_no,frame_no_pos=config.frame_no_pos) rotation=_getRotation(prev_frame_cords,curr_frame_cords,part1=part1,part2=part2,type=type,method=method,part1_atom_list=part1_atom_list,part2_atom_list=part2_atom_list) net_rotation+=rotation prev_frame_no=curr_frame_no prev_frame_cords=curr_frame_cords.copy() data['frame_no'].append(curr_frame_no) data['rotation'].append(rotation) return (net_rotation,data)
def getAvgTKE(file, start_frame_no, end_frame_no, step_size=1, part1='ring', part2='track', type='absolute', method='energy_trans_com', part1_atom_list=[], part2_atom_list=[]): avg_TKE = 0 net_TKE = 0 data = {'frame_no': [], 'TKE': []} assert end_frame_no >= start_frame_no, 'Invalid Frame Numbers' prev_frame_no = start_frame_no prev_frame_cords = io.readFileMd(file, prev_frame_no, frame_no_pos=config.frame_no_pos) for curr_frame_no in tqdm( range(start_frame_no + step_size, end_frame_no + 1, step_size)): curr_frame_cords = io.readFileMd(file, curr_frame_no, frame_no_pos=config.frame_no_pos) TKE = _getTKE(prev_frame_cords, curr_frame_cords, part1=part1, part2=part2, type=type, method=method, part1_atom_list=part1_atom_list, part2_atom_list=part2_atom_list) net_TKE += TKE prev_frame_no = curr_frame_no prev_frame_cords = curr_frame_cords.copy() data['frame_no'].append(curr_frame_no) data['TKE'].append(TKE) avg_TKE = net_TKE / len(range(start_frame_no, end_frame_no + 1, step_size)) return (avg_TKE, data)
def getRKE(file, frame1_no, frame2_no, part1='ring', part2='track', type='absolute', method='energy_rot_atomic_r_t', part1_atom_list=[], part2_atom_list=[]): assert frame2_no >= frame1_no, 'Invalid Frame Numbers' frame1_cords = io.readFileMd(file, frame1_no, frame_no_pos=config.frame_no_pos) frame2_cords = io.readFileMd(file, frame2_no, frame_no_pos=config.frame_no_pos) return _getRKE(frame1_cords, frame2_cords, part1=part1, part2=part2, type=type, method=method, part1_atom_list=part1_atom_list, part2_atom_list=part2_atom_list)
def extractMolecule(file_path,atom_no=0): if isMd(file_path): with open(file_path,'r') as file: df_cords=io.readFileMd(file,config.start_frame_no,frame_no_pos=config.frame_no_pos) else: df_cords=io.readFile(file_path) io.writeFile('ring_track_frame.tmp.xyz',df_cords) subprocess.run(['babel','ring_track_frame.tmp.xyz','ring_track_frame.tmp.mol']) G=io.readFile('ring_track_frame.tmp.mol',info='graph') subprocess.run(['rm','ring_track_frame.tmp.xyz','ring_track_frame.tmp.mol']) cc_list=list(nx.connected_component_subgraphs(G)) print(f'number of molecules found is {len(cc_list)}') for cc in cc_list: if atom_no in list(cc.nodes): return sorted(list(cc.nodes))