Skip to content
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

Open
wants to merge 13 commits into
base: main
Choose a base branch
from
Open
Changes from 7 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions grits/coarsegrain.py
Copy link
Member

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.

Original file line number Diff line number Diff line change
Expand Up @@ -727,6 +727,10 @@ def save(self, cg_gsdfile, start=0, stop=None, stride=1):
new_snap = gsd.hoomd.Frame()
position = []
mass = []
# make an empty list for forces here
net_force = []
# make an empty list for velocity
velocity = []
orientation = [] if self.aniso_beads else None
f_box = freud.Box.from_box(s.configuration.box)
unwrap_pos = f_box.unwrap(
Expand All @@ -738,6 +742,13 @@ def save(self, cg_gsdfile, start=0, stop=None, stride=1):
mass += [
sum(s.particles.mass[x]) * self.mass_scale for x in inds
]

# do the force calculation here
# do the velocity calculation here
velocity += [
np.mean(s.particles.velocity[x], axis=0) for x in inds
]

if self.aniso_beads:
for x in inds:
masses = s.particles.mass[x] * self.mass_scale
Expand Down
Loading