fuzzyworld

nordic-skating / files / test / strength.test.ts

strength.test.ts

Blame: the commit that last changed each line · file · history

6216d5cb 2026-10-09 Pavel Safronov1import { describe, expect, it } from 'vitest'
2import { singingFrequency } from '../src/ice/acoustics.js'
3import { BREAKING_THICKNESS, CRACKING_THICKNESS, SAFE_THICKNESS, bearingThickness } from '../src/ice/strength.js'
a8fd3f13 2026-10-10 Pavel Safronov4import { MAX_THICKNESS, MIN_THICKNESS } from '../src/world/lake.js'
6216d5cb 2026-10-09 Pavel Safronov5
6describe('ice strength', () => {
7 it('needs twice the ice for four times the load', () => {
8 expect(bearingThickness(320, 7) / bearingThickness(80, 7)).toBeCloseTo(2, 10)
9 })
10
11 it('gives a skater zones of 2.2, 3.4 and 4.8 cm', () => {
12 expect(BREAKING_THICKNESS * 100).toBeCloseTo(2.2, 1)
13 expect(CRACKING_THICKNESS * 100).toBeCloseTo(3.4, 1)
14 expect(SAFE_THICKNESS * 100).toBeCloseTo(4.8, 1)
15 })
16
a8fd3f13 2026-10-10 Pavel Safronov17 it('puts the film\'s ice in the zone that sings', () => {
18 expect(0.041).toBeGreaterThan(CRACKING_THICKNESS)
19 expect(0.041).toBeLessThan(SAFE_THICKNESS)
6216d5cb 2026-10-09 Pavel Safronov20 })
21
22 it('has every zone somewhere on the lake, and a pitch that tells them apart', () => {
23 expect(MIN_THICKNESS).toBeLessThan(BREAKING_THICKNESS)
24 expect(MAX_THICKNESS).toBeGreaterThan(SAFE_THICKNESS)
25 // Breaking ice sings above 1.4 kHz, safe ice below 640 Hz: more than an octave apart.
26 expect(singingFrequency(BREAKING_THICKNESS)).toBeGreaterThan(1390)
27 expect(singingFrequency(SAFE_THICKNESS)).toBeLessThan(640)
28 })
29})