Skip to content

Tabulated optically thin radiative cooling module with Townsend integration#349

Open
dutta-alankar wants to merge 39 commits into
idefix-code:developfrom
dutta-alankar:master
Open

Tabulated optically thin radiative cooling module with Townsend integration#349
dutta-alankar wants to merge 39 commits into
idefix-code:developfrom
dutta-alankar:master

Conversation

@dutta-alankar

@dutta-alankar dutta-alankar commented Sep 6, 2025

Copy link
Copy Markdown
Contributor

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 Cloudy generated 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 .rst documentation 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):
image

@dutta-alankar

dutta-alankar commented Oct 20, 2025

Copy link
Copy Markdown
Contributor Author

@glesur I noticed that use of CGS quantities has now been incorporated into Idefix. If this radiative cooling module with Townsend integration is something you/developer community thinks worth being integrated into Idefix, then I would be happy to change the code to utilize the CGS units capability. Let me know.

Comment thread src/fluid/addSourceTerms.hpp Outdated
Comment thread src/fluid/fluid.hpp
@dutta-alankar

dutta-alankar commented Jun 19, 2026

Copy link
Copy Markdown
Contributor Author

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 test/HD/CoolBox. @glesur @neutrinoceros Please let me know if you would like to have this feature in Idefix. I have been using this modified version of Idefix in simulating turbulent radiatively cooling mixing layers and also plan to use this in upcoming cloud-crushing simulations.

@neutrinoceros

Copy link
Copy Markdown
Collaborator

Hi @dutta-alankar
For the record, I have no say in what goes into idefix and it's not part of my job to work on it anymore.

@dutta-alankar

Copy link
Copy Markdown
Contributor Author

Hi @dutta-alankar For the record, I have no say in what goes into idefix and it's not part of my job to work on it anymore.

@neutrinoceros I understand. Apologies for my lack of knowledge on the latest developments and dynamics in the Idefix development team.

@neutrinoceros

Copy link
Copy Markdown
Collaborator

No worries

@glesur

glesur commented Jun 22, 2026

Copy link
Copy Markdown
Contributor

@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.

Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
@dutta-alankar dutta-alankar changed the base branch from master to develop June 29, 2026 06:32
@dutta-alankar

dutta-alankar commented Jun 29, 2026

Copy link
Copy Markdown
Contributor Author

@dutta-alankar: you should target the develop branch as this is not a hotfix.

@glesur I agree and should have noted this earlier. Anyway, now I changed the base branch to develop and resolved all the issues raised in Copilot code review. I am trying to run the CI/CD workflows locally on our Freya cluster and ensure if they all pass or not.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 22 out of 24 changed files in this pull request and generated 6 comments.

Comment thread src/fluid/fluid.hpp
Comment thread src/fluid/cooling/cooling.cpp Outdated
Comment on lines +100 to +104
// tabulated data does not enclose the temperature value
printf("RadCooling::TownsendIntegration Temperature out of range: T=%e, "
"valid range=[%e, %e]\n",
temperature, temperature_min_data, temperature_max_data);
Kokkos::abort("RadCooling::TownsendIntegration Temperature out of range");

@dutta-alankar dutta-alankar Jun 29, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

It might be okay to let it pass.

Comment thread src/global.cpp
Comment thread src/fluid/cooling/coolingConstructor.hpp Outdated
Comment thread doc/source/modules/radCooling.rst
Fix to not have radiative cooling in isothermal setup

Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 22 out of 24 changed files in this pull request and generated 6 comments.

Comment thread src/fluid/cooling/cooling.cpp Outdated
Comment thread src/global.cpp
Comment thread doc/source/modules/radCooling.rst Outdated
Comment thread doc/source/modules/radCooling.rst Outdated
Comment thread test/HD/CoolBox/idefix.ini
Comment thread src/fluid/cooling/coolingConstructor.hpp Outdated
@glesur

glesur commented Jun 29, 2026

Copy link
Copy Markdown
Contributor

@dutta-alankar : good idea for the CIs. Drop me a message when you think this is ready so that I can trigger the workflow on our side.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 26 out of 28 changed files in this pull request and generated 5 comments.

Comment thread src/fluid/cooling/cooling.cpp Outdated
Comment thread src/fluid/cooling/cooling.cpp Outdated
Comment thread doc/source/modules/radCooling.rst
Comment on lines +22 to +23
explicit Fluid_AddSourceTermsFunctor(Fluid<Phys> *hydro, real dt):
hydroin(hydro) {

@dutta-alankar dutta-alankar Jun 29, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Not related to my PR and I leave it to @glesur to consider this or not.

IdefixArray3D<real> csIsoArr;
IdefixArray3D<real> delta_eng_cool;

Fluid<Phys> *hydroin;

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Again not related to this PR and left to @glesur to decide

Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
@dutta-alankar

dutta-alankar commented Jun 29, 2026

Copy link
Copy Markdown
Contributor Author

@dutta-alankar : good idea for the CIs. Drop me a message when you think this is ready so that I can trigger the workflow on our side.

@glesur I think now you can trigger the CI/CD workflow from your end.

@dutta-alankar

Copy link
Copy Markdown
Contributor Author

@glesur In case you missed my previous comment. I think that this PR is now at a good state when you can trigger a CI/CD workflow.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants