nx_water_awg_test.nx source
↩ module page · 33 lines · 1745 B
1// nx_water_awg_test.nx -- smoke for nx_water_awg. Proves psychrometric
2// condensation yield/energy AND the harvester-technology recommender across
3// climates (humid->condensation, dry->sorbent, moderate->passive capillary).
4// Exit code = failed assertion number; 0 = all pass.
5
6import "nx_syscalls.nx"
7import "nx_water_awg.nx"
8
9func main() -> i64 {
10 // --- saturation vapor density table ---
11 if wa_sat_vapor_density_x10(30) != 304 { return 1 }
12 if wa_sat_vapor_density_x10(20) != 173 { return 2 }
13
14 // --- psychrometric condensation yield ---
15 if wa_abs_humidity_x10(30, 70) != 212 { return 3 } // 30.4 * 0.70
16 if wa_extractable_x10(30, 70, 5) != 144 { return 4 } // 212 - 68 (coil at 5C)
17 if wa_extractable_x10(20, 30, 5) != 0 { return 5 } // cool + dry: nothing condenses
18 if wa_daily_yield_ml(100, 144) != 34560 { return 6 } // 100 m3/h -> ~34.6 L/day
19 if wa_specific_energy_whl(144) != 208 { return 7 } // ~208 Wh/L (humid, good)
20
21 // --- technology-class envelopes ---
22 if wa_class_works(WA_SORBENT, 20) != 1 { return 8 } // MOF works at 20% RH
23 if wa_class_works(WA_CONDENSATION, 20) != 0 { return 9 } // refrigeration does not
24 if wa_class_energy_whl(WA_PASSIVE_CAP) != 0 { return 10 } // UPenn passive = no energy
25
26 // --- the recommender picks the right harvester per climate ---
27 if wa_recommend(30, 70) != WA_CONDENSATION { return 11 } // humid -> condense
28 if wa_recommend(25, 20) != WA_SORBENT { return 12 } // desert -> MOF sorbent
29 if wa_recommend(20, 35) != WA_PASSIVE_CAP { return 13 } // moderate -> passive capillary
30 if wa_recommend(20, 10) != WA_NONE { return 14 } // too dry for any -> none
31
32 return 0
33}