singularity-rs/tests/physics_test.rs

55 lines
1.5 KiB
Rust

use singularity_rs::physics;
#[test]
fn public_bcrt_constant_is_correct() {
// 3*sqrt(3)/2 ≈ 2.598076
let expected = 1.5 * 3.0_f32.sqrt();
assert!((physics::BCRIT - expected).abs() < 1e-5);
}
#[test]
fn kerr_isco_at_zero_is_schwarzschild() {
// spin=0 → ISCO = 6M = 3 Rs (Rs=1).
let isco = physics::kerr_isco(0.0);
assert!((isco - 3.0).abs() < 1e-3, "spin=0 ISCO should be 3.0, got {}", isco);
}
#[test]
fn kerr_isco_at_extremal_is_half_rs() {
// spin=1 → ISCO = M = Rs/2 = 0.5.
let isco = physics::kerr_isco(1.0);
assert!((isco - 0.5).abs() < 1e-3, "spin=1 ISCO should be 0.5, got {}", isco);
}
#[test]
fn kerr_isco_is_monotonically_decreasing() {
let a = physics::kerr_isco(0.3);
let b = physics::kerr_isco(0.6);
let c = physics::kerr_isco(0.9);
assert!(a > b, "0.3 > 0.6: {} vs {}", a, b);
assert!(b > c, "0.6 > 0.9: {} vs {}", b, c);
}
#[test]
fn kerr_horizon_at_zero_is_rs() {
// spin=0 → r+ = Rs = 1.0.
let r = physics::kerr_horizon(0.0);
assert!((r - 1.0).abs() < 1e-3, "spin=0 horizon should be 1.0, got {}", r);
}
#[test]
fn kerr_horizon_at_extremal_is_half_rs() {
// spin=1 → r+ = M = 0.5.
let r = physics::kerr_horizon(1.0);
assert!((r - 0.5).abs() < 1e-3, "spin=1 horizon should be 0.5, got {}", r);
}
#[test]
fn kerr_horizon_is_monotonically_decreasing() {
let a = physics::kerr_horizon(0.3);
let b = physics::kerr_horizon(0.6);
let c = physics::kerr_horizon(0.9);
assert!(a > b, "0.3 > 0.6: {} vs {}", a, b);
assert!(b > c, "0.6 > 0.9: {} vs {}", b, c);
}