Skip to content

Conversation

@Yin-YinjianZhao
Copy link
Contributor

In this PR, we will try to do a particle momentum rotation before calling the collision function, such that different azimuth positions of particles are also taken into account.

@Yin-YinjianZhao Yin-YinjianZhao added the component: collisions Anything related to particle collisions label Oct 28, 2021
@Yin-YinjianZhao Yin-YinjianZhao changed the title Correct collision algorithm in RZ. [WIP] Correct collision algorithm in RZ. Oct 28, 2021
@Yin-YinjianZhao
Copy link
Contributor Author

input.txt
This input file is used to test the PR.
With this PR, collisions should not change particle velocities.
Without this PR, collisions will change particle velocities randomly.
Capture
As shown in the plot, 1, 2, ..., 5 are five sample particles casually picked among total 640 particles.
All particles are tested using this script.
script.txt
It compares all particle velocities over time and show that all their velocities are not changed.

BTW, a small bug is fixed in UpdateMomentumPerezElastic.H.
I added a relative difference judgement at the beginning.
I.e., if the two particle's velocities are too close, no need to collide.
Previous judgement is too strict, and may lead to nan, such that the test mentioned before fails.

@lgtm-com
Copy link
Contributor

lgtm-com bot commented Nov 8, 2021

This pull request introduces 2 alerts when merging bb5a147 into 13f6e98 - view on LGTM.com

new alerts:

  • 1 for Unused import
  • 1 for Variable defined multiple times

@ax3l ax3l added the geometry: RZ axisymmetric 2D and quasi-3D label Nov 8, 2021
@Yin-YinjianZhao Yin-YinjianZhao changed the title [WIP] Correct collision algorithm in RZ. Correct collision algorithm in RZ. Nov 9, 2021
@lgtm-com
Copy link
Contributor

lgtm-com bot commented Nov 9, 2021

This pull request introduces 2 alerts when merging 9453118 into 9341e09 - view on LGTM.com

new alerts:

  • 1 for Unused import
  • 1 for Variable defined multiple times

Copy link
Member

@ax3l ax3l left a comment

Choose a reason for hiding this comment

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

Great work! Tiny suggestions inline.

@RemiLehe
Copy link
Member

As suggested by @NeilZaim, the generalization for higher-order modes could be implemented by binning particles in theta.

u1x[I1[i1]] = u1xbuf*std::cos(theta) - u1y[I1[i1]]*std::sin(theta);
u1y[I1[i1]] = u1xbuf*std::sin(theta) + u1y[I1[i1]]*std::cos(theta);
#endif

Copy link
Contributor

Choose a reason for hiding this comment

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

Why write to the backing arrays rather than just using local variables for these two values? This seems like pointless memory traffic.

Copy link
Contributor

Choose a reason for hiding this comment

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

Ok, so I see these are passed by reference, and updated inside UpdateMomentumPerezElastic. There's still an opportunity to do that write into a stack variable that won't be flushed to memory, and then only write it out once it's potentially been corrected by the following de-rotation.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@PhilMiller Hi, thanks for you comments, could you provide more details how to improve the code, I'm not sure if I understand your point. Stack variables also work on GPUs?

Copy link
Contributor

Choose a reason for hiding this comment

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

Yin-YinjianZhao#2
Here's a PR against your branch with my suggestion

Copy link
Member

@RemiLehe RemiLehe left a comment

Choose a reason for hiding this comment

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

Thanks for this PR. I added a request for the assert statement to be moved to another part of the code.

@RemiLehe RemiLehe merged commit 713f5ae into BLAST-WarpX:development Dec 6, 2021
lgiacome pushed a commit to lgiacome/WarpX that referenced this pull request Dec 16, 2021
* Add rotation.

* Fix a small bug

* Add automated test.

* rename inputs_rz

* Add json

* minor

* add comment.

* Apply suggestions from code review

Co-authored-by: Axel Huebl <[email protected]>

* Update analysis_collision_rz.py

* Fix missing import

* Change tolerance.

* Add warnings

* Apply suggestions from code review

* Move assert.

* fix end-of-Line whitespaces.

Co-authored-by: Axel Huebl <[email protected]>
Co-authored-by: Remi Lehe <[email protected]>
@Yin-YinjianZhao Yin-YinjianZhao deleted the collision_rz branch September 21, 2022 20:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

component: collisions Anything related to particle collisions geometry: RZ axisymmetric 2D and quasi-3D

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants