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

Fix k-value/k-vector units for non-cubic systems #793

Draft
wants to merge 12 commits into
base: main
Choose a base branch
from

Conversation

andkerr
Copy link
Contributor

@andkerr andkerr commented Jun 15, 2021

Description

This PR continues work started in #777 and others to ensure Freud's diffraction module computes the correct range of k-values and k-vectors for various grid_size, output_size, zoom,view_orientation, and box shapes, and that diffraction peaks are positioned such that their k-vectors satisfy the following relationship for lattice vectors R (from Wikipedia):

image

Previous commits fixed diffraction results for simple cubic systems. Ideally, future commits will ensure that freud.diffraction.compute() generates correct k-value, k-vectors and diffraction peaks for:

  • cubic boxes that have been extended in the direction parallel to the view axis (i.e. producing the same pattern as the corresponding cubic box)
  • orthorhombic boxes whose vectors all have different magnitudes
  • boxes rotated such that none of their face normal vectors are parallel to the view axis
  • boxes with 2+ face normal vectors projecting equally onto the view axis

Some of these will likely involve changing how the compute method's box_matrix_scale_factor is calculated. It is currently assigned to np.max(system.box.to_matrix()), which produces incorrect diffraction patterns in most cases.

Motivation and Context

Resolves: #750

How Has This Been Tested?

N/A. Commits to this PR will include unit tests to verify that diffraction results are correct.

Screenshots

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds or improves functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Documentation improvement (updates to user guides, docstrings, or developer docs)

Checklist:

  • I have read the CONTRIBUTING document.
  • My code follows the code style of this project.
  • I have updated the documentation (if relevant).
  • I have added tests that cover my changes (if relevant).
  • All new and existing tests passed.
  • I have updated the credits.
  • I have updated the Changelog.

@codecov
Copy link

codecov bot commented Jun 15, 2021

Codecov Report

Merging #793 (8e3adbc) into master (a0fc869) will not change coverage.
The diff coverage is n/a.

❗ Current head 8e3adbc differs from pull request most recent head 12e016f. Consider uploading reports for the commit 12e016f to get more accurate results
Impacted file tree graph

@@           Coverage Diff           @@
##           master     #793   +/-   ##
=======================================
  Coverage   55.57%   55.57%           
=======================================
  Files          16       16           
  Lines        2438     2438           
  Branches       33       33           
=======================================
  Hits         1355     1355           
  Misses       1070     1070           
  Partials       13       13           
Impacted Files Coverage Δ
freud/diffraction.pyx 71.64% <ø> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update a0fc869...12e016f. Read the comment docs.

andkerr and others added 7 commits June 15, 2021 18:56
This commit includes a rough / hacky change to diffraction.pyx that makes the long z-dimesion test pass by selecting  from only the box vectors in the x and y directions. This will likely be changed in the process of making the other new tests pass.
@bdice bdice mentioned this pull request Jun 24, 2021
11 tasks
@tommy-waltmann tommy-waltmann mentioned this pull request Apr 12, 2022
11 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Diffraction pattern depends on shape of simulation box
2 participants