#!/usr/bin/env python3
"""Full SolarHearth unit: cooking + all add-ons + ALL purification modules.
Rolls up the three prior models into one bill of materials."""

SOLAR = 5.5 * 0.78          # kWh delivered per kW-day
PV_W, BATT = 0.45, 160.0

# Daily electrical loads (Wh)
LOADS = [
    ("Induction cooking (2 meals)",        2000),
    ("Lights, phones, comms, radio/fan",    465),
    ("Flow pasteurizer, 20 L (12.3 Wh/L)",  246),
    ("UV-C polish, 20 L",                     4),
    ("Chlorinator + test kit + sensors",     10),
]

# One-time hardware ($)
HW = [
    ("Induction hob 1.8 kW",                 65),
    ("Enclosure, tank, plumbing, controls", 170),
    ("Phones/lights/comms/radio/fan kit",   292),
    ("UV-C flow cell",                       60),
    ("Water test kit + incubator pocket",    45),
    ("Electrochlorination cell (batch)",     90),
    ("Flow pasteurizer + counterflow HX",    95),
    ("Arsenic cartridge (FeOOH, loaded)",    50),
    ("Fluoride column (alumina/bone char)",  60),
]

# Annual consumables ($/yr) - low..high
CONSUMABLES = [
    ("Fluoride media", 19, 95),
    ("Arsenic media + disposal", 11, 20),
    ("Salt for chlorinator", 1, 2),
    ("Spares/maintenance (3% capex)", 0, 0),  # filled below
]

wh_day = sum(w for _, w in LOADS)
pv_w = wh_day / SOLAR
pv_cost = pv_w * PV_W
batt_kwh = 2.0   # evening meal 1.2 + overnight lights/comms/fans 0.5 + buffer
batt_cost = batt_kwh * BATT
hw_cost = sum(c for _, c in HW)
capex = pv_cost + batt_cost + hw_cost

maint = capex * 0.03
cons_lo = sum(l for _, l, h in CONSUMABLES) + maint
cons_hi = sum(h for _, l, h in CONSUMABLES) + maint

print(f"Daily load: {wh_day} Wh -> PV {pv_w:.0f} W (${pv_cost:.0f}), battery {batt_kwh} kWh (${batt_cost:.0f})")
print("Hardware:")
for n, c in HW:
    print(f"  {n:<38}${c}")
print(f"\nFULL UNIT CAPEX: ${capex:.0f}")
print(f"Consumables+maintenance: ${cons_lo:.0f}-{cons_hi:.0f}/yr")
amort_mo_lo = capex / (8 * 12) + cons_lo / 12
amort_mo_hi = capex / (8 * 12) + cons_hi / 12
print(f"All-in over 8 yr: ${amort_mo_lo:.0f}-{amort_mo_hi:.0f}/mo  (charcoal displaced: $15-40/mo)")

# Optional MOF water module (marginal, on top of full unit)
mof_wh = 20 * 620            # 20 L/day at 0.62 kWh/L
mof_pv = mof_wh / SOLAR * PV_W
mof_batt = 5.5 * BATT        # night-cycle fans + morning desorb buffer
mof_sorbent_lo, mof_sorbent_hi = 16 * 30, 30 * 80
mof_bop = 200
mof_lo = mof_pv + mof_batt + mof_sorbent_lo + mof_bop
mof_hi = mof_pv + mof_batt + mof_sorbent_hi + mof_bop
print(f"\nOptional MOF air-water module (+20 L/day): +${mof_lo:.0f} to +${mof_hi:.0f}")
print(f"Flagship (everything incl. MOF): ${capex+mof_lo:.0f}-{capex+mof_hi:.0f}")

# Cluster: 5 households, shared kitchen + fridge + camp-grade chlorinator
cluster = 2995 + 477 + 180 + 95 + 5 * (50 + 60)
print(f"\nCluster (5 hh: kitchen+fridge+chlorinator+pasteurizer+5x As/F): ${cluster} (${cluster/5:.0f}/hh)")
