-
Notifications
You must be signed in to change notification settings - Fork 28
Tabulated optically thin radiative cooling module with Townsend integration #349
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
dutta-alankar
wants to merge
40
commits into
idefix-code:develop
Choose a base branch
from
dutta-alankar:master
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
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 58de06b
[FIX] Dump datatype agnostic file xdmf IO
dutta-alankar c7f83dd
Merge branch 'idefix-code:master' into master
dutta-alankar 92992da
[ADD] tabulated optically thin radiative cooling module
dutta-alankar 1357703
[FIX] additional tags for successful `cmake` compilation
dutta-alankar b07f7ff
[FIX] minor typo in documentation
dutta-alankar 70d6c40
[FIX] decrement internal energy by radiative cooling
dutta-alankar d4aa609
[FIX] cpplint edits
dutta-alankar 231951b
[DOC] radiative cooling module documentation
dutta-alankar 16a3844
[DOC] unit conversion
dutta-alankar 6f7733f
[FIX] reverse old change
dutta-alankar 391b273
Merge branch 'idefix-code:master' into master
dutta-alankar ff6dbfa
Merge branch 'master' into master
dutta-alankar f625997
Change energy calculation to energy per unit volume
dutta-alankar 7bb5ef1
Usage of runtime code units in cooling
dutta-alankar 7f8d399
documentation update
dutta-alankar c6040dc
Fix formatting of code block reference in radCooling.rst
dutta-alankar 781e56d
Fix cooling to work on GPUs
dutta-alankar b45b6c6
Fix non-existent library linking error (librt stub)
dutta-alankar 02cd06d
Handle output log directory creation and log file dumping
dutta-alankar 6cb070a
[FIX] `pre-commit` linting
dutta-alankar be83ab6
Merge pull request #1 from dutta-alankar/pr-349
dutta-alankar 0e37bc4
Fix cpplint in cooling Townsend range check
dutta-alankar d34c256
Apply suggestions from code review
dutta-alankar 34f99a8
Addressed Copilot code review
dutta-alankar 4209e26
Fix for the circular dependency issue in cooling header
dutta-alankar 9a3e4ad
Fix uninitialized warning for EoS object
dutta-alankar 1a5d395
Fix failing pytest issue
dutta-alankar 9350e90
Fix with `HAVE_ENERGY`guard on cooling
dutta-alankar 7ea869d
Apply suggestions from code review
dutta-alankar 80140a9
Added test for Cooling box
dutta-alankar ec0582c
Added test for Cooling box
dutta-alankar ccff439
`pre-commit` linting fix
dutta-alankar c245f30
Cooling box test added to CI/CD workflow
dutta-alankar d682ba9
Fix to pass simulation run tests
dutta-alankar f27975d
Fix default executable directory
dutta-alankar be68a22
Apply suggestions from code review
dutta-alankar 445fe6c
Minor rearrangement of cooling cases
dutta-alankar 0318e7b
Minor comment modification
dutta-alankar ea0a21e
Fix CoolBox testme.json for the pytest-based test runner
dutta-alankar File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,62 @@ | ||
| .. _radiativeCoolingModule: | ||
|
|
||
| Radiative Cooling module | ||
| =================== | ||
|
|
||
| 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 | ||
|
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}`). | ||
|
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). | ||
|
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 | ||
| `` | ||
|
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 | | ||
| +----------------------+-------------------------+----------------------------------------------------------------------------------------------+ | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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]; | ||
|
|
@@ -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; | ||
| } | ||
| } | ||
|
|
||
| //***************************************************************** | ||
|
|
@@ -52,7 +60,9 @@ struct Fluid_AddSourceTermsFunctor { | |
| IdefixArray1D<real> x1; | ||
| IdefixArray1D<real> x2; | ||
| IdefixArray3D<real> csIsoArr; | ||
| IdefixArray3D<real> delta_eng_cool; | ||
|
|
||
| Fluid<Phys> *hydroin; | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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; | ||
|
|
@@ -72,6 +82,9 @@ struct Fluid_AddSourceTermsFunctor { | |
| // shearing box (only with fargo&cartesian) | ||
| real sbS; | ||
|
|
||
| // Radiative cooling | ||
| bool coolingOn; | ||
|
|
||
| //***************************************************************** | ||
| // Functor Operator | ||
| //***************************************************************** | ||
|
|
@@ -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 | ||
|
dutta-alankar marked this conversation as resolved.
Outdated
|
||
| } | ||
|
dutta-alankar marked this conversation as resolved.
|
||
| } | ||
| }; | ||
|
|
||
|
|
||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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} | ||
| ) |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.