darkmatter 0.0.2

Dark matter simulation engine — gravitational fields, particle dynamics, halo stability, and cosmological constants
Documentation
use crate::constants::physical::{C, HBAR};
use std::f64::consts::PI;

#[derive(Clone, Copy, Debug, PartialEq)]
pub struct Axion {
    pub mass_ev: f64,
    pub coupling_photon: f64,
    pub decay_constant_gev: f64,
}

impl Axion {
    pub fn mass_kg(&self) -> f64 {
        self.mass_ev * 1.783e-36
    }

    pub fn compton_wavelength(&self) -> f64 {
        HBAR / (self.mass_kg() * C)
    }

    pub fn de_broglie_wavelength(&self, v: f64) -> f64 {
        HBAR / (self.mass_kg() * v)
    }

    pub fn lifetime_seconds(&self) -> f64 {
        64.0 * PI / (self.coupling_photon * self.coupling_photon * self.mass_ev.powi(3) * 1.519e15)
    }

    pub fn oscillation_temperature_gev(&self) -> f64 {
        1.0 * (self.mass_ev * 1e-9).powf(0.5)
    }

    pub fn qcd_axion_mass_ev(fa_gev: f64) -> f64 {
        5.7e-6 * (1e12 / fa_gev)
    }

    pub fn qcd_axion_coupling(fa_gev: f64) -> f64 {
        let alpha_em = 1.0 / 137.0;
        alpha_em / (2.0 * PI * fa_gev) * 1.92
    }

    pub fn jeans_scale_kpc(&self) -> f64 {
        let m22 = self.mass_ev / 1e-22;
        55.0 / m22.sqrt()
    }
}

pub fn misalignment_relic_density(fa_gev: f64, theta_initial: f64) -> f64 {
    0.12 * (fa_gev / 1e12).powf(1.19) * theta_initial * theta_initial
}

pub fn axion_dark_matter_mass_ev(theta_initial: f64) -> f64 {
    let fa = 1e12 * (0.12 / (theta_initial * theta_initial)).powf(1.0 / 1.19);
    Axion::qcd_axion_mass_ev(fa)
}

pub fn haloscope_power_watts(
    b_field_tesla: f64,
    volume_m3: f64,
    quality_factor: f64,
    coupling_photon: f64,
    mass_ev: f64,
    rho_local_gev_cm3: f64,
) -> f64 {
    let rho_si = rho_local_gev_cm3 * 1.783e-27 * 1e6;
    let omega = mass_ev * 1.519e15;
    coupling_photon
        * coupling_photon
        * b_field_tesla
        * b_field_tesla
        * volume_m3
        * quality_factor
        * rho_si
        / (mass_ev * 1.783e-36)
        * HBAR
        * omega
}

pub fn fuzzy_dm_soliton_radius_kpc(mass_ev: f64, halo_mass_solar: f64) -> f64 {
    let m22 = mass_ev / 1e-22;
    let m9 = halo_mass_solar / 1e9;
    1.6 / m22 / m9.powf(1.0 / 3.0)
}

pub fn fuzzy_dm_soliton_mass(mass_ev: f64, halo_mass_solar: f64) -> f64 {
    let m22 = mass_ev / 1e-22;
    let m_halo_12 = halo_mass_solar / 1e12;
    1.4e9 / m22 * m_halo_12.powf(1.0 / 3.0)
}

pub fn axion_star_max_mass(fa_gev: f64, mass_ev: f64) -> f64 {
    let mpl_gev = 1.22e19;
    let m_a_gev = mass_ev * 1e-9;
    10.0 * mpl_gev * mpl_gev * fa_gev / (m_a_gev * m_a_gev * m_a_gev) * 1.783e-27 / 1.989e30
}

pub fn cavity_frequency_ghz(mass_ev: f64) -> f64 {
    mass_ev * 2.418e14 * 1e-9
}