fuzzyworld

tower / files / src / canon / atmosphere.ts

atmosphere.ts

1.5 KB · history · blame

1/**
2 * Tower's atmosphere. See design.md §1.5 and §1.8.
3 *
4 * Gravity falls linearly to zero on the axis, so the air is far deeper than Earth's
5 * and the density profile is set by the rotational potential rather than by a
6 * constant g. This is what makes a sightline across the interior clearer than one
7 * of the same length along the floor — the defining optical fact about Tower.
8 */
9import {
10 OMEGA_RAD_S, RADIUS_M, SPECIFIC_GAS_CONSTANT, TEMPERATURE_K,
11 FLOOR_PRESSURE_PA, RAYLEIGH_FLOOR_PER_M,
12} from './constants.js'
13
14/** Rotational potential per unit mass between the floor and radius `s`. */
15export function potentialAtRadius(s: number): number {
16 return (OMEGA_RAD_S ** 2 * (RADIUS_M ** 2 - s ** 2)) / 2
17}
18
19/** Air density at radius `s` from the axis, relative to floor density. */
20export function relativeDensityAtRadius(s: number): number {
21 return Math.exp(-potentialAtRadius(s) / (SPECIFIC_GAS_CONSTANT * TEMPERATURE_K))
22}
23
24/** Absolute pressure (Pa) at radius `s`. 5.2 kPa on the axis — thin, but real air. */
25export function pressureAtRadius(s: number): number {
26 return FLOOR_PRESSURE_PA * relativeDensityAtRadius(s)
27}
28
29export const relativeDensityAtHeight = (h: number) => relativeDensityAtRadius(RADIUS_M - h)
30export const pressureAtHeight = (h: number) => pressureAtRadius(RADIUS_M - h)
31
32/** Rayleigh extinction coefficient (per metre) at radius `s`. */
33export function extinctionAtRadius(s: number): number {
34 return RAYLEIGH_FLOOR_PER_M * relativeDensityAtRadius(s)
35}