use crate::constants::*;
pub fn weak_interaction_rate(temp_k: f64) -> f64 {
let t_mev = K_B * temp_k * J_TO_EV * 1e-6;
let rate = 1.13 * t_mev.powi(5);
rate
}
pub fn hubble_rate_radiation(temp_k: f64) -> f64 {
let g_star = 10.75;
let rho = (std::f64::consts::PI.powi(2) / 30.0) * g_star
* K_B.powi(4) * temp_k.powi(4)
/ (HBAR.powi(3) * C.powi(5));
let hubble = ((8.0 * std::f64::consts::PI * G * rho) / 3.0).sqrt();
hubble
}
pub fn freezeout_temperature() -> f64 {
let t_freeze_mev = 0.7; let t_freeze_k = t_freeze_mev * 1e6 / (K_B * J_TO_EV);
t_freeze_k
}
pub fn freezeout_np_ratio() -> f64 {
let t_freeze = freezeout_temperature();
let delta_m = (M_N - M_P) * C * C; let delta_m_mev = delta_m * J_TO_EV * 1e-6; let t_mev = K_B * t_freeze * J_TO_EV * 1e-6;
(-delta_m_mev / t_mev).exp()
}
pub fn estimate_yp_from_freezeout() -> f64 {
let np_freeze = freezeout_np_ratio();
2.0 * np_freeze / (1.0 + np_freeze)
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn test_freezeout_temperature() {
let t_freeze = freezeout_temperature();
assert!(t_freeze > 5e9 && t_freeze < 2e10);
}
#[test]
fn test_freezeout_np_ratio() {
let np = freezeout_np_ratio();
assert!(np > 0.1 && np < 0.2);
}
#[test]
fn test_yp_estimate() {
let yp = estimate_yp_from_freezeout();
assert!(yp > 0.20 && yp < 0.30);
}
}