How gduthe/windfarm-gnn works
Project Type and Purpose
• This is a research-oriented, modular graph-ML pipeline (not a web or full-stack app).
• Purpose: generate wind-farm graph datasets via PyWake, train/finetune Graph Neural Networks (GNNs) for power and load prediction, and provide inference + plotting tools.
File Structure
Top-level components:
• gnn_framework/ – core ML pipeline
– train.py, predict.py
– config.yml (training)
– data/ (Dataset class, stats computation)
– models/ (encoder, processor, decoder, WindFarmGNN definitions)
– finetuning/ (LoRA & other finetuning scripts + configs)
• graph_farms/ – data-generation module
– generate_graphs.py (parallel PyWake + Sobol sampling)
– inflow_gen.py, layout_gen.py, pywake_sim.py
– config.yml (generation parameters)
• notebooks/ – Jupyter examples invoking generation, training, evaluation, plotting
• plotting/ – post-processing and visualization utilities
Extract Insights from the README
• Workflow stages:
a) Generate dataset (graph_farms)
b) Train base GNN (gnn_framework/train.py)
c) Finetune (LoRA or other methods)
d) Predict/infer on test data (gnn_framework/predict.py)
e) Plot results (plotting/) or explore via notebooks
• Config-driven design via YAML files at each stage
• External dependency: parallelized PyWake for fluid dynamics simulation
Main Components & Interactions
A. Data Generation Layer (“graph_farms” module)
• Sobol Sampler + Layout Generator
• PyWake Simulation Engine (external)
→ Outputs: serialized graph datasets (e.g., .pt, .npz, or custom) on disk
B. Data Ingestion Layer (“gnn_framework/data”)
• Dataset class
• compute_dataset_stats
C. Model Training Layer (“gnn_framework/models” + train.py)
• Encoder, Message-Passing Processor, Decoder, Task Heads
• Training Engine (PyTorch)
→ Generates: trained model checkpoint
D. Fine-Tuning Layer (“gnn_framework/finetuning”)
• LoRA adapter or other strategies
→ Outputs: fine-tuned model checkpoint
E. Inference Layer (“gnn_framework/predict.py”)
• Loads model + test graphs → runs batch inference
F. Visualization Layer (“plotting” + notebooks)
• Plotting scripts
• Interactive notebooks invoking generation/training/inference
graph_farms → dataset storage → data ingestion → training → (optionally) finetuning → inference → plotting
Architectural Patterns & Design Principles
• Modular separation of concerns (data gen vs. data loader vs. model vs. finetune vs. visualization)
• Pipeline-driven, config-as-code (YAML)
• Plugin-style finetuning (LoRA, all-layers, decoder-only)
• Batch-parallel data generation (multiprocessing of PyWake simulations)
• Layout-agnostic GNN (graph abstraction layer in models/)
Detailed Element Checklist
• Component names matching directory names (e.g., “gnn_framework/models”)
• Config files next to each module
• Storage blocks for raw graphs, processed datasets, model artifacts
• Notebook layer as an orchestration client