-
Notifications
You must be signed in to change notification settings - Fork 9
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Map forces onto beads #80
base: main
Are you sure you want to change the base?
Conversation
for more information, see https://pre-commit.ci
for more information, see https://pre-commit.ci
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Congrats on your first pull request! Here's to many more.
@StephMcCallum here are some hints to for when you're working on this at the workshop.
|
Hi @StephMcCallum, Once you load a trajectory and iterate through the frames, you can check what kind of stuff is logged for each frame with: print(frame.log.keys()) For example, for a gsd file that I'm currently looking at right now, the result looks like this:
The key names are a bit weird but they have all the info that you need. As you can see the per particle forces are stored based on the force type i.e. LJ pair forces, Harmonic bond forces, Harmonic angle forces , etc and their key name starts with For example, I have a gsd file that I will share with you that contains 300 PPS monomers (each monomer has 7 atoms, therefore 2100 total particles) and the number of frames in this gsd file is 101. If you want to access the forces generated from the Lennard-Jones interactions for each particle in each frame of this trajectory, you can do something like this: import numpy as np
traj_lj_forces = [] #initiate an empty list to store all frame forces
for frame in traj:
lj_forces = frame.log['particles/md/pair/LJ/forces']
traj_lj_forces.append(lj_forces) #for each frame, append particle forces to the list
traj_lj_forces = np.asarray(traj_lj_forces) #convert the list to a numpy array, so that array operations could be done easily
print(traj_lj_forces.shape) The bond forces: I hope this makes it more clear. please let me know if you have any questions :) |
for more information, see https://pre-commit.ci
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the additons so far look good. Now, you'll have to add the coarse-grained velocities to the new gsd frame that GRiTS is making.
You can see what is done for other properties around lines 780:
new_snap.particles.N = len(typeid)
new_snap.particles.position = position
new_snap.particles.image = images
new_snap.particles.typeid = typeid.astype(int)
new_snap.particles.types = types
new_snap.particles.mass = mass
So, you can define the new_snap.particles.velocity
property with the velocity
list being populated.
…ng the forces to gsd log file.
Check out this pull request on See visual diffs & provide feedback on Jupyter Notebooks. Powered by ReviewNB |
for more information, see https://pre-commit.ci
…mporary fix to remove third dimension of array created from reduce function.
for more information, see https://pre-commit.ci
Adding comments to start project