Skip to content

SenseiSuraj24/Project-VARUNA

Repository files navigation

🌊 Project VARUNA

Physics-Informed Rural Drainage Planning System

VARUNA — named after the Vedic deity of water and cosmic order — is an AI-powered drainage planning system for rural India. It combines Physics-Informed Graph Neural Networks (PI-GNN), real terrain data, and IMD rainfall records to generate hydraulically sound, PMGSY-compliant drainage designs with sub-kilometre precision.


📖 Table of Contents

  1. Overview
  2. Architecture
  3. Tech Stack
  4. Repository Structure
  5. Pipeline Phases
  6. Physics Model
  7. Dashboard (VO)
  8. Installation
  9. Usage
  10. Configuration
  11. Outputs
  12. Dataset Sources
  13. Team

Overview

Rural flood damage in India costs billions annually and disproportionately harms agrarian communities. Existing drainage design tools are either too expensive, rely on coarse data, or ignore terrain physics entirely.

VARUNA solves this by:

  • Processing real LiDAR or DEM elevation data to build terrain graphs
  • Simulating flood behaviour using shallow-water physics embedded in a GNN
  • Designing Manning's-equation-compliant drainage pipe networks
  • Exporting results as GeoJSON and AutoCAD DXF for direct field use
  • Providing a live interactive Next.js dashboard for visual decision-making

Architecture

┌─────────────────────────────────────────────────────────────────┐
│                        Project VARUNA                           │
│                                                                 │
│  ┌──────────────┐   ┌──────────────┐   ┌───────────────────┐   │
│  │  LiDAR /DEM  │──▶│  Terrain     │──▶│   PI-GNN Model    │   │
│  │  Input Data  │   │  Graph Build │   │   (DUALFloodGNN)  │   │
│  └──────────────┘   └──────────────┘   └───────┬───────────┘   │
│                                                 │               │
│  ┌──────────────┐   ┌──────────────┐   ┌───────▼───────────┐   │
│  │   CAD DXF    │◀──│  Drainage    │◀──│   Flood Simulation│   │
│  │  GeoJSON out │   │  Designer    │   │  (SWE Physics)    │   │
│  └──────────────┘   └──────────────┘   └───────────────────┘   │
│                                                                 │
│  ┌─────────────────────────────────────────────────────────┐    │
│  │              VO — Next.js Interactive Dashboard          │    │
│  │  Leaflet map · Layer toggles · Flood zone overlays      │    │
│  └─────────────────────────────────────────────────────────┘    │
└─────────────────────────────────────────────────────────────────┘

Tech Stack

Backend (Python)

Component Technology
GNN Model PyTorch + PyTorch Geometric
Terrain Graph NetworkX + PySheds
LiDAR Processing PDAL, LASpy, RandLA-Net
DEM & Rasters Rasterio, WhiteboxTools
Spatial Analysis GeoPandas, Shapely, OSMnx
Rainfall Data IMD NetCDF4 / xarray
CAD Export ezdxf
Web Server Python http.server (ThreadingHTTPServer)

Frontend (VO Dashboard)

Component Technology
Framework Next.js 16 (Turbopack)
Language TypeScript / React 19
Map Leaflet + react-leaflet
Charts Recharts
UI Components Radix UI + shadcn/ui
Styling Tailwind CSS v4

Repository Structure

Project-VARUNA/
├── src/varuna/
│   ├── main.py                  # CLI entrypoint (all sub-commands)
│   ├── pipeline.py              # End-to-end orchestration
│   ├── config/
│   │   ├── settings.py          # VarunaConfig dataclass
│   │   └── default_config.yaml  # Tunable defaults
│   ├── lidar/
│   │   ├── segmenter.py         # Ground/non-ground LiDAR classification
│   │   ├── dtm.py               # Digital Terrain Model generation
│   │   ├── hydrology.py         # Flow accumulation, watershed delineation
│   │   ├── manning.py           # Manning's n lookup from LULC codes
│   │   ├── randlanet.py         # RandLA-Net deep LiDAR segmentation
│   │   └── pdal_utils.py        # PDAL pipeline wrappers
│   ├── graph/
│   │   ├── builder.py           # TerrainGraphBuilder — DEM → PyG Data
│   │   ├── assembly.py          # Graph edge/node feature assembly
│   │   └── adaptive.py          # Adaptive density graph refinement
│   ├── pignn/
│   │   ├── model.py             # DUALFloodGNN (depth + u/v + edge flow)
│   │   ├── losses.py            # Continuity, momentum, gravity-alignment loss
│   │   ├── trainer.py           # PIGNNTrainer — training loop
│   │   ├── predictor.py         # FloodPredictor — inference
│   │   └── engine.py            # FloodSimulationEngine — simulation wrapper
│   ├── drainage/
│   │   ├── designer.py          # DrainageDesigner — Manning's pipe sizing
│   │   ├── cad_export.py        # GeoJSON → AutoCAD DXF
│   │   └── design_summary.py    # JSON summary statistics
│   ├── data/
│   │   ├── village_demo.py      # OSMnx village boundary + DEM fetcher
│   │   ├── imd_loader.py        # IMD rainfall CSV / NetCDF loader
│   │   ├── training_dataset.py  # PyG dataset builder
│   │   └── dataset_audit.py     # Data readiness checker
│   ├── benchmark/
│   │   ├── speed_compare.py     # Inference latency benchmarks
│   │   ├── physics_blind_demo.py# Physics-blind vs PI-GNN comparison
│   │   ├── imd_stress_test.py   # IMD extreme-rainfall stress test
│   │   ├── village_impact.py    # Flood impact assessment
│   │   └── panel_pack.py        # Judge evidence bundle generator
│   └── visualization/
│       └── __init__.py
├── VO/                          # Next.js interactive dashboard
│   ├── app/
│   │   ├── page.tsx             # Main dashboard page
│   │   └── layout.tsx           # Root layout + metadata
│   ├── components/
│   │   ├── drainage-map.tsx     # Leaflet map with all overlay layers
│   │   ├── control-sidebar.tsx  # Layer toggles, analysis controls
│   │   ├── detail-panel.tsx     # Click-to-inspect panel details
│   │   └── header.tsx           # Top navigation bar
│   ├── lib/
│   │   ├── drainage-data.ts     # Demo location data + metrics engine
│   │   ├── varuna-loader.ts     # GeoJSON loader + MST recommendation engine
│   │   └── utils.ts             # Shared utilities
│   └── public/
│       └── varuna_drainage_design.geojson  # Pre-computed real GNN output
├── data/
│   └── imd/                     # IMD daily rainfall data
├── tests/
│   └── test_pignn_physics.py    # Physics validation test suite
├── pyproject.toml
├── requirements.txt
└── train_varuna.py              # Standalone training script

Pipeline Phases

Phase 1 — LiDAR / DEM Ingestion

Accepts either a raw .las/.laz point cloud (PDAL + SMRF classification) or a pre-processed DEM GeoTIFF. For village demos, OSMnx fetches the village boundary from OpenStreetMap and downloads SRTM/ASTER elevation data automatically.

Phase 2 — Terrain Graph Construction

The DEM is converted into a PyTorch Geometric Data object. Each pixel/cell becomes a node with features:

Feature Description
x[:,0] Elevation (m)
x[:,1] Slope magnitude
x[:,2] Manning's n from LULC
x[:,3] Topographic Wetness Index (TWI)
x[:,4] Rainfall intensity proxy

Edges are directed downhill-only (configurable), with edge attributes encoding slope and distance.

Phase 3 — PI-GNN Flood Simulation

The DUALFloodGNN model processes the graph through:

  1. A node feature encoder (2-layer MLP → hidden_dim)
  2. A stack of message-passing processor layers with slope-weighted aggregation (downhill edges get higher weight via softplus(slope))
  3. Four prediction heads:
    • Depth head (softplus → always non-negative water depth)
    • u-head (x-velocity component, tanh)
    • v-head (y-velocity component, tanh)
    • Edge flow head (directional flow magnitude)

Phase 4 — Drainage Design

The DrainageDesigner selects up to 220 diverse seed nodes ranked by TWI + rainfall score. From each seed it traces a steepest-descent path downstream (~24 hops). For every segment it computes:

  • Manning's diameter: d = ((Q·n·4^(5/3)) / (π·√S))^(3/8)
  • Diameter class: D060_080, D080_100, or D100_PLUS
  • PMGSY compliance check (min 0.6 m)
  • Chainage, flow rate, slope

All segments are exported as GeoJSON and AutoCAD DXF.

Phase 5 — Visualisation

Results are served to the VO React dashboard for interactive exploration.


Physics Model

VARUNA embeds three physical constraints as loss terms during training:

1. Continuity (Mass Conservation)

∂h/∂t + ∇·Q = r

Residual: (h / dt) + divergence(edge_flow) - rainfall_term

2. Momentum (Simplified SWE Proxy)

(Δu² + Δv²) ≈ |Δh|

Velocity differences across edges should scale with the hydraulic head gradient.

3. Gravity Alignment

Penalises water flowing uphill on downhill terrain edges:

L_gravity = mean(ReLU(-dot(velocity_src, edge_direction)))  [downhill edges only]

Combined Loss

L = w_data · MSE(h_pred, h_target)
  + w_physics · (L_continuity + 0.5 · L_momentum)
  + w_gravity · L_gravity

Default weights: w_data = 0.7, w_physics = 0.2, w_gravity = 0.1


Dashboard (VO)

The interactive dashboard is a Next.js 16 application located in the VO/ directory.

Features

Feature Description
🗺️ Interactive Map Leaflet map with real village boundaries
🌊 Flood Zone Overlay Problem zones coloured by severity
🔵 Drainage Network Existing vs proposed pipeline segments
📊 Metrics Panel Total length, pipeline counts, coverage area
🌧️ Rainfall Simulation Intensify flood zones by 1.5×
🔍 Click-to-Inspect Click any segment or zone for details
📍 Multi-location Switchable demo villages + real VARUNA output

Running the Dashboard

cd VO
npm install
npm run dev

Open http://localhost:3000.

The dashboard loads the pre-computed public/varuna_drainage_design.geojson (real PI-GNN output) for the VARUNA Real — Ralegan Siddhi location.


Installation

Prerequisites

  • Python ≥ 3.10
  • Node.js ≥ 18 + npm
  • CUDA-capable GPU (optional but recommended for training)

Python Backend

# Clone the repository
git clone https://github.com/SenseiSuraj24/Project-VARUNA.git
cd Project-VARUNA

# Create a virtual environment
python -m venv .venv
.venv\Scripts\activate        # Windows
# source .venv/bin/activate   # Linux/macOS

# Install the package + dependencies
pip install -e .
pip install -r requirements.txt

Frontend Dashboard

cd VO
npm install
npm run dev

Usage

All backend commands go through the varuna-run CLI entry point (or python -m varuna.main).

Run from a LiDAR Point Cloud

varuna-run run path/to/village.laz --scenario baseline --pretty

Run from a DEM GeoTIFF

varuna-run run-dem path/to/dem.tif --scenario baseline --max-cells 320 --pretty

Auto Village Demo (OSMnx + SRTM)

varuna-run village-demo "Ralegan Siddhi, Maharashtra, India" --half-km 1.5 --pretty

Train the PI-GNN

varuna-run train outputs/graphs/village_graph.pt --epochs 50

Run Inference

varuna-run predict outputs/graphs/village_graph.pt outputs/models/checkpoint.pt

Audit Dataset Readiness

varuna-run audit

Run Benchmark Suite

varuna-run benchmark outputs/graphs/village_graph.pt

Serve the Backend API (for Dashboard)

varuna-run dashboard --serve --port 8000

Configuration

All defaults are in src/varuna/config/default_config.yaml:

rainfall:
  baseline_mm_per_hr: 75.0      # IMD 50-year return period
  infiltration_mm_per_hr: 10.0
  return_period_years: 50

graph:
  node_spacing_m: 2.0
  downhill_only_edges: true

pignn:
  hidden_dim: 64
  num_layers: 3
  loss_weight_data: 0.7
  loss_weight_physics: 0.2
  loss_weight_gravity: 0.1
  train_epochs: 20
  learning_rate: 0.001

drainage:
  min_pipe_diameter_m: 0.6      # PMGSY minimum
  manning_n_concrete: 0.013

Override any value by editing the YAML or by extending VarunaConfig in code.


Outputs

Output Path Format
Drainage design outputs/varuna_drainage_design.geojson GeoJSON
CAD drawing outputs/varuna_drainage_design.dxf AutoCAD DXF
Design summary outputs/varuna_drainage_summary.json JSON
Trained model outputs/training/best_model.pt PyTorch checkpoint
Training report outputs/training/latest_training_report.json JSON
Village boundary outputs/village_boundary.geojson GeoJSON

Dataset Sources

Dataset Source Use
LiDAR Point Clouds Field survey / Open TopoData Ground truth terrain
SRTM/ASTER DEM NASA / OpenTopography Elevation (village demo)
IMD Gridded Rainfall RF25_ind*.nc (IMD) Rainfall scenarios
LULC Rasters Bhuvan / ISRO Manning's n values
OSM Village Boundaries OpenStreetMap (osmnx) AOI definition
PMGSY Standards MoRD, Government of India Pipe sizing compliance

Team

Project VARUNA was built for the PAML Hackathon 2026.

Member Role
Suraj Architecture, PI-GNN, Dashboard
Sudarshan G Backend, Visualization, UI Refactor
Narendra Kanchi Physics Loss, Testing, Documentation

License

This project is developed for academic and hackathon purposes.
© 2026 Project VARUNA Team. All rights reserved.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages