This technical documentation provides a comprehensive breakdown of the **HydroSense-Kenya** system. It is designed to serve as your primary reference for the live code audit and final submission.
---
# HydroSense-Kenya: Technical System Documentation
## 1. Project Overview and Logic
HydroSense-Kenya is a scientific computing tool that manages water resources for a three-zone farm (Zone A: Tomato, Zone B: Kale, Zone C: Maize). The system moves from raw data (15-minute sensor readings) to high-level decision support (Smart Irrigation).
### The Intellectual Arc
1. **Framing:** Defining the water balance equation.
2. **Acquisition:** Aggregating high-frequency data into daily steps.
3. **Numerical Engine:** Implementing the math required to solve for unknown water needs.
4. **Simulation:** Using Differential Equations (ODEs) to predict the future.
5. **Optimization:** Applying a threshold-based algorithm to prevent crop stress.
6. **Validation:** Testing the math with `pytest`.
---
## 2. Mathematical and Numerical Engine (`src/numerical_methods.py`)
This module contains the "manual" implementations of standard numerical algorithms. The rubric requires these to be built from scratch without using SciPy.
### 2.1 Root Finding (Bisection & Newton-Raphson)
* **Purpose:** To find the exact irrigation amount ($I$) required to move soil moisture from its current state to the target state.
* **Bisection Method:** Starts with an interval $[a, b]$ where the function changes sign. It repeatedly halves the interval. It is slow but guaranteed to converge.
* **Newton-Raphson Method:** Uses the derivative of the function to follow the tangent line to the x-axis. It is significantly faster ($O(h^2)$ convergence) but can fail if the initial guess is poor or the derivative is zero.
### 2.2 Numerical Integration (Trapezoidal & Simpson’s Rules)
* **Purpose:** To calculate the cumulative water deficit or total evapotranspiration over a period.
* **Trapezoidal Rule:** …