Skip to content

Self-shielded Grackle table#1527

Merged
chongchonghe merged 17 commits into
developmentfrom
chong/cooling/grackle-shielded
Jan 7, 2026
Merged

Self-shielded Grackle table#1527
chongchonghe merged 17 commits into
developmentfrom
chong/cooling/grackle-shielded

Conversation

@chongchonghe

@chongchonghe chongchonghe commented Dec 18, 2025

Copy link
Copy Markdown
Contributor

Description

Use this command to generate a Grackle cooling table with self-shielding (https://grackle.readthedocs.io/en/latest/Parameters.html#data-files), excluding photoelectric heating to allow time/space-variable photoelectric heating rate.

./resample_grackle_cooling_tables.py --shield --exclude_pe --output CloudyData_UVB=HM2012_shielded_resampled_noPE.h5

More changes:

  • The resample_grackle_cooling_tables.py script will also make a phase plot of cooling length as a function of gas number density n and effective temperature T/mu.

Related issues

Are there any GitHub issues that are fixed by this pull request? Add a link to them here.

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.

@dosubot dosubot Bot added size:L This PR changes 100-499 lines, ignoring generated files. dependencies Pull requests that update a dependency file labels Dec 18, 2025
@gemini-code-assist

Copy link
Copy Markdown
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 significantly extends the capabilities of the Grackle cooling table generation and resampling tools. It introduces the ability to create self-shielded cooling tables and provides an option to exclude photoelectric heating, which is crucial for simulations requiring dynamic heating rates. Furthermore, the updated script now computes and visualizes cooling lengths, offering deeper insights into the thermal properties of the gas.

Highlights

  • Self-Shielding Support: The script can now generate Grackle cooling tables that account for self-shielding effects, enhancing the accuracy of astrophysical simulations in dense gas environments.
  • Photoelectric Heating Exclusion: Users can opt to exclude photoelectric heating from the generated tables, which is crucial for simulations requiring dynamic or externally controlled heating rates.
  • Cooling Length Calculation and Visualization: The table resampling process now includes the calculation and storage of cooling lengths, and automatically generates phase plots to visualize these thermal properties.
  • Enhanced Command-Line Interface: New command-line arguments (--shield, --exclude_pe, --local) have been added to resample_grackle_cooling_tables.py, providing greater control over table generation and data handling.
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.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

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 primarily introduces the calculation and plotting of cooling lengths into the resample_grackle_cooling_tables.py script. A new compute_cooling_time function was added, and the resample_cooling_tables function was updated to utilize this, store the calculated cooling lengths in the output HDF5 file, and generate a phase plot of cooling length. The cooling_rate function in grackle_tables.py was modified to include an include_pe parameter, allowing photoelectric heating to be conditionally applied. New command-line arguments (--exclude_pe, --shield, --local) were added to resample_grackle_cooling_tables.py to control photoelectric heating, use shielded Grackle data, and manage local storage of downloaded tables, respectively, with updated example usage in the script's docstring. Review comments indicate that the compute_cooling_time function's docstring and inline unit comment incorrectly refer to 'cooling length' and 'cm' instead of 'cooling time' and 's', and that an unused variable Z_abs should be removed from the plotting section.

Comment thread extern/cooling/resample_grackle_cooling_tables.py Outdated
Comment thread extern/cooling/resample_grackle_cooling_tables.py Outdated
Comment thread extern/cooling/resample_grackle_cooling_tables.py Fixed
Comment thread extern/cooling/resample_grackle_cooling_tables.py Fixed
Comment thread extern/cooling/resample_grackle_cooling_tables.py Fixed
Comment thread extern/cooling/resample_grackle_cooling_tables.py Fixed
Comment thread extern/cooling/resample_grackle_cooling_tables.py Fixed

@BenWibking BenWibking left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Overall, looks good. I think it would be useful to add an HDF5 attribute to the output file that says whether PE is included or not. Otherwise, it relies on the user to change the filename to memorialize this, and that could be easily forgotten. On the Quokka side, it should check whether this attribute is set or not, and turn on/off PE accordingly.

@chongchonghe

chongchonghe commented Dec 19, 2025

Copy link
Copy Markdown
Contributor Author

Overall, looks good. I think it would be useful to add an HDF5 attribute to the output file that says whether PE is included or not. Otherwise, it relies on the user to change the filename to memorialize this, and that could be easily forgotten.

Good point. I'll do it.

On the Quokka side, it should check whether this attribute is set or not, and turn on/off PE accordingly.

This won't work, because turning on time-variable PE heating requires self-consistent SF and quite a few runtime parameters. Quokka can't just turn it on itself. However, I can add a check and throw an error if there is a mismatch between the cooling table and the problem setup.

@chongchonghe

Copy link
Copy Markdown
Contributor Author

/gemini review

@chongchonghe

Copy link
Copy Markdown
Contributor Author

@codex review

@chongchonghe

Copy link
Copy Markdown
Contributor Author

/azp run

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines successfully started running 2 pipeline(s).

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

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 calculation and storage of 'cooling length' in resampled Grackle cooling tables, including the generation of a phase plot for visualization. The resample_grackle_cooling_tables.py script was updated with new command-line options for handling shielded Grackle data, enabling local storage of downloaded tables, and providing more comprehensive usage examples. A significant change involves integrating the include_pe (photoelectric heating) flag into the HDF5 metadata of the resampled tables and modifying the C++ codebase to read this flag. The C++ changes ensure that if star formation history (SFH) based photoelectric heating is enabled in the simulation, the loaded Grackle cooling table must explicitly not include photoelectric heating, preventing double-counting. The DataTable.hpp utility was updated to correctly parse this new metadata attribute from HDF5 files. Review comments highlighted two issues: a potential TypeError in the Python script due to float division (n_rho/2) where integer division (n_rho//2) is required for array indexing, and a suggestion to clarify the docstring for compute_cooling_time to refer to Edot as 'net volumetric heating rate' instead of 'net cooling rate' for better accuracy.

Comment thread extern/cooling/resample_grackle_cooling_tables.py
Comment thread extern/cooling/resample_grackle_cooling_tables.py Outdated
@chongchonghe

Copy link
Copy Markdown
Contributor Author

/azp run

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines successfully started running 2 pipeline(s).

@chongchonghe

Copy link
Copy Markdown
Contributor Author

@BenWibking @markkrumholz I addressed all the comments. Ready for review.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. 👍

ℹ️ 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".

@sonarqubecloud

Copy link
Copy Markdown

@chongchonghe

Copy link
Copy Markdown
Contributor Author

/azp run

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines successfully started running 2 pipeline(s).

@chongchonghe

Copy link
Copy Markdown
Contributor Author

@BenWibking @markkrumholz Can you review this PR?

@chongchonghe

Copy link
Copy Markdown
Contributor Author

@BenWibking @markkrumholz Can you approve and merge this PR?
I think we should actually use this shielded Grackle table for all future runs, including our INCITE runs. The current Grackle table does not cool efficiently enough.

@BenWibking

BenWibking commented Jan 7, 2026

Copy link
Copy Markdown
Collaborator

@BenWibking @markkrumholz Can you approve and merge this PR? I think we should actually use this shielded Grackle table for all future runs, including our INCITE runs. The current Grackle table does not cool efficiently enough.

We used it in https://ui.adsabs.harvard.edu/abs/2023MNRAS.521.5972W/abstract and it produced what I would say are "vaguely reasonable" results. So I am hesitant to change it for the full-disk simulations, unless we can be sure that it won't make the agreement with MW observations worse, given that there is a lot of missing physics in the current version. What are your criteria for saying that the shielded table is better?

@markkrumholz

Copy link
Copy Markdown
Collaborator

We need the revised tables for the dwarf galaxy simulations, because the current tables do not function properly at low metallicity. We know this because @chongchonghe's sub-solar tall box sims using the old grackle cooling fail to form any stars at all, because the heating from the extragalactic UV / X-ray keeps the gas thermally stable even when the photoelectric heating rate is zero. So I think we will need these new tables for the dwarf sims at a minimum.

@chongchonghe chongchonghe added this pull request to the merge queue Jan 7, 2026
@dosubot dosubot Bot added the lgtm This PR has been approved by a maintainer label Jan 7, 2026
Merged via the queue into development with commit 81159e2 Jan 7, 2026
49 checks passed
@chongchonghe chongchonghe deleted the chong/cooling/grackle-shielded branch January 14, 2026 11:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

dependencies Pull requests that update a dependency file lgtm This PR has been approved by a maintainer size:L This PR changes 100-499 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants