-
Notifications
You must be signed in to change notification settings - Fork 18
Add SPH pairing instability test example #1504
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 SPH pairing instability test example #1504
Conversation
Add example scripts for testing the pairing instability in SPH: - pairing_instability.py: Simulation script supporting both Square and FCC lattice configurations with M4 cubic spline kernel - generate_gifs.py: Visualization script to generate annotated GIF animations from VTK output The pairing instability is a well-known numerical artifact in SPH where particles on regular grids tend to cluster in pairs. This test compares Square vs FCC lattice behavior to demonstrate the effect. Configuration via environment variables: PAIRING_LATTICE: square or fcc PAIRING_N: Grid resolution PAIRING_END_TIME: Simulation end time PAIRING_N_OUTPUTS: Number of VTK outputs Usage: PAIRING_LATTICE=square ./shamrock --sycl-cfg 0:0 --rscript pairing_instability.py python generate_gifs.py
Summary of ChangesHello @Guo-astro, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request adds a comprehensive example for testing the SPH pairing instability, a critical numerical artifact in particle-based simulations. It provides a simulation setup that compares the stability of square and FCC initial particle lattices, alongside a robust visualization tool to generate animated GIFs from the simulation results. This allows users to easily observe and understand how initial particle arrangements influence the development of the instability, contributing to better understanding and validation of SPH methods. Highlights
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code Review
This pull request adds two new example scripts for testing SPH pairing instability. The simulation script pairing_instability.py and the visualization script generate_gifs.py are well-structured and documented.
My review focuses on improving code style, performance, and robustness. For pairing_instability.py, I've suggested vectorizing the particle generation loops using NumPy, which is more idiomatic and performant. For generate_gifs.py, I've pointed out some style improvements regarding imports and resource management, suggested making command-line arguments mutually exclusive for better user experience, and recommended reading simulation parameters from the metadata file to make the script more robust.
- Move io import to top-level - Use context manager for BytesIO - Read physics params from metadata instead of hardcoding - Make --annotated/--simple mutually exclusive - Vectorize particle generation with NumPy - Reduce pairing_instability.py from 257 to 114 lines - Reduce generate_gifs.py from 361 to 176 lines
|
Thanks @Guo-astro for opening this PR! You can do multiple things directly here: Once the workflow completes a message will appear displaying informations related to the run. Also the PR gets automatically reviewed by gemini, you can: |
- Remove separate generate_gifs.py file - Add GIF generation at end of pairing_instability.py - Optional dependency with try/except for missing packages
Summary
Add example script for testing the pairing instability in SPH with Square and FCC lattice configurations using M4 cubic spline kernel.
Background
The pairing instability is a well-known numerical artifact in SPH where particles on regular grids tend to cluster in pairs. This test compares Square vs FCC lattice behavior.
Configuration
Environment variables:
PAIRING_LATTICE: square or fcc (default: square)PAIRING_N: Grid resolution (default: 64)PAIRING_END_TIME: Simulation end time (default: 1.0)PAIRING_N_OUTPUTS: Number of VTK outputs (default: 50)Usage
GIF animation is generated automatically at the end of each simulation run (requires pyvista, imageio, PIL).
Test Plan