code wiki / (root) / nx_soda_carbonation_test.nx

nx_soda_carbonation_test.nx source

↩ module page · 64 lines · 2920 B

1// nx_soda_carbonation_test.nx -- smoke for nx_soda_carbonation (craft-soda C0). 2// 3// Proves Henry's-law carbonation + the MEASURED EXCEEDS behind "carbonation 4// without heavy equipment": 5// - k_H falls as water warms; anchors exact (1-3) 6// - COLD HOLDS MORE FIZZ: 4C dissolves more CO2 than 25C at one pressure (4) 7// - volumes unit + Henry round-trip (5-6) 8// - NO HEAVY EQUIPMENT: 4 volumes at 4C is nanobubble-feasible (<=5 bar) (7) 9// but the SAME target at 25C needs a saturator (>5 bar) -- the exceed (8) 10// - NANOBUBBLE 5x faster + 5-min target (9-10) 11// - carbonation is acid: more CO2 -> more [H+] -> lower pH, soda range (11-15) 12// Exit code = failed assertion number; 0 = all pass. 13 14import "nx_syscalls.nx" 15import "nx_soda_carbonation.nx" 16 17func main() -> i64 { 18 // --- k_H(T): cold water holds more dissolved CO2 (falls as it warms) --- 19 if soda_kh(4) <= soda_kh(25) { return 1 } 20 if soda_kh(25) != 1450 { return 2 } 21 if soda_kh(0) != 3350 { return 3 } 22 23 // --- COLD HOLDS MORE FIZZ: same pressure, colder water dissolves more --- 24 let cold: i64 = soda_co2_mg_per_l(4, 3000) 25 let warm: i64 = soda_co2_mg_per_l(25, 3000) 26 if cold <= warm { return 4 } 27 28 // --- volumes unit: 1960 mg/L == exactly 1.000 volume --- 29 if soda_volumes_milli(1960) != 1000 { return 5 } 30 31 // --- Henry round-trip: solve pressure for 4.0 vol @4C, back to volumes --- 32 let p4: i64 = soda_required_pressure_mbar(4000, 4) 33 let back: i64 = soda_volumes_milli(soda_co2_mg_per_l(4, p4)) 34 var dd: i64 = back - 4000 35 if dd < 0 { dd = 0 - dd } 36 if dd > 20 { return 6 } 37 38 // --- NO HEAVY EQUIPMENT: 4 vol @4C sits inside the 2-5 bar nanobubble 39 // envelope (a compact venturi loop, not an industrial saturator) --- 40 if soda_nanobubble_feasible(p4) != 1 { return 7 } 41 42 // --- the EXCEED a fixed carbonation chart misses: the SAME 4 vol target 43 // at 25C needs >5 bar (heavy equipment); cold is what makes the 44 // low-pressure, no-heavy-gear approach feasible --- 45 if soda_nanobubble_feasible(soda_required_pressure_mbar(4000, 25)) != 0 { return 8 } 46 47 // --- NANOBUBBLE kinetics: exactly 5x faster than sparging --- 48 if soda_carbonation_time_s(SODA_METHOD_SPARGE, 4000) != soda_carbonation_time_s(SODA_METHOD_NANOBUBBLE, 4000) * 5 { return 9 } 49 if soda_carbonation_time_s(SODA_METHOD_NANOBUBBLE, 4000) != 300 { return 10 } 50 51 // --- carbonation is a SOUR lever: more dissolved CO2 -> more [H+] --- 52 if soda_hplus_um(8000) <= soda_hplus_um(4000) { return 11 } 53 if soda_hplus_um(0) != 0 { return 12 } 54 55 // --- pH lands in the measured soda range (3.4-4.0) for 4 volumes --- 56 let ph: i64 = soda_ph_milli(7840) 57 if ph < 3400 { return 13 } 58 if ph > 4000 { return 14 } 59 60 // --- more carbonation -> lower pH (stronger fizz tastes tarter) --- 61 if soda_ph_milli(8000) >= soda_ph_milli(3000) { return 15 } 62 63 return 0 64}