ur-whitelab / hoomd-tf

A plugin that allows the use of Tensorflow in Hoomd-Blue for GPU-accelerated ML+MD
https://hoomd-tf.readthedocs.io
MIT License
30 stars 8 forks source link

Generate mapped trajectories from Gromacs AA traj files #273

Closed geemi725 closed 3 years ago

geemi725 commented 3 years ago

Addresses issue #266

pep8speaks commented 3 years ago

Hello @geemi725! Thanks for updating this PR. We checked the lines you've touched for PEP 8 issues, and found:

There are currently no PEP 8 issues detected in this Pull Request. Cheers! :beers:

Comment last updated at 2021-02-18 03:25:23 UTC
geemi725 commented 3 years ago

@whitead instead of implementing this in utils.py shall I only make an example notebook?

whitead commented 3 years ago

@geemi725 think it's better in utils with a conditional import. Also, we have a few trajectories in our examples directory. Can you use one of those for purposes of this? Thanks!

geemi725 commented 3 years ago

@whitead I updated the example to read from the trajectory and, compute COMs using the HTF function as we discussed. Thoughts?

whitead commented 3 years ago

@geemi725 it looks much better. Can you remove the use of make_tensor_proto though? I think you want something like

    mapped_pos = htf.center_of_mass(tf.cast(positions[:,:3],dtype=tf.float64), 
                                                         tf.cast(cg_mapping,dtype=tf.float64), box_size)
    mdbox = u.dimensions

    #Let's generate snapshots of each frame and write to a GSD file 
    t.append(htf.create_frame(frame_num, CGnum, CGtypes, CGids, mapped_pos.numpy(), mdbox))
    frame_num += 1
geemi725 commented 3 years ago

@whitead I need mapped positions as a numpy array. So to use tf.make_ndarray don't I have to use make_tensor_proto?

I followed this https://www.tensorflow.org/api_docs/python/tf/make_ndarray

whitead commented 3 years ago

I believe just using t.numpy() will convert a tensor into a numpy array.

geemi725 commented 3 years ago

@whitead addressed your comment. @hgandhi2411 I think this is good for review now.

geemi725 commented 3 years ago

@hgandhi2411 addressed your comments. Thanks!!

hgandhi2411 commented 3 years ago

@geemi725 Everything looks good to me. I fixed some typos. Also, made hoomd context initialization on cpu since initializing on gpu kept giving me a runtime error.