blackholesfactory 0.0.3

Black hole factory — create and simulate stellar, intermediate-mass, and supermassive black holes with full Kerr physics
Documentation
#[derive(Debug, Clone, Copy, PartialEq)]
pub struct BlackHoleShaderData {
    pub spin_parameter: f64,
    pub mass_solar_masses: f64,
    pub accretion_rate: f64,
    pub inclination_rad: f64,
}

impl BlackHoleShaderData {
    pub fn from_params(mass_solar: f64, spin: f64, inclination: f64) -> Self {
        Self {
            spin_parameter: spin,
            mass_solar_masses: mass_solar,
            accretion_rate: 0.01,
            inclination_rad: inclination,
        }
    }

    pub fn schwarzschild_radius_m(&self) -> f64 {
        2.0 * 6.674e-11 * self.mass_solar_masses * 1.989e30 / (2.998e8 * 2.998e8)
    }

    pub fn isco_radius_m(&self) -> f64 {
        let a = self.spin_parameter;
        let rs = self.schwarzschild_radius_m();
        if a.abs() < 1e-12 {
            return 3.0 * rs;
        }
        let z1 = 1.0
            + (1.0 - a * a).powf(1.0 / 3.0)
                * ((1.0 + a).powf(1.0 / 3.0) + (1.0 - a).powf(1.0 / 3.0));
        let z2 = (3.0 * a * a + z1 * z1).sqrt();
        let r_g = rs / 2.0;
        r_g * (3.0 + z2 - ((3.0 - z1) * (3.0 + z1 + 2.0 * z2)).sqrt())
    }

    pub fn photon_sphere_radius_m(&self) -> f64 {
        1.5 * self.schwarzschild_radius_m()
    }

    pub fn gravitational_redshift_at(&self, radius_m: f64) -> f64 {
        let rs = self.schwarzschild_radius_m();
        1.0 / (1.0 - rs / radius_m).sqrt() - 1.0
    }
}