Skip to content
Open
Show file tree
Hide file tree
Changes from 11 commits
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
b36dafa
Tolerance updated in `RegressionTest` in `test/HD/sod/testme.py`
dutta-alankar Aug 30, 2024
58de06b
[FIX] Dump datatype agnostic file xdmf IO
dutta-alankar Sep 9, 2024
c7f83dd
Merge branch 'idefix-code:master' into master
dutta-alankar Aug 28, 2025
92992da
[ADD] tabulated optically thin radiative cooling module
dutta-alankar Sep 4, 2025
1357703
[FIX] additional tags for successful `cmake` compilation
dutta-alankar Sep 4, 2025
b07f7ff
[FIX] minor typo in documentation
dutta-alankar Sep 6, 2025
70d6c40
[FIX] decrement internal energy by radiative cooling
dutta-alankar Sep 6, 2025
d4aa609
[FIX] cpplint edits
dutta-alankar Sep 6, 2025
231951b
[DOC] radiative cooling module documentation
dutta-alankar Sep 6, 2025
16a3844
[DOC] unit conversion
dutta-alankar Sep 6, 2025
6f7733f
[FIX] reverse old change
dutta-alankar Sep 6, 2025
391b273
Merge branch 'idefix-code:master' into master
dutta-alankar Jan 14, 2026
ff6dbfa
Merge branch 'master' into master
dutta-alankar Jun 17, 2026
f625997
Change energy calculation to energy per unit volume
dutta-alankar Jun 17, 2026
7bb5ef1
Usage of runtime code units in cooling
dutta-alankar Jun 18, 2026
7f8d399
documentation update
dutta-alankar Jun 18, 2026
c6040dc
Fix formatting of code block reference in radCooling.rst
dutta-alankar Jun 18, 2026
781e56d
Fix cooling to work on GPUs
dutta-alankar Jun 18, 2026
b45b6c6
Fix non-existent library linking error (librt stub)
dutta-alankar Jun 19, 2026
02cd06d
Handle output log directory creation and log file dumping
dutta-alankar Jun 19, 2026
6cb070a
[FIX] `pre-commit` linting
dutta-alankar Jun 22, 2026
be83ab6
Merge pull request #1 from dutta-alankar/pr-349
dutta-alankar Jun 22, 2026
0e37bc4
Fix cpplint in cooling Townsend range check
dutta-alankar Jun 23, 2026
d34c256
Apply suggestions from code review
dutta-alankar Jun 28, 2026
34f99a8
Addressed Copilot code review
dutta-alankar Jun 29, 2026
4209e26
Fix for the circular dependency issue in cooling header
dutta-alankar Jun 29, 2026
9a3e4ad
Fix uninitialized warning for EoS object
dutta-alankar Jun 29, 2026
1a5d395
Fix failing pytest issue
dutta-alankar Jun 29, 2026
9350e90
Fix with `HAVE_ENERGY`guard on cooling
dutta-alankar Jun 29, 2026
7ea869d
Apply suggestions from code review
dutta-alankar Jun 29, 2026
80140a9
Added test for Cooling box
dutta-alankar Jun 29, 2026
ec0582c
Added test for Cooling box
dutta-alankar Jun 29, 2026
ccff439
`pre-commit` linting fix
dutta-alankar Jun 29, 2026
c245f30
Cooling box test added to CI/CD workflow
dutta-alankar Jun 29, 2026
d682ba9
Fix to pass simulation run tests
dutta-alankar Jun 29, 2026
f27975d
Fix default executable directory
dutta-alankar Jun 29, 2026
be68a22
Apply suggestions from code review
dutta-alankar Jun 29, 2026
445fe6c
Minor rearrangement of cooling cases
dutta-alankar Jul 5, 2026
0318e7b
Minor comment modification
dutta-alankar Jul 5, 2026
ea0a21e
Fix CoolBox testme.json for the pytest-based test runner
dutta-alankar Jul 5, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ endif()
if(Idefix_MPI)
add_compile_definitions("WITH_MPI")
find_package(MPI REQUIRED)
target_link_libraries(idefix MPI::MPI_CXX)
target_link_libraries(idefix PRIVATE MPI::MPI_CXX)
target_sources(idefix
PUBLIC src/mpi.cpp
PUBLIC src/mpi.hpp
Expand All @@ -114,9 +114,9 @@ if(Idefix_HDF5)
PUBLIC src/output/xdmf.cpp
PUBLIC src/output/xdmf.hpp
)
find_package(HDF5 REQUIRED)
target_link_libraries(idefix "${HDF5_LIBRARIES}")
target_include_directories(idefix "${HDF5_INCLUDE_DIRS}")
find_package(HDF5 REQUIRED COMPONENTS C)
target_link_libraries(idefix PRIVATE HDF5::HDF5)
# target_include_directories(idefix PRIVATE ${HDF5_INCLUDE_DIRS})
message(STATUS "XDMF (hdf5+xmf) dumps enabled")
else()
set(Idefix_HDF5 OFF)
Expand Down Expand Up @@ -237,7 +237,7 @@ target_include_directories(idefix PUBLIC
src
)

target_link_libraries(idefix Kokkos::kokkos)
target_link_libraries(idefix PRIVATE Kokkos::kokkos)

message(STATUS "Idefix final configuration")
if(Idefix_EVOLVE_VECTOR_POTENTIAL)
Expand Down
5 changes: 5 additions & 0 deletions doc/source/modules.rst
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@ In this section, you will find a more detailed documentation about each module t
The Braginskii module, models the anisotropic flux of heat and momentum
taking place in weakly collisional, magnetised plasma (like the intracluster medium).

:ref:`radiativeCoolingModule`
The optically thin radiative cooling module, handles the loss of internal thermal energy due to radiation in an
optically thin medium.

:ref:`gridCoarseningModule`
The grid coarsening module, that allows to derefine the grid in particular locations to speed up the computation.

Expand All @@ -42,5 +46,6 @@ In this section, you will find a more detailed documentation about each module t
modules/eos.rst
modules/selfGravity.rst
modules/braginskii.rst
modules/radCooling.rst
modules/gridCoarsening.rst
modules/pydefix.rst
62 changes: 62 additions & 0 deletions doc/source/modules/radCooling.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
.. _radiativeCoolingModule:

Radiative Cooling module
===================

Comment thread
dutta-alankar marked this conversation as resolved.
Outdated
Equations solved and method
---------------------------

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
Comment thread
dutta-alankar marked this conversation as resolved.
Outdated
by other plasma modeling codes, for example, Cloudy (Ferland et. al, PASP 110, 749 (1998)).

This computation becomes especially relevant for multiphase gas in astrophysical environments
prevalent in the ISM, the CGM, and the ICM, for which this module has been designed.

The ``RadiativeCooling`` module implemented in *Idefix* follows the algorithm of the Townsend
to integrate the loss of internal thermal energy (Townsend, ApJS 181, 2 (2009)) at every timestep
in an operator split manner. The cooling rate is read from a table at runtime where the `first` row
is temperature (in :math:`\rm K`) and second row is :math:`\Lambda (T)` (in :math:`\rm erg cm^3 s^{-1}`).
Comment thread
dutta-alankar marked this conversation as resolved.

.. note::
We assume a normalization of :math:`n_H`, the total hydrogen number density for the
of the cooling curve supplied by the rate table at runtime to *Idefix*. Different might cooling curves with
different normalisation is known to exist in literature and special attention must be given to
what is supplied to the code. Right now, this module has been tested only with the ideal gas equation of state.
We also assume the mean particle mass :math:`\mu=0.609`, i.e., constant in the current implementation (appropriate
for fully ionized plasma).
Comment thread
dutta-alankar marked this conversation as resolved.
It is recommended to include conversion factors between code and physical units in ``definitions.hpp``. For example,
``
#define UNIT_LENGTH 3.086e+18
#define UNIT_DENSITY (1.0e-02*0.609*1.673e-24)
#define UNIT_VELOCITY 1.000e+05
``

Main parameters of the module
-----------------------------

The ``RadiativeCooling`` module is a submodule of the ``Hydro`` module to compute the loss of internal thermal energy (pressure)
of the gas. The parameters specific to radiative cooling are to be set in a dedicated line starting with the word
``Cooling`` in the ``[Hydro]`` block. An example is as follows succeded by a detailed explanation.

``
Cooling Tabulated cooltable.dat Townsend TcoolFloor 1.0e+04
``
Comment thread
dutta-alankar marked this conversation as resolved.
Outdated

+----------------------+-------------------------+----------------------------------------------------------------------------------------------+
| Entry name | Parameter type | Comment |
+======================+=========================+==============================================================================================+
| cooling mode | string | | Type of radiative cooling. Only `Tabulated` supported right now. |
+----------------------+-------------------------+----------------------------------------------------------------------------------------------+
| table name | string | | name/location of the cooling table w.r.t. *Idefix* binary to be loaded at runtime. |
+----------------------+-------------------------+----------------------------------------------------------------------------------------------+
| integration method | string | | Integration method to calculate the internal thermal energy loss due to radiative cooling. |
| | | | Only `Townsend` supported right now. |
+----------------------+-------------------------+----------------------------------------------------------------------------------------------+
| TcoolFloor (skip) | string | | Floor temperature in K below which cooling is turned off. |
+----------------------+-------------------------+----------------------------------------------------------------------------------------------+
| temperature floor | float (optional) | | Default is 1.0e+04 |
+----------------------+-------------------------+----------------------------------------------------------------------------------------------+
6 changes: 3 additions & 3 deletions doc/source/programmingguide.rst
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ A typical loop on three indices looks like
idefix_for("LoopName",
kbeg,kend,
jbeg,jend,
ibeg,ieng,
ibeg,iend,
KOKKOS_LAMBDA (int k, int j, int i) {
myArray(k,j,i) = 0.0;
});
Expand Down Expand Up @@ -153,7 +153,7 @@ For instance, a sum over all of the elements would be done through:
idefix_reduce("Sum",
kbeg,kend,
jbeg,jend,
ibeg,ieng,
ibeg,iend,
KOKKOS_LAMBDA (int k, int j, int i, real &localSum) {
localSum += myArray(k,j,i);
},
Expand All @@ -179,7 +179,7 @@ snippet:
idefix_reduce("Minimum",
kbeg,kend,
jbeg,jend,
ibeg,ieng,
ibeg,iend,
KOKKOS_LAMBDA (int k, int j, int i, real &localMin) {
localMin = std::fmin(localMin, myArray(k,j,i));
},
Expand Down
1 change: 1 addition & 0 deletions src/fluid/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ add_subdirectory(constrainedTransport)
add_subdirectory(eos)
add_subdirectory(RiemannSolver)
add_subdirectory(tracer)
add_subdirectory(cooling)


target_sources(idefix
Expand Down
18 changes: 17 additions & 1 deletion src/fluid/addSourceTerms.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ struct Fluid_AddSourceTermsFunctor {
//*****************************************************************
// Functor constructor
//*****************************************************************
explicit Fluid_AddSourceTermsFunctor(Fluid<Phys> *hydro, real dt) {
explicit Fluid_AddSourceTermsFunctor(Fluid<Phys> *hydro, real dt):
hydroin(hydro) {
Comment on lines +22 to +23

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

Uc = hydro->Uc;
Vc = hydro->Vc;
x1 = hydro->data->x[IDIR];
Expand All @@ -42,6 +43,13 @@ struct Fluid_AddSourceTermsFunctor {
}
// shearing box (only with fargo&cartesian)
sbS = hydro->sbS;

// Radiative cooling
coolingOn = hydro->coolingOn;
if (coolingOn) {
hydro->radCooling->CalculateCoolingSource(dt);
this->delta_eng_cool = hydro->radCooling->delta_eng;
}
}

//*****************************************************************
Expand All @@ -52,7 +60,9 @@ struct Fluid_AddSourceTermsFunctor {
IdefixArray1D<real> x1;
IdefixArray1D<real> x2;
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

real dt;
#if GEOMETRY == SPHERICAL
IdefixArray1D<real> sinx2;
Expand All @@ -72,6 +82,9 @@ struct Fluid_AddSourceTermsFunctor {
// shearing box (only with fargo&cartesian)
real sbS;

// Radiative cooling
bool coolingOn;

//*****************************************************************
// Functor Operator
//*****************************************************************
Expand Down Expand Up @@ -194,7 +207,10 @@ struct Fluid_AddSourceTermsFunctor {
Uc(MX2,k,j,i) += dt*Sm / rt(i);
#endif // COMPONENTS
#endif
if (coolingOn) {
Uc(ENG,k,j,i) += (delta_eng_cool(k,j,i)/Uc(RHO,k,j,i)); // specific energy
Comment thread
dutta-alankar marked this conversation as resolved.
Outdated
}
Comment thread
dutta-alankar marked this conversation as resolved.
}
};


Expand Down
8 changes: 8 additions & 0 deletions src/fluid/cooling/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
target_sources(idefix
PUBLIC ${CMAKE_CURRENT_LIST_DIR}/cooling.hpp
PUBLIC ${CMAKE_CURRENT_LIST_DIR}/cooling.cpp
)

target_include_directories(idefix
PUBLIC ${CMAKE_CURRENT_LIST_DIR}
)
Loading