-
Notifications
You must be signed in to change notification settings - Fork 18
[GSPH] Add GSPH physics module (UpdateDerivs) #1452
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
Conversation
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 introduces the foundational Godunov Smoothed Particle Hydrodynamics (GSPH) physics module, a significant enhancement for hydrodynamics simulations. It shifts from conventional SPH artificial viscosity to a more physically rigorous approach by solving 1D Riemann problems at particle interfaces. This allows for the precise calculation of particle acceleration and energy rates, adhering to the well-established Cha & Whitworth (2003) formulation. The module is designed with flexibility, offering various Riemann solver and reconstruction configurations, and integrates seamlessly with existing Shamrock infrastructure for efficient neighbor searching and data handling. Highlights
🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console. 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 introduces the core GSPH physics module, which is a significant and well-structured addition. The separation of concerns into configuration, storage, and computation modules is commendable. However, I've identified several critical issues that need to be addressed before merging. There is substantial code duplication, particularly in the Riemann solver implementations and the main derivative update loops, which will pose a maintenance challenge. A critical bug exists in the energy equation calculation, where a symmetric formula is incorrectly used for a non-symmetric term. Additionally, there are hardcoded values that make the implementation less robust, such as an assumed value for gamma in the HLLC solver, and magic numbers that should be defined as named constants. I have provided specific comments and code suggestions to resolve these issues.
src/shammodels/gsph/include/shammodels/gsph/math/riemann/iterative.hpp
Outdated
Show resolved
Hide resolved
9a4853a to
b9643aa
Compare
b9643aa to
d1d3553
Compare
y-lapeyre
left a comment
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.
Could you close the Gemini conversations when the point was addressed please? To make the discussion clearer :)
Resolved all Gemini conversations in my newest commit :) |
9c9dc0b to
9d3b7d7
Compare
Add the derivative computation module for GSPH: - UpdateDerivs.hpp/cpp: Computes acceleration and energy rate using Riemann solvers - Supports iterative (van Leer 1997) and HLLC approximate solvers - Exact and Roe solvers declared but not yet implemented - Uses forces.hpp utilities from merged PR Shamrock-code#1451 for acceleration calculation - Follows Cha & Whitworth (2003) formulation for energy equation
9d3b7d7 to
acf30a7
Compare
y-lapeyre
left a comment
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.
Ok to me!
Workflow reportworkflow report corresponding to commit 59eeb4a Pre-commit check reportPre-commit check: ✅ Test pipeline can run. Clang-tidy diff reportNo relevant changes found. You should now go back to your normal life and enjoy a hopefully sunny day while waiting for the review. Doxygen diff with
|
tdavidcl
left a comment
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.
LGTM
## Summary This PR adds the core physics computation module for GSPH. **Depends on:** Shamrock-code#1451 (Riemann solvers) ### Files added **modules/UpdateDerivs.hpp/cpp:** - Main derivative computation using Riemann solver results - Implements both iterative (van Leer 1997) and HLLC solvers - Computes acceleration (dv/dt) using interface pressure p* - Computes energy rate (du/dt) for adiabatic simulations - Uses shamrock's neighbor cache for efficient particle iteration ### Implementation Follows Cha & Whitworth (2003) formulation: - Momentum equation: `dv_a/dt = -sum_b m_b * p* * (nabla W / (rho^2 * omega))` - Energy equation: `du_a/dt = -sum_b m_b * p* * (v* - v_a) dot nabla W / (rho^2 * omega)` For each particle pair: 1. Extract left/right states (rho, v, P) 2. Project velocities onto pair axis 3. Solve 1D Riemann problem to get (p*, v*) 4. Compute force contribution using p* instead of artificial viscosity ### CMakeLists.txt updates - Added UpdateDerivs.cpp to sources - Added shamtree and shammodels_sph dependencies ## References - Cha & Whitworth (2003) "Implementations and tests of Godunov-type particle hydrodynamics" - Inutsuka (2002) "Reformulation of SPH with Riemann Solver" ## Test plan - [x] Builds successfully with GSPH infrastructure - [x] Template instantiations compile for all kernel types (M4, M6, M8, C2, C4, C6) --------- Co-authored-by: David--Cléris Timothée <timothee.davidcleris@proton.me> Co-authored-by: Yona LAPEYRE <yona.lapeyre@ens-lyon.fr>
Summary
This PR adds the core physics computation module for GSPH.
Depends on: #1451 (Riemann solvers)
Files added
modules/UpdateDerivs.hpp/cpp:
Implementation
Follows Cha & Whitworth (2003) formulation:
dv_a/dt = -sum_b m_b * p* * (nabla W / (rho^2 * omega))du_a/dt = -sum_b m_b * p* * (v* - v_a) dot nabla W / (rho^2 * omega)For each particle pair:
CMakeLists.txt updates
References
Test plan