Tabulated optically thin radiative cooling module with Townsend integration#349
Tabulated optically thin radiative cooling module with Townsend integration#349dutta-alankar wants to merge 23 commits into
Conversation
|
@glesur I noticed that use of CGS quantities has now been incorporated into |
Updated energy calculation in addSourceTerms.hpp to use energy per unit volume instead of specific energy.
|
I have now updated the Townsend radiative cooling module to utilize the code units to CGS units conversion as a runtime parameter from the ini file and the documentation has been updated accordingly along with the addition of a test problem of an advecting uniform box undergoing cooling in |
|
Hi @dutta-alankar |
@neutrinoceros I understand. Apologies for my lack of knowledge on the latest developments and dynamics in the Idefix development team. |
|
No worries |
|
@dutta-alankar thanks for the heads up and the additional test. I owe you an applogy for the delay in working on your PR... I'll submit a review shortly, but in the meantime, I think you can probably start with fixing the pre-commit issues. |
[FIX] `pre-commit` linting
No worries. I myself, had been occupied with many other stuffs and this got to the back burner for a long while. I have fixed the linting from the pre-commit report. |
|
@dutta-alankar: you should target the develop branch as this is not a hotfix. |
There was a problem hiding this comment.
Pull request overview
This PR introduces an optically thin radiative cooling capability to the Hydro module (tabulated cooling with Townsend integration), along with a dedicated test case, documentation, and a few build/logging quality-of-life improvements to support the new module and runtime outputs.
Changes:
- Add a new Hydro submodule for tabulated optically thin radiative cooling with Townsend integration and a configurable temperature floor.
- Add a CoolBox test setup (ini + setup/analysis) and new module documentation pages wired into the Sphinx docs.
- Improve runtime logging behavior (log directory handling) and update CMake logic for CUDA librt and HDF5 detection/parallel validation.
Reviewed changes
Copilot reviewed 19 out of 21 changed files in this pull request and generated 6 comments.
Show a summary per file
| File | Description |
|---|---|
| test/HD/CoolBox/setup.cpp | Adds a cooling validation analysis that writes temperature and inferred cooling rates over time. |
| test/HD/CoolBox/idefix.ini | Defines a small uniform-domain run configured to use the new Tabulated/Townsend cooling entry. |
| test/HD/CoolBox/definitions.hpp | Declares a basic 3D Cartesian test configuration. |
| src/input.hpp | Adds state to control log enabling and track executable directory for log fallback. |
| src/input.cpp | Determines an executable directory and enables log files after parsing input/CLI options. |
| src/global.hpp | Extends the logging API to accept an optional log directory. |
| src/global.cpp | Implements log-directory creation and explicit erroring on log open failure. |
| src/fluid/showConfig.hpp | Fixes an Ohmic typo and prints cooling configuration when enabled. |
| src/fluid/fluid.hpp | Plumbs cooling into Fluid: adds RadCooling ownership and initialization. |
| src/fluid/fluid_defs.hpp | Adds a cooling-related function typedef (currently unused in the diff). |
| src/fluid/cooling/cooling.hpp | Declares the new RadCooling class and parses [Hydro]:Cooling options. |
| src/fluid/cooling/cooling.cpp | Implements Townsend integration and computes per-cell energy source terms. |
| src/fluid/cooling/CMakeLists.txt | Adds cooling sources/includes to the build. |
| src/fluid/CMakeLists.txt | Wires the cooling subdirectory into the fluid build. |
| src/fluid/addSourceTerms.hpp | Applies cooling energy deltas during source-term application. |
| doc/source/programmingguide.rst | Fixes a small typo in idefix_for/idefix_reduce examples (ieng → iend). |
| doc/source/modules/radCooling.rst | Adds module documentation for radiative cooling and its input parameters. |
| doc/source/modules.rst | Adds the new cooling module page to the modules index. |
| CMakeLists.txt | Adds CUDA librt workaround and improves HDF5 target selection + parallel HDF5 checks. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| #include "fluid.hpp" | ||
|
|
||
| template<typename Phys> | ||
| RadCooling::RadCooling(Input &input, Grid &grid, Fluid<Phys> *hydroin): | ||
| Vc(hydroin->Vc), | ||
| Vs(hydroin->Vs) { | ||
| idfx::pushRegion("RadCooling::RadCooling"); |
| #include <string> | ||
|
|
| if (coolingOn) { | ||
| Uc(ENG,k,j,i) += delta_eng_cool(k,j,i); // energy per unit volume | ||
| } |
| else { | ||
| del_prs = ZERO_F; | ||
| delta_eng(k,j,i) = ZERO_F; | ||
| } |
| void MakeAnalysis(DataBlock & data) { | ||
| // Mirror data on host for analysis reductions. | ||
| DataBlockHost d(data); | ||
| d.SyncFromDevice(); |
| The ``RadiativeCooling`` module implements the computation of the loss of internal thermal energy | ||
| due radiation in an optically thin medium. Physically, it solves for :math:`\dot_{e}=\mathcal{L}`, | ||
| where we have used :math:`\mathcal{L}=-n_H^2 \Lambda (T)` (where :math:`T` is the gas temperature, | ||
| :math:`n_H=\rho X_H/m_p` is the total hydrogen number density, and :math:`\Lambda(T)`) is the | ||
| radiative cooling rate computed seperately from quantum mechanical calculations |
I have implemented optically thin radiative cooling module for Idefix. I have tested this for by allowing cooling of a collection of cells (initially at$2\times 10^6 \ \rm K$ ) in a uniform domain (and calculating temperature and $-\dot{e}/n_H^2$ from the code over time) which seems to exactly reproduce the cooling rate as supplied by the table read during runtime by the code (screenshot attached). The setup and analysis code is attached here for reference and further testing. I have also put in a sample
Cloudygenerated equilibrium cooling rate table for plasma at solar metallicity in presence of HM12 UV photo-ionizing background at redshift 0.The integration method follows the Townsend algorithm (https://ui.adsabs.harvard.edu/abs/2009ApJS..181..391T/abstract), which is quite efficient in calculating the pressure drop due to radiative cooling. There is also a way to set a floor that switches off cooling below some temperature, as required by many popular setups. I have also included a small
.rstdocumentation for this module.Let me know if this is something worth integrating to the main repo and if something additional needs to be done.
Test setup:
cooling-test.tar.gz
Test result (purple: supplied table; green: code result):
