RDF of mixtures

155 views
Skip to first unread message

Seth Martin

unread,
Nov 18, 2019, 12:59:50 PM11/18/19
to freud-users
Hey folks,

I just started trying freud, and I'm having trouble figuring out how to calculate RDF's in mixtures. I saw an old post that discussed this, but there seem to have been major changes since then. How do I select subsets of points (say by particle type) to compute rdf's of two different species?

Thanks for your help.

Seth Martin

vramasub

unread,
Nov 18, 2019, 1:17:26 PM11/18/19
to freud-users
Hi Seth,
What simulation software did you use, and what output file format is the trajectory in? freud doesn't provide any utilities for manipulating trajectories, it assumes that you have other ways of doing that. We recommend that you use a different package to perform the import and filtering of data. For example, if you're dumping a DCD file, MDAnalysis has readers capable of reading the file and provides a trajectory object you can use to subset with. If you're using HOOMD with GSD, then the gsd python package can be used directly to load the file. Once you subset, you would just use freud to compute separate RDFs for each type.

Hope that helps! Feel free to reach out if you need some more guidance on this.
Vyas

Bradley Dice

unread,
Nov 18, 2019, 1:23:57 PM11/18/19
to freud-users
Seth,

Also, here's a code snippet demonstrating how to work with the subsets of positions corresponding to each type. As Vyas mentioned, you'll need to use another trajectory reading tool to actually get these subsets of positions by type, since freud doesn't handle types.

import freud
import matplotlib
import matplotlib.pyplot as plt
matplotlib.use('agg')

# Create two arrays, representing the positions of type A and type B
box, points_A = freud.data.make_random_system(box_size=5, num_points=10000)
box, points_B = freud.data.make_random_system(box_size=5, num_points=10000)

rdf = freud.density.RDF(bins=50, r_max=2)

# Use one set of points to construct the system, and another set of points
# as the "query_points"
rdf.compute((box, points_A), query_points=points_B)

plt.figure()
rdf.plot(ax=plt.gca())
plt.savefig('rdf_mixture.png')

I have attached this script and its image output.

Best,
Bradley
rdf_mixture.png
rdf_mixture.py

jude vishnu

unread,
Feb 7, 2021, 2:18:01 PM2/7/21
to freud-users
Is this code snippet calculating the g(r)_BB of the system? Or is it calculating g(r)_AB? Could you please explain how the query_points works here?

Regards,
Jude Ann Vishnu
Reply all
Reply to author
Forward
0 new messages