cosmicrays / hermes

HERMES is a publicly available computational framework for the line of sight integration over galactic radiative processes which creates sky maps in the HEALPix-compatibile format.
GNU General Public License v3.0
22 stars 9 forks source link

New integrator: Gamma-ray absorption on CMB only #20

Closed carmeloevoli closed 2 years ago

carmeloevoli commented 2 years ago

In order to speed up the pi0 integrator including gamma-ray absorption we should consider the case in which CMB is the only photon field. Being spatially uniform it simplifies the runtime calculation of the optical depth.

adundovi commented 2 years ago

Should we do this as a new integrator, derived from the current pi0?

carmeloevoli commented 2 years ago

My notes about the calculation of the absorption coefficient for CMB can be found here

The new integrator is very similar to pi0, just adding a function which computes K(E) and using it following my equation (7).

Notice however that my equation for K(E) (equation 4) looks different than that implemented now in HERMES.

carmeloevoli commented 2 years ago

I am working on a branch to implement CMB absorption. Notice that I had to modify the BreitWheeler class with the new expression. Now I don't know how to write this: https://github.com/cosmicrays/hermes/blob/79c19ef652d609b32139084a4a0a483c5ffb17f6/src/integrators/PiZeroCmbAbsorptionIntegrator.cpp#L9

adundovi commented 2 years ago

std::expm1(static_cast<double>(eps / kT)) if you want to override HERMES units...

carmeloevoli commented 2 years ago

It is a ratio of energies, shouldn't be a "QNumber"?

adundovi commented 2 years ago

Yes, although QNumber is dimensionless, it is still a HERMES unit, and a std function such as expm1 will not accept it without casting it to double.

adundovi commented 2 years ago

eps / kT is QNumber and a compiler already knows that, you don't need to cast a dimensionless expression to QNumber by hand, but from QNumber to ordinary double or float, you have to.

carmeloevoli commented 2 years ago

thanks, in fact I was trying to use this: https://github.com/cosmicrays/hermes/blob/51d8e4b6ff4943838c17c0005d5a75c5909b9762/include/hermes/units/UnitsFunctions.h#L18 but of course it doesn't work if I use std

carmeloevoli commented 2 years ago

I am thinking that it is better to have in the public code the PiZeroAbsorptionIntegrator having only CMB as photon field. We will work separately on a new integrator with a generic photon field but at the moment is way too slow.

Another issue. I don't understand why PiZeroAbsorptionIntegrator is not derived from PiZeroIntegrator with the override of just 1 or 2 functions. In this way, if we change something on PiZeroIntegrator automatically gets inherited by PiZeroAbsorptionIntegrator.

In the branch, I'm working on this idea.

carmeloevoli commented 2 years ago

The PiZeroAbsorptionIntegrator is now working in C++. We should modify python/integrators.cpp to have it also in python.

carmeloevoli commented 2 years ago

It is as fast as PiZeroIntegrator. I had a minimal approach by implementing only the few functions that are different from PiZeroIntegrator. I think that we should keep this Integrator in HERMES and leaving the absorption on a generic photon field to future updates.

carmeloevoli commented 2 years ago

Branch merged and CI working. That's all folks!