Skip to content

Add a new regression test: random SN in a box#1547

Merged
chongchonghe merged 27 commits intodevelopmentfrom
chong/tests/new-reg-test-blast
Jan 10, 2026
Merged

Add a new regression test: random SN in a box#1547
chongchonghe merged 27 commits intodevelopmentfrom
chong/tests/new-reg-test-blast

Conversation

@chongchonghe
Copy link
Contributor

@chongchonghe chongchonghe commented Dec 28, 2025

Description

Refactored RandomBlast Problem: The testRandomBlast.cpp problem was significantly refactored to utilize the new particle system for SN feedback, removing the previous stochastic sampling method and integrating particle initialization from a file.

Particle Generation Script: Added a new Python script (create_particles.py) to generate initial particle distributions for various types (CIC, Sink, Rad, StochasticStellarPop) with options for spatial sampling (uniform, Gaussian, Plummer) and physical parameters.

Dependent on #1546 : Supernova (SN) Explosion Tracking: Modified the C++ particle physics core to accurately track and return the number of supernova explosions occurring within a simulation timestep, enhancing diagnostics and logging

Checklist

Before this pull request can be reviewed, all of these tasks should be completed. Denote completed tasks with an x inside the square brackets [ ] in the Markdown source below:

  • I have added a description (see above).
  • I have added a link to any related issues (if applicable; see above).
  • I have read the Contributing Guide.
  • I have added tests for any new physics that this PR adds to the code.
  • (For quokka-astro org members) I have manually triggered the GPU tests with the magic comment /azp run.

@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @chongchonghe, 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 integrates a new regression test, 'random SN in a box,' into the Quokka astrophysical simulation framework. It introduces a dedicated Python utility for generating diverse particle initial conditions and significantly enhances the C++ backend to track and process supernova feedback from these particles. The changes streamline the setup of particle-based simulations and improve the robustness of particle data handling during checkpoint and restart operations, particularly across varying MPI configurations.

Highlights

  • New Regression Test: Introduced a new regression test named 'random SN in a box' to simulate supernova feedback using stochastic stellar population particles.
  • Particle Generation Script: Added a new Python script (create_particles.py) to generate initial particle distributions for various types (CIC, Sink, Rad, StochasticStellarPop) with options for spatial sampling (uniform, Gaussian, Plummer) and physical parameters.
  • Supernova (SN) Explosion Tracking: Modified the C++ particle physics core to accurately track and return the number of supernova explosions occurring within a simulation timestep, enhancing diagnostics and logging.
  • Refactored RandomBlast Problem: The testRandomBlast.cpp problem was significantly refactored to utilize the new particle system for SN feedback, removing the previous stochastic sampling method and integrating particle initialization from a file.
  • Checkpoint/Restart Robustness: Improved the particle checkpoint/restart mechanism to handle scenarios where the number of MPI processes changes between runs, ensuring data integrity and proper redistribution.
Using Gemini Code Assist

The 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 /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

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 .gemini/ folder in the base of the repository. Detailed instructions can be found here.

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

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a 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 a new regression test for random supernovae in a box, driven by particles. This involved a significant and valuable refactoring of the RandomBlast problem to use the StochasticStellarPop particle framework. A new Python script is also added to generate particle data. The supernova deposition logic is updated to count SN explosions for diagnostics, and the robustness of checkpoint/restarts is improved. The changes are generally excellent. I've found a few issues, including a bug in the new particle generation script, the use of non-portable system calls, and a bug in an existing test that would cause it to always report success.

@chongchonghe chongchonghe marked this pull request as ready for review December 28, 2025 15:02
@dosubot dosubot bot added the size:XL This PR changes 500-999 lines, ignoring generated files. label Dec 28, 2025
@dosubot dosubot bot added enhancement New feature or request particles labels Dec 28, 2025
Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

// update the particle's mass: subtract ejecta mass
const amrex::Real mass_dead_star = p.rdata(mass_index) - m_ej;
// AMREX_ASSERT_WITH_MESSAGE(mass_dead_star > 0.0, "SN progenitor mass should be greater than ejecta mass (10 M_sun)");
p.rdata(mass_index) = std::max(m_dead_min, mass_dead_star);

P1 Badge Cap SN ejecta by available stellar mass

The SN deposition path always removes a fixed m_ej = 10 M_sun and then clamps the remaining particle mass to m_dead_min (lines 299–344). With the new RandomBlast setup, many particles in particles_stochastic_n100.txt are well below 10 M⊙, yet when their death_time is reached this code still ejects 10 M⊙ and leaves a 1.4 M⊙ remnant, creating several solar masses out of nothing. Each low‑mass star that explodes will inflate the total mass and momentum budget, breaking conservation and the physical model. Consider skipping SNs for sub‑10 M⊙ stars or limiting ejecta to the particle’s current mass minus the remnant.

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@chongchonghe chongchonghe marked this pull request as draft December 28, 2025 15:51
@chongchonghe chongchonghe marked this pull request as ready for review December 28, 2025 17:11
@chongchonghe
Copy link
Contributor Author

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 2 pipeline(s).

@chongchonghe
Copy link
Contributor Author

chongchonghe commented Dec 28, 2025

@BenWibking @markkrumholz This is ready for your review.

I have created regression test benchmark files for this new test problem. Once merged to the main branch, it will demonstrate that hydro+AMR+gravity+particles+cooling is fully reproducible.
The regression test will fail now because the main branch is missing a particle data file required for the new test problem.

Dependent on #1546

Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@chongchonghe
Copy link
Contributor Author

@BenWibking @markkrumholz Can you review this PR? I need this new test problem to test radiation module and tall box benchmark.

@BenWibking
Copy link
Collaborator

Can you fix the merge conflict? Then I can review it.

@chongchonghe
Copy link
Contributor Author

@BenWibking Ready

@sonarqubecloud
Copy link

Copy link
Collaborator

@BenWibking BenWibking left a comment

Choose a reason for hiding this comment

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

LGTM assuming GPU tests pass

@dosubot dosubot bot added the lgtm This PR has been approved by a maintainer label Jan 10, 2026
@BenWibking
Copy link
Collaborator

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 2 pipeline(s).

@chongchonghe chongchonghe added this pull request to the merge queue Jan 10, 2026
Merged via the queue into development with commit 2f9b722 Jan 10, 2026
49 of 51 checks passed
@BenWibking BenWibking deleted the chong/tests/new-reg-test-blast branch January 10, 2026 14:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request lgtm This PR has been approved by a maintainer particles size:XL This PR changes 500-999 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants