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

Add utilities so that freud.diffraction.Diffractometer can be used like bitbucket diffractometer code #8

Merged
merged 9 commits into from
Jun 16, 2021
4 changes: 2 additions & 2 deletions cmeutils/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from . import gsd_utils
from . import gsd_utils, structure
from .__version__ import __version__

__all__ = ["__version__", "gsd_utils"]
__all__ = ["__version__", "gsd_utils", "structure"]
27 changes: 26 additions & 1 deletion cmeutils/structure.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,33 @@
from cmeutils import gsd_utils
import freud
import gsd
import gsd.hoomd
import numpy as np
from rowan import vector_vector_rotation

from cmeutils import gsd_utils


def get_quaternions(n_views = 20):
"""Get the quaternions for the specified number of views."""
jennyfothergill marked this conversation as resolved.
Show resolved Hide resolved
# Calculate points for even distribution on a sphere
ga = np.pi * (3 - 5**0.5)
theta = ga * np.arange(n_views-3)
z = np.linspace(1 - 1/(n_views-3), 1/(n_views-3), n_views-3)
radius = np.sqrt(1 - z * z)
points = np.zeros((n_views, 3))
points[:-3,0] = radius * np.cos(theta)
points[:-3,1] = radius * np.sin(theta)
points[:-3,2] = z

# face on
points[-3] = np.array([0, 0, 1])
# edge on
points[-2] = np.array([0, 1, 1])
# corner on
points[-1] = np.array([1, 1, 1])

unit_z = np.array([0, 0, 1])
return [vector_vector_rotation(i, unit_z) for i in points]


def gsd_rdf(
Expand Down
1 change: 1 addition & 0 deletions environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,4 @@ dependencies:
- python=3.7
jennyfothergill marked this conversation as resolved.
Show resolved Hide resolved
- pytest
- pytest-cov
- rowan