nx_water_quality.nx
buildroot/runtime/nx_water_quality.nx
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
imports: nx_syscalls.nx
imported by: nx_validation.nxnx_validation_test.nxnx_water_design.nxnx_water_design_test.nxnx_water_quality_test.nx
structs
| 59 | struct NxWaterSample |
consts
| 30 | const WQ_LEAD_PPB: i64 = 15 |
| 31 | const WQ_ARSENIC_PPB: i64 = 10 |
| 32 | const WQ_NITRATE_MGL: i64 = 10 |
| 33 | const WQ_PFAS_PPT: i64 = 4 |
| 34 | const WQ_THM_PPB: i64 = 80 |
| 37 | const WQ_CA_MIN: i64 = 20 |
| 38 | const WQ_MG_MIN: i64 = 10 |
| 42 | const WQ_INSIPID: i64 = 0 // TDS < 50 (flat) |
| 43 | const WQ_EXCELLENT: i64 = 1 // < 300 |
| 44 | const WQ_GOOD: i64 = 2 // 300-600 |
| 45 | const WQ_FAIR: i64 = 3 // 600-900 |
| 46 | const WQ_POOR: i64 = 4 // 900-1200 |
| 47 | const WQ_UNACCEPTABLE: i64 = 5 // > 1200 |
| 49 | const WQ_SAFE: i64 = 0 |
| 50 | const WQ_REFUSED_LEAD: i64 = 1 |
| 51 | const WQ_REFUSED_ARSENIC: i64 = 2 |
| 52 | const WQ_REFUSED_NITRATE: i64 = 3 |
| 53 | const WQ_REFUSED_PFAS: i64 = 4 |
| 54 | const WQ_REFUSED_BACTERIA: i64 = 5 |
| 55 | const WQ_REFUSED_THM: i64 = 6 |
functions
| 76 | func nx_water_sample_new() -> *NxWaterSample |
| 97 | func wq_tds_taste_class(tds: i64) -> i64 |
| 107 | func wq_tds_points(tds: i64) -> i64 called by 1: wq_taste_score |
| 117 | func wq_ca_points(ca: i64) -> i64 called by 1: wq_taste_score |
| 123 | func wq_mg_points(mg: i64) -> i64 called by 1: wq_taste_score |
| 129 | func wq_ph_points(ph_x10: i64) -> i64 called by 1: wq_taste_score |
| 137 | func wq_taste_score(s: *NxWaterSample) -> i64 |
| 143 | func wq_safety_admit(s: *NxWaterSample) -> i64 |
| 153 | func wq_is_potable(s: *NxWaterSample) -> i64 |
| 159 | func wq_is_healthful(s: *NxWaterSample) -> i64 |