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

[bugfix] Fixing issues with particles #2338

Merged
merged 8 commits into from
Oct 18, 2019
Merged

Conversation

jzuhone
Copy link
Contributor

@jzuhone jzuhone commented Sep 25, 2019

This is one of those PRs which basically led one down a rabbit hole, finding several issues along the way.

  1. The DiskSelector was computing selections incorrectly for SPH particles.
  2. The relative_particle_position and relative_particle_velocity fields were using modify_reference_frame to compute the relative fields. This takes a normal vector and then returns the relative coordinates in a rotated coordinate system, in which the new normal vector is the z-axis. However, the fields for particle positions in spherical and cylindrical coordinates (such as radius, etc.) were assuming the normal field parameter was the original one instead and using the relative fields, which gave incorrect results. I'm changing here the way the relative fields are computed, consistent with the way we handle relative fields from grid datasets, by only subtracting the center off. As far as I can tell, this only occurs in particle_fields.py.
  3. For some reason merges with master did not get the fixes from PR Reverse angular momentum orientation #2043 into the yt-4.0 branch, this adds them back in.

Open to suggestions about new tests.

PR Checklist

  • Code passes flake8 checker
  • Adds a test for any bugs fixed.

@matthewturk
Copy link
Member

matthewturk commented Sep 26, 2019 via email

@@ -1230,7 +1230,7 @@ cdef class DiskSelector(SelectorObject):
h = d = 0
for i in range(3):
temp = self.periodic_difference(pos[i], self.center[i], i)
h += pos[i] * self.norm_vec[i]
h += temp * self.norm_vec[i]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ouch, great catch.

@@ -568,7 +568,8 @@ def get_box_grids_below_level(
@cython.cdivision(True)
@cython.boundscheck(False)
@cython.wraparound(False)
def obtain_position_vector(data):
def obtain_position_vector(
data, field_names = ('x', 'y', 'z')):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should maybe add a note that this may result in an ambiguous access

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree with this.

@matthewturk
Copy link
Member

Some of the angular momentum stuff is included in #2172 but this is a set of great catches. Thanks.

Copy link
Member

@munkm munkm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks good to me. Thanks for the fix! I think we talked in the triage meeting about adding some minor documentation for the position vector function; I'd be happy to merge once that's in.

@@ -568,7 +568,8 @@ def get_box_grids_below_level(
@cython.cdivision(True)
@cython.boundscheck(False)
@cython.wraparound(False)
def obtain_position_vector(data):
def obtain_position_vector(
data, field_names = ('x', 'y', 'z')):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree with this.

@munkm
Copy link
Member

munkm commented Oct 10, 2019

@jzuhone is going to add a couple tests to this and then it'll be ready to go.

@jzuhone
Copy link
Contributor Author

jzuhone commented Oct 16, 2019

After the tests pass, this is ready to go. I think disk objects need to be added to the AMR and SPH answer tests, which would have to come in another PR.

@munkm munkm merged commit 22f6033 into yt-project:yt-4.0 Oct 18, 2019
@jzuhone jzuhone deleted the cyl_fix branch January 14, 2020 18:46
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.

3 participants