contraction_agama.py
def contract_density_fit( density_DM, density_bar, mass_DM, mass_bar, f_bar=0.157 ):
    """ Returns the contracted DM density profile given the 'uncontracted' density and that of the baryonic distribution.
    It uses the differential (d/dr) form of Eq. (11) from Cautun et al (2020).
    
    WARNING: This function is based on a fit to the iterative calculated result of the 'contract_enclosed_mass' and works best when the
    baryonic fraction is close to the Planck (2015) value, f_bar=0.157. Do not use it if that is not the case.
   
   Args:
      density_DM    : array of DM densities. 
                          It corresponds to '(1-baryon_fraction) * density in
                          DMO (dark matter only) simulations'.
      density_bar   : array of baryonic densities.
      mass_DM       : enclosed mass in the DM component in the absence of baryons. 
                          It corresponds to '(1-baryon_fraction) * enclosed mass in
                          DMO (dark matter only) simulations'.
      mass_bar      : enclosed baryonic mass for which to calculate the DM profile.
      f_bar         : optional cosmic baryonic fraction.
   Returns:
      Array of 'contracted' DM densities.
   """
        
    eta_bar = mass_bar / mass_DM * (1.-f_bar) / f_bar  # the last two terms account for transforming the DM mass into the corresponding baryonic mass in DMO simulations
    first_factor = 0.45 + 0.41 * (eta_bar + 0.98)**0.53
    temp         = density_bar - eta_bar * density_DM * f_bar / (1.-f_bar)
    const_term   = 0.41 * 0.53 * (eta_bar + 0.98)**(0.53-1.) * (1.-f_bar) / f_bar * temp
    
    return density_DM * first_factor + const_term
 Returns the contracted DM density profile given the 'uncontracted' density and that of the baryonic distribution.
    It uses the differential (d/dr) form of Eq. (11) from Cautun et al (2020).
    
    WARNING: This function is based on a fit to the iterative calculated result of the 'contract_enclosed_mass' and works best when the
    baryonic fraction is close to the Planck (2015) value, f_bar=0.157. Do not use it if that is not the case.
   
   Args:
      density_DM    : array of DM densities. 
                          It corresponds to '(1-baryon_fraction) * density in
                          DMO (dark matter only) simulations'.
      density_bar   : array of baryonic densities.
      mass_DM       : enclosed mass in the DM component in the absence of baryons. 
                          It corresponds to '(1-baryon_fraction) * enclosed mass in
                          DMO (dark matter only) simulations'.
      mass_bar      : enclosed baryonic mass for which to calculate the DM profile.
      f_bar         : optional cosmic baryonic fraction.
   Returns:
      Array of 'contracted' DM densities.
   
Returns the contracted DM density profile given the 'uncontracted' density and that of the baryonic distribution.
It uses the differential (d/dr) form of Eq.

This function is based on a fit to the iterative calculated result of the 'contract_enclosed_mass' and works best when the
baryonic fraction is close to the Planck (2015) value, f_bar=0.157. Do not use it if that is not the case.
Returns the contracted DM density profile given the ' uncontracted ' density and that of the baryonic distribution . It uses the differential ( d / dr ) form of Eq . This function is based on a fit to the iterative calculated result of the ' contract_enclosed_mass ' and works best when the baryonic fraction is close to the Planck ( 2015 ) value f_bar = 0 . 157 . Do not use it if that is not the case .
def contract_density_fit( density_DM, density_bar, mass_DM, mass_bar, f_bar=0.157 ):
    eta_bar = mass_bar / mass_DM * (1.-f_bar) / f_bar  
    first_factor = 0.45 + 0.41 * (eta_bar + 0.98)**0.53
    temp         = density_bar - eta_bar * density_DM * f_bar / (1.-f_bar)
    const_term   = 0.41 * 0.53 * (eta_bar + 0.98)**(0.53-1.) * (1.-f_bar) / f_bar * temp
    return density_DM * first_factor + const_term
def contract_density_fit ( density_DM , density_bar , mass_DM , mass_bar , f_bar = 0.157 ) : eta_bar = mass_bar / mass_DM * ( 1. - f_bar ) / f_bar first_factor = 0.45 + 0.41 * ( eta_bar + 0.98 ) ** 0.53 temp = density_bar - eta_bar * density_DM * f_bar / ( 1. - f_bar ) const_term = 0.41 * 0.53 * ( eta_bar + 0.98 ) ** ( 0.53 - 1. ) * ( 1. - f_bar ) / f_bar * temp return density_DM * first_factor + const_term
Returns the contracted DM density profile given the 'uncontracted' density and that of the baryonic distribution.
Returns the contracted DM density profile given the ' uncontracted ' density and that of the baryonic distribution .
""" Returns the contracted DM density profile given the 'uncontracted' density and that of the baryonic distribution.
    It uses the differential (d/dr) form of Eq. (11) from Cautun et al (2020).
    
    WARNING: This function is based on a fit to the iterative calculated result of the 'contract_enclosed_mass' and works best when the
    baryonic fraction is close to the Planck (2015) value, f_bar=0.157. Do not use it if that is not the case.
   
   Args:
      density_DM    : array of DM densities. 
                          It corresponds to '(1-baryon_fraction) * density in
                          DMO (dark matter only) simulations'.
      density_bar   : array of baryonic densities.
      mass_DM       : enclosed mass in the DM component in the absence of baryons. 
                          It corresponds to '(1-baryon_fraction) * enclosed mass in
                          DMO (dark matter only) simulations'.
      mass_bar      : enclosed baryonic mass for which to calculate the DM profile.
      f_bar         : optional cosmic baryonic fraction.
   Returns:
      Array of 'contracted' DM densities.
   """ # the last two terms account for transforming the DM mass into the corresponding baryonic mass in DMO simulations
Array of 'contracted' DM densities.
Array of ' contracted ' DM densities .
density_DM
density_bar
mass_DM
mass_bar
f_bar
density_DM    
array of DM densities.
It corresponds to '(1-baryon_fraction) * density in
DMO (dark matter only) simulations'.
array of DM densities . It corresponds to ' ( 1 - baryon_fraction ) * density in DMO ( dark matter only ) simulations ' .
density_bar   
array of baryonic densities.
array of baryonic densities .
mass_DM       
enclosed mass in the DM component in the absence of baryons.
It corresponds to '(1-baryon_fraction) * enclosed mass in
DMO (dark matter only) simulations'.
enclosed mass in the DM component in the absence of baryons . It corresponds to ' ( 1 - baryon_fraction ) * enclosed mass in DMO ( dark matter only ) simulations ' .
mass_bar      
enclosed baryonic mass for which to calculate the DM profile.
enclosed baryonic mass for which to calculate the DM profile .
f_bar         
optional cosmic baryonic fraction.
optional cosmic baryonic fraction .