The freud library provides users the ability to analyze molecular dynamics and Monte Carlo simulation trajectories for advanced metrics such as the radial distribution function and various order parameters. Its modules work with and return NumPy arrays, and are able to process both 2D and 3D data. Features in freud include computing the radial distribution function, local density, hexagonal order parameter and local bond order parameters, Voronoi tessellations, k-space quantities, and more.
When using freud to process data for publication, please use this citation.
If you have a question, please consider posting to the freud-users mailing list.
Official binaries of freud are available via conda through the glotzer channel.
To install freud, first download and install miniconda following
Then add the
glotzer channel and install freud:
$ conda config --add channels glotzer $ conda install freud
Use CMake to configure and make freud from source.
mkdir build cd build cmake ../ make -j20
By default, freud installs to the USER_SITE directory,
which is in
~/.local on Linux and in
~/Library on macOS.
USER_SITE is on the Python search path by default, so there is no need to modify
To run out of the build directory, add the build directory to your
bash export PYTHONPATH=`pwd`:$PYTHONPATH
For more detailed instructions, see the documentation.
The freud library makes use of submodules. CMake has been configured to automatically init and update submodules. If this does not work or you would like to do this yourself, please execute:
git submodule update --init
- Python >= 2.7 (3.5+ recommended)
- NumPy >= 1.7
- Boost (headers only)
- CMake >= 2.8.0 (to compile freud)
- C++ 11 capable compiler (tested with gcc >= 4.8.5, clang 3.5)
- Intel Threading Building Blocks
- Cython >= 0.23 (to compile your own _freud.cpp)
The freud library is called using Python scripts.
Here is a simple example.
import freud # create a freud compute object (rdf is the canonical example) rdf = freud.density.rdf(rmax=5, dr=0.1) # load in your data (freud does not provide a data reader) box_data = np.load("path/to/box_data.npy") pos_data = np.load("path/to/pos_data.npy") # create freud box box = freud.box.Box(Lx=box_data["Lx"], Ly=box_data["Ly"], is2D=True) # compute RDF rdf.compute(box, pos_data, pos_data) # get bin centers, rdf data r = rdf.getR() y = rdf.getRDF()
The documentation is available online at https://freud.readthedocs.io.
To build the documentation yourself, please install sphinx:
conda install sphinx
pip install sphinx
To view the full documentation run the following commands in the source directory:
# Linux cd doc make html xdg-open build/html/index.html # Mac cd doc make html open build/html/index.html
If you have latex and/or pdflatex, you may also build a pdf of the documentation:
# Linux cd doc make latexpdf xdg-open build/latex/freud.pdf # Mac cd doc make latexpdf open build/latex/freud.pdf
Run all unit tests with
nosetests . in the
To add a test, simply add a file to the
tests directory, and nosetests will automatically discover it.
Refer to this introduction to nose for help writing tests.
cd tests nosetests .