GW_back
GW_back.py is a Python routine that contains functions relevant for cosmological stochastic gravitational wave backgrounds (SGWB).
Adapted from the original cosmoGW in GW_turbulence (https://github.com/AlbertoRoper/GW_turbulence), created in Dec. 2021
Currently part of the cosmoGW code:
https://github.com/cosmoGW/cosmoGW/ https://github.com/cosmoGW/cosmoGW/blob/main/src/cosmoGW/GW_back.py
Note
For full documentation, visit Read the Docs.
To use it, first install cosmoGW:
pip install cosmoGW
Dates
Created: 01/12/2021 (GW_turbulence)
Updated: 21/08/2025 (release cosmoGW 1.0: https://pypi.org/project/cosmoGW)
References
[Maggiore:1999vm]: M. Maggiore, “Gravitational wave experiments andearly universe cosmology,” Phys.Rept. 331 (2000) 283-367,`arXiv:gr-qc/9909001 <https://arxiv.org/abs/gr-qc/9909001>`_.
[RoperPol:2018sap]: A. Roper Pol, A. Brandenburg, T. Kahniashvili,A. Kosowsky, S. Mandal, “The timestep constraint in solving thegravitational wave equations sourced by hydromagnetic turbulence,”Geophys. Astrophys. Fluid Dynamics 114, 1, 130 (2020),`arXiv:1807.05479 <https://arxiv.org/abs/1807.05479>`_.
[RoperPol:2021xnd]: A. Roper Pol, S. Mandal, A. Brandenburg,T. Kahniashvili, “Polarization of gravitational waves from helicalMHD turbulent sources,” JCAP 04 (2022), 019,`arXiv:2107.05356 <https://arxiv.org/abs/2107.05356>`_.
[RoperPol:2022iel]: A. Roper Pol, C. Caprini, A. Neronov, D. Semikoz,”The gravitational wave signal from primordial magnetic fields in thePulsar Timing Array frequency band,” Phys. Rev. D 105, 123502 (2022),`arXiv:2201.05630 <https://arxiv.org/abs/2201.05630>`_.
- cosmoGW.GW_back.Omega_A(A=1.0, fref=0, beta=0, h0=1.0)
Returns the amplitude of the SGWB energy density spectrum, expressed as a power law (PL), given the amplitude A of the characteristic strain, also expressed as a PL.
A is always given for the reference frequency of \(f_{\rm yr} = 1/(1 {\rm yr})\) and is used in the common process reported by PTA collaborations.
The GW energy density and characteristic amplitude can be expressed as:
\[\Omega_{\rm GW} = \Omega_{\rm ref} * (f/f_{\rm ref})^\beta h_c = A * (f/f_{\rm yr})^\alpha\]Parameters
- Afloat
Amplitude of the characteristic strain PL using 1yr as the reference frequency.
- freffloat
Reference frequency used for the PL expression of the GW background given in units of frequency (default 1 yr^(-1)).
- betafloat
Slope of the PL.
- h0float
Parameterizes the uncertainties (Hubble tension) in the value of the Hubble rate (default 1).
Returns
- Omreffloat
Amplitude of the GW energy density PL.
Reference
RoperPol:2022iel, eq. 44
- cosmoGW.GW_back.fac_hc_OmGW(d=1, h0=1.0)
Returns the factor to transform the strain function \(h_c (f)\) to the GW energy density \(\Omega_{\rm GW}(f)\) away from the source.
Parameters
- dint
Option to give the factor to convert from energy density to strain if set to -1 (default 1).
- h0float
Parameterizes the uncertainties (Hubble tension) in the value of the Hubble rate (default 1).
Returns
- facfloat
Factor to convert from the strain function hc(f) to the GW energy density OmGW(f) in frequency units (Hz).
Reference
Maggiore:1999vm, eq. 17
- cosmoGW.GW_back.hc_OmGW(f, OmGW, d=1, h0=1.0)
Transforms the GW energy density \(\Omega_{\rm GW}(f)\) to the characteristic strain spectrum function \(h_c(f)\) away from the source.
Note
Careful with the different notations (can be confusing!!), see below.
\[\Omega_{\rm GW}(f) = \frac{2 \pi^2}{3 H_0^2} f^2 h_c^2(f)\]Parameters
- farray_like
Frequency array (in units of frequency, e.g. Hz).
- OmGWarray_like
GW energy density spectrum OmGW(f).
- dint
Option to convert from energy density to strain if set to -1 (default 1).
- h0float
Parameterizes the uncertainties (Hubble tension) in the value of the Hubble rate (default 1).
Returns
- hcarray_like
Strain spectrum.
References
Maggiore:1999vm, eq. 17
Maggiore defines \(S_h(f)\) in eq. B12 such that
\[h_c^2(f) = 2 f S_h^{\mathrm{Mag}}(f)\]Note that this is different than the notation in RoperPol:2021xnd, eq. B.18, used in interferometry.py, where
\[h_c^2(f) = f S_h^{\pm}(f)\]such that
\[S_h^{\pm}(f) = 2 S_h^{\mathrm{Mag}}(f)\]Hence, from \(h_c^2(f)\) we can compute
\[S_h^{\mathrm{Mag}}(f) = \frac{h_c^2(f)}{2f} \qquad S_h^{\pm}(f) = \frac{h_c^2(f)}{f}\]
- cosmoGW.GW_back.hc_Sf(f, Sf, d=1)
Transforms the power spectral density \(S_f(f)\) to the characteristic strain spectrum function \(h_c(f)\).
Parameters
- farray_like
Frequency array (in units of frequency, e.g. Hz).
- Sfarray_like
Power spectral density \(S_f(f)\) (in units of 1/Hz^3).
- dint
Option to convert from strain to power spectral density if set to -1 (default 1).
Returns
- hcarray_like
Strain spectrum.
Reference
RoperPol:2022iel, eq. 42
- cosmoGW.GW_back.shift_OmGW_today(k, OmGW, g=100, gS=0.0, T=<Quantity 100. GeV>, d=1, h0=1.0, kk=True, Neff=3)
Shifts the GW energy density spectrum from the time of generation to the present time. Assumes the time of generation is within the radiation dominated era. Test.
Parameters
- karray_like
Array of wave numbers (normalized by the Hubble scale).
- OmGWarray_like
GW energy density spectrum per logarithmic interval (normalized by the radiation energy density).
- gfloat
Number of relativistic degrees of freedom (dof) at the time of generation (default is 100).
- gSfloat
Number of adiabatic dof (default is gS = g).
- Tfloat
Temperature scale at the time of generation in energy units (convertible to MeV) (default is 100 GeV).
- dint
Option to reverse the transformation if set to -1 (default 1).
- h0float
Parameterizes the uncertainties (Hubble tension) in the value of the Hubble rate (default 1).
- kkbool
If True, kf corresponds to k_* HH_*, otherwise refers to the length in terms of the Hubble size \({\cal H}_\ast l_\ast = 2 \pi {\cal H}_\ast/k_\ast\).
- Nefffloat
Effective number of neutrino species (default is 3).
Returns
- farray_like
Shifted wave number to frequency as a present time observable (in Hz).
- OmGW0array_like
Shifted spectrum OmGW to present time.
Reference
See functions shift_onlyOmGW_today and shift_frequency_today.
- cosmoGW.GW_back.shift_frequency_today(k, g=100, gS=0.0, T=<Quantity 100. GeV>, d=1, kk=True, Neff=3)
Transforms the normalized wave number at the time of generation by the Hubble rate \(H_\ast\) to the present time frequency.
Parameters
- karray_like
Array of wave numbers (normalized by the Hubble scale).
- gfloat
Number of relativistic degrees of freedom (dof) at the time of generation (default is 100).
- gSfloat
Number of adiabatic dof (default is gS = g).
- Tfloat
Temperature scale at the time of generation in energy units (convertible to MeV) (default is 100 GeV).
- dint
Option to reverse the transformation if set to -1 (default 1).
- kkbool
If True, kf corresponds to \(k_\ast {\cal H}_\ast\), otherwise refers to the length in terms of the Hubble size \({\cal H}_\ast l_\ast = 2 \pi {\cal H}_\ast/k_\ast\).
- Nefffloat
Effective number of neutrino species (default is 3).
Returns
- farray_like
Shifted wave number to frequency as a present time observable (in Hz).
Reference
RoperPol:2022iel, eq. 32
- cosmoGW.GW_back.shift_hc_today(k, hc, g=100, gS=0.0, T=<Quantity 100. GeV>, d=1, kk=True, Neff=3)
Shifts the characteristic amplitude spectrum from the time of generation to the present time.
Assumes the time of generation is within the radiation dominated era.
Parameters
- karray_like
Array of wave numbers (normalized by the Hubble scale).
- hcarray_like
Spectrum of GW characteristic amplitude per logarithmic interval.
- gfloat
Number of relativistic degrees of freedom (dof) at the time of generation (default is 100).
- gSfloat
Number of adiabatic dof (default is gS = g).
- Tfloat
Temperature scale at the time of generation in energy units (convertible to MeV) (default is 100 GeV).
- dint
Option to reverse the transformation if set to -1 (default 1).
- kkbool
If True, kf corresponds to \(k_* \mathcal{H}_*\). Otherwise, refers to the length in terms of the Hubble size, i.e. \(\mathcal{H}_* l_* = 2\pi {\cal H}_\ast/k_*\).
- Nefffloat
Effective number of neutrino species (default is 3).
Returns
- farray_like
Shifted wave number to frequency as a present time observable (in Hz).
- hc0array_like
Shifted \(h_c(f)\) spectrum to present time.
Reference
RoperPol:2018sap, eq. B.12
- cosmoGW.GW_back.shift_onlyOmGW_today(OmGW, g=100, gS=0.0, d=1, h0=1.0, Neff=3)
Shifts the GW energy density spectrum from the time of generation to the present time (assumed to be within the RD era).
Parameters
- OmGWarray_like
GW energy density spectrum per logarithmic interval (normalized by the radiation energy density).
- gfloat
Number of relativistic degrees of freedom (dof) at the time of generation (default is 100).
- gSfloat
Number of adiabatic dof (default is gS = g).
- dint
Option to reverse the transformation if set to -1 (default 1).
- h0float
Parameterizes the uncertainties (Hubble tension) in the value of the Hubble rate (default 1).
- Nefffloat
Effective number of neutrino species (default is 3).
Returns
- OmGW0array_like
Shifted spectrum OmGW to present time.
Reference
RoperPol:2022iel, eq. 27