-
Notifications
You must be signed in to change notification settings - Fork 8
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
Vectorization of xrd_simulator #9
Conversation
This is ready to ship. The docstrings should still be verified to fit with current changes though. The key issue limiting performance right now are convexhull operations. I dont know any vectorized way to intersect many tetrahedra with some polyhedra simultaneously, probably there is some GPU way of doing it. |
Fantastic! This looks good to me in general! 🙂 A corner case for the mesh spheres came up in my testing on your fork - it is related to loss of precision in the line segment and triangle sphere wrapper functions. The fix is just to expand the sphere radii very slightly to ensure that the triangle and line segments are actually containing the nodes they claim to contain. Without this I get bounding sphere radii that change as a function of pure rigid body motions which makes testing awkward. see commit d145326 I think we should add docstrings to the functions that are user exposed before we can merge this. It would be a shame to have a bunch of docs that are lying about the code. The starting point would be to hide the functions that are not supposed to be used by the user using the underscore notation Cheers |
@Marcraven : Please let me know if you will have the possibility to get the docs for this major pull request in shape (don't need to be perfect). It would be a shame to loose all the good progress. ❤️ Once this gets merged I think we deserve to roll up the version count and move from alpha into beta with a new releases on pypi and conda channels. Cheers |
Hi Axel,
I am sorry, I want to do it this week. Hopefully tomorrow!
Un saludo
…---
Marc Raventós Tato
On Tue, Jun 11, 2024 at 9:04 PM Axel Henningsson ***@***.***> wrote:
@Marcraven <https://github.com/Marcraven> : Please let me know if you
will have the possibility to get the docs for this major pull request in
shape (don't need to be perfect). It would be a shame to loose all the good
progress. ❤️
Once this gets merged I think we deserve to roll up the version count and
move from beta into alpha with a new releases on pypi and conda channels.
Cheers
Axel
—
Reply to this email directly, view it on GitHub
<#9 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AF4OE7EIJAVHB76P5KXPGVDZG5C35AVCNFSM6AAAAABGCPAAVSVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDCNRRGQZDONBRHE>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>
|
I increased the radii by 0.1% in the cases of line and triangle segments. ¿Would that be enough? |
Sounds good! |
This pull request is a generealized vectorization of most procedures in xrd_simulator.
The main idea behind is to increase computation speed an facilitate code parallelization whenever possible. The motivation behind was my intention to use this code to simulate powder samples with several million tetrahedra.
The main files affected are:
mesh.py
Once the mesh is created by meshio/pygalmesh, subsequent computations related to bounding spheres, centroids etc. have all been vectorized.
polycrystal.py
The _diffract method has been extensively modified to compute all diffraction points simultaneously for each phase present in the sample. There is still work to be done on the side of the tetrahedron-beam intersection, in which a faster bounding-box approximation has been implemented. The convex-hull calculation for the ScatteringUnit is still a bottleneck, but so far I have no idea how to improve it.
Another minor improvement has been adding zd and yd to the scattering unit to prevent repeating the calculation later in the rendering.
utils.py
Geometric calculations for circumspheres have been added here which help accelerate the mesh.py script a lot. A printvars utility has been added to help debugging memory issues during code execution.
Current bottlenecks
Vectorization of these last steps is not trivial and has to be thought through. The last one is probably doable although I could not find the time.
Suggestions