code wiki / (root) / nx_water_quality.nx

nx_water_quality.nx

buildroot/runtime/nx_water_quality.nx

5365 B164 linesdepth 2pulls 2 transitivereach 5 importersview sourcekind librarytopic water
docsdependenciesstructsconstsfunctions

about

nx_water_quality.nx -- WATER SYSTEMS / TASTE + HEALTH + SAFETY. Scores a water for TASTE (WHO total-dissolved-solids palatability + mineral balance + pH) and HEALTH (WHO desirable calcium + magnesium), and gates SAFETY by construction: a NEVER-POISON refusal if any regulated contaminant exceeds its EPA/WHO limit or bacteria are present. INTEGER-EXACT. TDS + minerals in mg/L; pH x10; trace contaminants in their regulatory units (lead/arsenic ppb, nitrate mg/L-as-N, PFAS ppt, THM ppb). Grounded limits: lead <= 15 ppb (EPA action level, Lead and Copper Rule) arsenic <= 10 ppb; nitrate-N <= 10 mg/L; THM(total) <= 80 ppb (EPA MCL) PFOA+PFOS <= 4 ppt (EPA 2024 MCL); bacteria (E. coli/coliform) must be 0 Taste bands (WHO GDWQ): <300 excellent, 300-600 good, 600-900 fair, 900-1200 poor, >1200 unacceptable; very low TDS (<50) tastes flat. Health minerals (WHO desalination remineralization guidance): Ca >= 20, Mg >= 10 mg/L desirable (optimum Ca 40-80, Mg 20-30). THE exceed: taste + health scored AND a never-poison safety gate that STRUCTURALLY refuses lead/arsenic/nitrate/PFAS/bacteria/THM -- a TDS meter reads a number, this decides drinkable / delicious / healthful. grounded: who_gdwq_tds_palatability + epa_national_primary_drinking_water + epa_2024_pfas_mcl + who_remineralization_calcium_magnesium genealogy_id: water_quality_taste_health + nishi_never_poison

dependencies 1 imports · 5 importers

nx_syscalls.nx nx_water_quality.nx nx_validation.nx nx_validation_test.nx nx_water_design.nx nx_water_design_test.nx nx_water_quality_test.nx

imports: nx_syscalls.nx

imported by: nx_validation.nxnx_validation_test.nxnx_water_design.nxnx_water_design_test.nxnx_water_quality_test.nx

structs

59struct NxWaterSample

consts

30const WQ_LEAD_PPB: i64 = 15
31const WQ_ARSENIC_PPB: i64 = 10
32const WQ_NITRATE_MGL: i64 = 10
33const WQ_PFAS_PPT: i64 = 4
34const WQ_THM_PPB: i64 = 80
37const WQ_CA_MIN: i64 = 20
38const WQ_MG_MIN: i64 = 10
42const WQ_INSIPID: i64 = 0 // TDS < 50 (flat)
43const WQ_EXCELLENT: i64 = 1 // < 300
44const WQ_GOOD: i64 = 2 // 300-600
45const WQ_FAIR: i64 = 3 // 600-900
46const WQ_POOR: i64 = 4 // 900-1200
47const WQ_UNACCEPTABLE: i64 = 5 // > 1200
49const WQ_SAFE: i64 = 0
50const WQ_REFUSED_LEAD: i64 = 1
51const WQ_REFUSED_ARSENIC: i64 = 2
52const WQ_REFUSED_NITRATE: i64 = 3
53const WQ_REFUSED_PFAS: i64 = 4
54const WQ_REFUSED_BACTERIA: i64 = 5
55const WQ_REFUSED_THM: i64 = 6

functions

76func nx_water_sample_new() -> *NxWaterSample
called by 2: wd_raw_condensatemain calls 1: sys_mmap
97func wq_tds_taste_class(tds: i64) -> i64
called by 2: mainmain
107func wq_tds_points(tds: i64) -> i64
called by 1: wq_taste_score
117func wq_ca_points(ca: i64) -> i64
called by 1: wq_taste_score
123func wq_mg_points(mg: i64) -> i64
called by 1: wq_taste_score
129func wq_ph_points(ph_x10: i64) -> i64
called by 1: wq_taste_score
137func wq_taste_score(s: *NxWaterSample) -> i64
143func wq_safety_admit(s: *NxWaterSample) -> i64
153func wq_is_potable(s: *NxWaterSample) -> i64
159func wq_is_healthful(s: *NxWaterSample) -> i64
called by 2: mainmain calls 1: wq_is_potable