aienux
Aienux, the AienOS kernel: boot, scheduling, IPC and capability boundaries. Pre-alpha; host, emulator and physical evidence are labelled separately.
Brought by drakestapleton
aienux / native / kernel / ui / tests / chirp_audit.c
| 1 | /* chirp_audit.c -- measures the startup chirp (ui/chirp.c) against the numbers |
| 2 | * published for GW150914 (Abbott et al., PRL 116, 061102): the signal sweeps |
| 3 | * from 35 to 250 Hz, 8 cycles from 35 to 150 Hz in 0.2 s, source-frame masses |
| 4 | * 36 and 29 solar masses, final mass 62, final spin 0.67, redshift 0.09. The |
| 5 | * leading-order (Newtonian quadrupole) inspiral law and the Berti, Cardoso and |
| 6 | * Will (2006) fit for the least-damped ringdown mode are the physics used. |
| 7 | * Prints a plain report. Hosted only. */ |
| 8 | #include <math.h> |
| 9 | #include <stdio.h> |
| 10 | #include "../chirp.h" |
| 11 | |
| 12 | #define MSUN_S 4.925491e-6 /* G M_sun / c^3, seconds */ |
| 13 | |
| 14 | int main(void) |
| 15 | { |
| 16 | const double m1 = 36, m2 = 29, z = 0.09, mf = 62, spin = 0.67; |
| 17 | double mc = pow(m1 * m2, 0.6) / pow(m1 + m2, 0.2) * (1 + z); /* detector-frame chirp mass */ |
| 18 | double T = mc * MSUN_S; |
| 19 | printf("GW150914, detector-frame chirp mass %.2f solar masses (published: about 30)\n", mc); |
| 20 | /* leading order: time to merger tau(f) = 5/256 (pi f)^(-8/3) T^(-5/3) */ |
| 21 | double f0 = 35, f1 = 150; |
| 22 | double tau0 = 5.0 / 256 * pow(M_PI * f0, -8.0 / 3) * pow(T, -5.0 / 3); |
| 23 | double tau1 = 5.0 / 256 * pow(M_PI * f1, -8.0 / 3) * pow(T, -5.0 / 3); |
| 24 | /* gravitational-wave cycles between f0 and f1: N = (1/(32 pi^(8/3))) T^(-5/3) (f0^(-5/3) - f1^(-5/3)) */ |
| 25 | double ncyc = pow(T, -5.0 / 3) / (32 * pow(M_PI, 8.0 / 3)) * (pow(f0, -5.0 / 3) - pow(f1, -5.0 / 3)); |
| 26 | printf("physics, leading order: 35 Hz is %.3f s before the merger, 150 Hz is %.4f s before; %.3f s and %.1f cycles between " |
| 27 | "(published: about 0.2 s, about 8 cycles)\n", tau0, tau1, tau0 - tau1, ncyc); |
| 28 | double mdet = mf * (1 + z) * MSUN_S; |
| 29 | double fr = (1.5251 - 1.1568 * pow(1 - spin, 0.1292)) / (2 * M_PI * mdet); |
| 30 | double q = 0.7 + 1.4187 * pow(1 - spin, -0.4990); |
| 31 | printf("physics, ringdown of the final hole (mass %.0f, spin %.2f): %.0f Hz, quality %.2f, damping time %.1f ms " |
| 32 | "(published: the signal tops out near 250 Hz)\n", mf, spin, fr, q, 1000 * q / (M_PI * fr)); |
| 33 | printf("\nthe chirp in the kernel (ui/chirp.c), pitch by time before the merger:\n"); |
| 34 | printf(" ms before merger Hz level (of %d)\n", CK_CHIRP_PEAK); |
| 35 | uint32_t mf_frame = CK_CHIRP_RATE / 1000u * CK_NIGHT_MERGE_MS; |
| 36 | static const uint32_t before[] = {600, 500, 400, 300, 200, 100, 50, 20, 10, 5, 0}; |
| 37 | for (unsigned i = 0; i < sizeof before / sizeof *before; i++) { |
| 38 | uint32_t fr_ = mf_frame - CK_CHIRP_RATE / 1000u * before[i]; |
| 39 | printf(" %5u %5u %5u\n", before[i], ck_chirp_hz(fr_), ck_chirp_level(fr_)); |
| 40 | } |
| 41 | /* where the pitch stops rising, and how long the sweep lasts in the kernel */ |
| 42 | uint32_t cap = 0; |
| 43 | for (uint32_t f = mf_frame - CK_CHIRP_RATE / 1000u * CK_CHIRP_RISE_MS; f < mf_frame; f++) |
| 44 | if (ck_chirp_hz(f) >= CK_CHIRP_TO_HZ - 1) { |
| 45 | cap = f; |
| 46 | break; |
| 47 | } |
| 48 | printf("the pitch reaches %u Hz %.1f ms before the merger and holds; the sweep %u to %u Hz lasts %.0f ms\n", CK_CHIRP_TO_HZ, |
| 49 | (double)(mf_frame - cap) * 1000 / CK_CHIRP_RATE, CK_CHIRP_FROM_HZ, CK_CHIRP_TO_HZ, |
| 50 | (double)(cap - (mf_frame - CK_CHIRP_RATE / 1000u * CK_CHIRP_RISE_MS)) * 1000 / CK_CHIRP_RATE); |
| 51 | /* cycles of the sound over the sweep: integrate the pitch */ |
| 52 | double cyc = 0; |
| 53 | for (uint32_t f = mf_frame - CK_CHIRP_RATE / 1000u * CK_CHIRP_RISE_MS; f < cap; f++) |
| 54 | cyc += (double)ck_chirp_hz(f) / CK_CHIRP_RATE; |
| 55 | printf("cycles in the sweep: %.0f (published signal: about 8 between 35 and 150 Hz, perhaps 10 to the peak)\n", cyc); |
| 56 | /* the ring after the merger: the level falls by e each 30 ms (DECAY) */ |
| 57 | double l0 = ck_chirp_level(mf_frame), l1 = ck_chirp_level(mf_frame + CK_CHIRP_RATE / 1000u * 30); |
| 58 | printf("ring after the merger: level falls to %.2f of itself in 30 ms (time constant %.1f ms; physics: %.1f ms), held at %u Hz " |
| 59 | "(physics: %.0f Hz)\n", l1 / l0, -30.0 / log(l1 / l0), 1000 * q / (M_PI * fr), CK_CHIRP_TO_HZ, fr); |
| 60 | /* the ratios if the sound were the signal sped up uniformly */ |
| 61 | printf("pitch ratio, sound over signal: start %.2f (%u / 35), top %.2f (%u / 250); sweep length over the law's %.3f s: %.2f\n", |
| 62 | CK_CHIRP_FROM_HZ / 35.0, CK_CHIRP_FROM_HZ, CK_CHIRP_TO_HZ / 250.0, CK_CHIRP_TO_HZ, tau0, |
| 63 | (double)(mf_frame - (mf_frame - CK_CHIRP_RATE / 1000u * CK_CHIRP_RISE_MS)) / CK_CHIRP_RATE / tau0); |
| 64 | |
| 65 | /* ---- the picture: the black holes in ui/night.c, in design pixels (1920 wide) ---- */ |
| 66 | const double E = 60, shadow = 20, a0 = 270, orbit_ms = 5200, spiral_s = 6.0; /* night.c: e_full, rs_full, a0, ORBIT_MS */ |
| 67 | const double bc = sqrt(27.0) / 2; /* shadow radius of a Schwarzschild hole, in Rs */ |
| 68 | printf("\nblack-hole picture (ui/night.c): Einstein radius %.0f px, shadow radius %.0f px, ratio %.2f\n", E, shadow, E / shadow); |
| 69 | printf(" a hole's shadow is sqrt(27)/2 = %.4f Rs; the point-lens Einstein angle (source far behind) is sqrt(2 Rs / D). " |
| 70 | "A ratio of %.2f means the viewer is D = %.1f Rs from the hole (%.0f km for 36 solar masses)\n", bc, E / shadow, |
| 71 | pow(E / shadow * bc, 2) / 2, pow(E / shadow * bc, 2) / 2 * 2 * 36 * 1.476625); |
| 72 | double rs_px = shadow / bc; |
| 73 | printf(" so 1 Rs is %.2f px; the wide orbit's separation %.0f px = %.1f Rs; its Einstein radius %.1f Rs\n", rs_px, a0, a0 / rs_px, |
| 74 | E / rs_px); |
| 75 | double M = (m1 + m2) * (1 + z) * MSUN_S; /* detector-frame total mass, s */ |
| 76 | double sep_m = a0 / rs_px; /* in GM/c^2 of the pair: one hole of half the mass has Rs = GM/c^2 */ |
| 77 | double w = pow(sep_m, -1.5) / M; /* orbital angular frequency, rad/s */ |
| 78 | double fgw = w / M_PI; |
| 79 | double tau = 5.0 / 256 * pow(M_PI * fgw, -8.0 / 3) * pow(T, -5.0 / 3); |
| 80 | printf(" physics at that separation: orbital period %.2f s, gravitational-wave pitch %.2f Hz, real time to the merger %.0f s " |
| 81 | "(the picture: orbit %.2f s, %.0f s to the merger)\n", 2 * M_PI / w, fgw, tau, orbit_ms / 1000, spiral_s); |
| 82 | printf(" time compression of the inspiral in the picture: %.1f times; orbit slowed %.1f times at the start\n", tau / spiral_s, |
| 83 | orbit_ms / 1000 / (2 * M_PI / w)); |
| 84 | double mf_over = mf / ((m1 + m2) / 2); |
| 85 | printf(" merger: final mass over each initial mass (equal masses assumed) %.2f; the picture's shadow grows %.2f times " |
| 86 | "(ends at 2.0) and its Einstein radius %.3f times (physics sqrt of the mass ratio: %.3f)\n", mf_over, 2.0, 362.0 / 256, |
| 87 | sqrt(mf_over)); |
| 88 | printf(" the bend is eased to zero between 2.2 E and 4.4 E: the point-lens pull E^2/theta there is %.1f px at 2.2 E and %.1f px at " |
| 89 | "4.4 E that the picture leaves out\n", E / 2.2, E / 4.4); |
| 90 | return 0; |
| 91 | } |