Commit c700a0a7 authored by Stelios Karozis's avatar Stelios Karozis

Begin domain decomposition function

parent 5bdfa21b
......@@ -6,6 +6,17 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## [Unreleased]
## [0.0.2] - 2020-05-04
### Added
- debug trr frames export
- initial code fro domain decomposition function
### Changed
- None
### Removed
- None
## [0.0.1] - 2020-04-27
### Added
- add gitignore
......
......@@ -5,5 +5,6 @@ import tooba_f as tbf
#print(tbf.angle_between3D(P1,P2))
#tbf.last_fr_export(trajfile='traj.trr')
tbf.read_gro('initial.gro')
\ No newline at end of file
data_all=tbf.fr_export(trajfile='traj.trr',num_frames=10)
#system,data_num,box_size,res_num,res_type,atom_type,atom_num,rest_dt = tbf.read_gro('initial.gro')
tbf.domain_decomposition(data=data_all,dx=-1,dy=-1,dz=-1)
\ No newline at end of file
......@@ -72,6 +72,11 @@ def plot_surf(data, normal, c):
plt.show()
def count_frames(trajfile='traj.trr'):
"""
Count total frames of .trr file
parameters: trajfile = [.trr]
"""
cnt_fr=0
with open(trajfile, 'rb') as inputfile:
for i in range(1000):
......@@ -85,20 +90,45 @@ def count_frames(trajfile='traj.trr'):
return cnt_fr
def fr_export(trajfile='traj.trr', num_frames=1):
"""
Export frames from gromacs .trr file.
parameters: trajfile = [.trr]
num_frames = [number of frames to keep
counting from the end of file]
"""
cnt_fr=count_frames(trajfile)
data_all={}
with open(trajfile, 'rb') as inputfile:
for i in range(cnt_fr-num_frames):
header = read_trr_header(inputfile)
#print('Step: {step}, time: {time}'.format(**header))
skip_trr_data(inputfile, header)
for i in range(cnt_fr-num_frames,cnt_fr):
header = read_trr_header(inputfile)
print('Step: {step}, time: {time}'.format(**header))
data = read_trr_data(inputfile, header)
print(data.keys())
print(data['box'])
print(data['x'][0])
#print(data.keys())
#print(data['box'])
#print(data['x'][0])
step='{step}'.format(**header)
data_all[step]=data
return data_all
def read_gro(gro):
"""
Read .gro file and exports
1. system name
2. data number
3. box size
4. residue number
5. residue type
6. atom type
7. atom number
8. free format data (x,y,z,v,u,w)
parameters: gro = [.gro]
"""
cnt=0
data_num=0
res_num = []
......@@ -124,3 +154,24 @@ def read_gro(gro):
box_size=line[:50]
#print(system,data_num,box_size)
return system,data_num,box_size,res_num,res_type,atom_type,atom_num,rest_dt
def domain_decomposition(data,dx,dy,dz):
"""
Identify residues that rely inside a subdomain
of a rectangular box
"""
print('xs ys zs x y z')
for step in data.keys():
#print(data[step]['box'])
#data[step]['box'][row][element]
xs=data[step]['box'][0][0]
ys=data[step]['box'][1][1]
zs=data[step]['box'][2][2]
#data[step]['x'][atom_num][x(0),y(1),z(3)]
x=data[step]['x'][0][0]
y=data[step]['x'][0][1]
z=data[step]['x'][0][2]
print(xs,ys,zs, x, y, z)
#Todo: identify points inside box that belong to same residue
#return
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment