nx_water_design.nx source
↩ module page · 79 lines · 3062 B
1// nx_water_design.nx -- WATER SYSTEMS / DESIGN CAPSTONE. The research->
2// design loop end to end: pick the harvesting technology for a climate,
3// take the raw atmospheric condensate (near-distilled AND microbially unsafe
4// until treated), disinfect + filter it, then remineralize to the taste +
5// health optimum -- and score the result. Composes nx_water_awg (harvest)
6// and nx_water_quality (taste / health / never-poison safety).
7//
8// The honest chain: fresh condensate is FLAT (TDS ~2, insipid) AND unsafe
9// (stagnant condensate can grow Legionella) -- so the raw water is refused
10// by the safety gate until UV + filtration, then remineralized with Ca /
11// Mg / bicarbonate to hit the delicious + healthful window.
12//
13// THE exceed: it DESIGNS the water (choose harvester -> treat -> dose
14// minerals) and proves the result beats raw condensate on taste (insipid ->
15// excellent) while passing health + never-poison safety -- a real
16// sovereign design, no hardware yet (honest).
17//
18// grounded: who_remineralization_targets + uv_germicidal_disinfection
19// + legionella_condensate_risk
20// genealogy_id: water_system_design + nishi_water_systems
21
22import "nx_syscalls.nx"
23import "nx_water_awg.nx"
24import "nx_water_quality.nx"
25
26// ===== Harvest (compose nx_water_awg) =============================
27
28func wd_recommend_harvester(temp_c: i64, rh_pct: i64) -> i64 {
29 return wa_recommend(temp_c, rh_pct)
30}
31
32func wd_daily_yield_ml(temp_c: i64, rh_pct: i64, coil_temp_c: i64, airflow_m3h: i64) -> i64 {
33 let ext: i64 = wa_extractable_x10(temp_c, rh_pct, coil_temp_c)
34 return wa_daily_yield_ml(airflow_m3h, ext)
35}
36
37// ===== The water-treatment + design chain =========================
38
39// Raw atmospheric condensate: near-distilled (flat) and NOT yet safe
40// (untreated condensate can harbour Legionella -> bacteria present).
41func wd_raw_condensate() -> *NxWaterSample {
42 let s: *NxWaterSample = nx_water_sample_new()
43 s.tds = wa_condensate_tds()
44 s.ph_x10 = 60
45 s.bacteria = 1
46 return s
47}
48
49// Disinfect (UV) + filter (carbon/RO polish): removes microbes + any trace
50// contaminants. Now safe, but still flat (no minerals).
51func wd_treat(s: *NxWaterSample) -> i64 {
52 s.bacteria = 0
53 s.lead_ppb = 0
54 s.arsenic_ppb = 0
55 s.pfas_ppt = 0
56 s.thm_ppb = 0
57 s.nitrate_mgl = 0
58 return 0
59}
60
61// Remineralize: add calcium + magnesium + bicarbonate; TDS ~ the sum of the
62// added ions; bicarbonate buffers pH into the good range.
63func wd_remineralize(s: *NxWaterSample, ca_dose: i64, mg_dose: i64, hco3_dose: i64) -> i64 {
64 s.ca = s.ca + ca_dose
65 s.mg = s.mg + mg_dose
66 s.hco3 = s.hco3 + hco3_dose
67 s.tds = s.ca + s.mg + s.hco3 + s.na + s.sulfate + s.chloride + 2
68 s.ph_x10 = 75
69 return 0
70}
71
72// The full designed water: raw condensate -> treat -> remineralize to the
73// taste + health optimum (Ca 50, Mg 25, bicarbonate 150 -> TDS ~227).
74func wd_design_best_water() -> *NxWaterSample {
75 let s: *NxWaterSample = wd_raw_condensate()
76 wd_treat(s)
77 wd_remineralize(s, 50, 25, 150)
78 return s
79}