Cooling and Heating Functions of Photoionized Gas

Nickolay Y. Gnedin, Nicholas Hollon

Last updated: 20120621

Paper

Downloadable data and the reader

(A smaller, 68MB, slightly less accurate table is available upon request.)

Test driver for validation

Usage instructions

The reader is written in fortran, because it is easier to call fortran from C rather than C from fortran.

The table is loaded in the code by calling

where path is the path to the data file and mode is the flag that specifies what is returned: The table persists for the rest of the simulation and cannot be unloaded. Parameter mode also serves as an error code - it is reset to zero if the loading of the data is successfull, and is set to -1 if there is an error opening the file or the data file is corrupted. The reader uses internally the fortran unit number 97. If this conflicts with other parts of your code, it can be changed manually in frt_cf3.inc.

The reader offers a two-level interface. In the higher level interface, for each set of values for the gas temperature Tem (in K), baryon density Den≈ρ/mp (in cm-3), metallicity Z (in solar units), Lyman-Werner band H2 photo-desctruction rate PLW, and photo-ionization rates for HI (PHI), HeI (PHeI), and CVI (PCVI - all in s-1), the cooling and heating rates per baryon cfun and hfun (in erg cm3/s) can be returned by calling

and the error flag ierr is set to zero if the call is successfull. The call may be unsuccessfull if the values of the parameters are such that the table needs to be sampled outside of its current range. In that case, the absolute value of the flag returns the dimension of the table along which the out-of-bound error occur, and the sign is -1 or +1 depending on whether the lower or the upper boundary of the table is crossed. The reader then returns the value from the table at the boundary, which may be highly imprecise.

In the lower-level interface, some of the table data can be pre-cached with a call

where icache and rcache are integer and real arrays declared as The cooling and heating rates per baryon cfun and hfun as functions of gas temperature (at fixed density, metallicity, and radiation field) can then be returned by successfully calling for different values of the gas temperature Tem.

The low-level interface is intended to be used in simulation codes with sub-cycling - for each hydrodynamic step you need to call frtCFCache once per cell/particle, but then a sub-cycler can call frtCFGetLn multiple times to update the internal energy efficiently (a call to frtCFGetLn is much faster than a call to frtGetCF). Given the cooling and heating rates per baryon cfun and hfun, the change in the internal energy of the gas is

For C/C++ codes, all one needs to do is to declare these prototypes:

and in C++ they need to be wrapped into declaration wrapper.

Please e-mail Nick Gnedin is anything is not working right with this code or you find that its cache performance is poor.