Open hainm opened 9 years ago
Status: implemented
low priority
Frame(int n_atoms, double* ptr)
Frame::Frame(int natomIn, double* ptr) :
natom_(natomIn),
maxnatom_(natomIn),
ncoord_(natomIn*3),
T_(0.0),
time_(0.0),
X_(0),
V_(0),
Mass_(natomIn, 1.0)
{
if (ncoord_ > 0)
X_ = ptr;
}
Motivation : We can create contigous memory block for numpy array. Whenever creating a Frame for cpptraj's action, we just make a "view" without copying data. This saves a lot of memory.
Dan's comment
This could be done, but then Frame needs to be re-worked so it doesn't try to free memory, and any routines that make use of this need to be responsible for freeing memory.
Hai: may be give the ownership to numpy.
mdtraj
?In [20]: md.baker_hubbard(traj)
Out[20]:
array([[ 13, 14, 9],
[ 47, 48, 50],
[167, 168, 170]])
But I am not sure where we need those indices. Currently cpptraj us 0 and 1 to say 'no', 'yes' for the existence of hbond for each frame. This is what I am expecting.
In [23]: pt.search_hbonds(traj)
Out[23]:
<pytraj.DatasetList with 10 datasets>
total_solute_solute
[5 5 5 4 4 5 6 5 5 4]
LYS12_O-SER1_N-H3
[1 1 1 1 0 1 0 1 0 1]
LYS8_O-GLU5_N-H
[1 1 0 1 1 0 1 1 1 1]
...
TRP2_O-THR3_OG1-HG1
[0 0 0 0 1 1 1 0 0 0]
THR3_O-THR10_N-H
[0 0 0 0 0 1 1 1 1 0]
But it's also great if we can take the atom indices and inspect distances, angles later (example below)?
In [31]: traj = pt.iterload("./data/tz2.nc", "./data/tz2.parm7")
In [32]: pt.angle(traj, indices)
Out[32]:
array([[ 128.26687651, 140.4319339 , 130.87185144, ..., 98.56379937,
107.85608806, 89.34456598],
[ 17.55336985, 118.77424219, 27.46849459, ..., 7.05500858,
88.28587392, 81.54357284],
[ 52.47597634, 49.17080732, 45.59776004, ..., 47.63029318,
71.20751101, 80.74681557]])
cpptraj
for clustering?
some of ideas might be better for pytraj/cpptraj api. (or might be not)
dump coordinates directly to
xyz
3d or 1d array without creating Frame object.Motivation:
pytraj
might use numpy Trajectory for in-memory trajectory. In the current implementation, cpptraj need to read coords from disk to Frame, thenpytraj
make copy to numpy array.