"""A ladder of lengths from a proton to the observable universe, in powers of ten.""" import math import sys from pathlib import Path import scipy.constants as sc sys.path.insert(0, str(Path(__file__).resolve().parents[1])) from labkit import Q, const, versions # noqa: E402 print("computed:", versions()) print() light_year = (const.c * Q(1, "julian_year")).to("m") rungs = [ ("proton (charge diameter)", 2 * sc.physical_constants["proton rms charge radius"][0], "CODATA 2022"), ("hydrogen atom (2 x Bohr radius)", 2 * sc.physical_constants["Bohr radius"][0], "CODATA 2022"), ("red blood cell", 7.5e-6, "typical diameter"), ("human height", 1.7, "typical adult"), ("Earth (mean diameter)", 12_742e3, "IUGG mean radius 6,371 km"), ("Earth to Sun (1 au)", 149_597_870_700.0, "IAU 2012, exact"), ("one light-year", light_year.magnitude, "c x 365.25 days"), ("Milky Way (disc diameter)", 100_000 * light_year.magnitude, "about 100,000 light-years"), ("observable universe (diameter)", 93e9 * light_year.magnitude, "about 93 billion light-years"), ] print(" length metres power of ten") for name, metres, note in rungs: exponent = math.floor(math.log10(metres) + 0.5) print(f" {name:<32} {metres:>12.3e} 10^{exponent:<4} ({note})") span = math.log10(rungs[-1][1] / rungs[0][1]) print() print(f"From the proton to the edge of what we can see: {span:.1f} powers of ten")