How gschivley/battery_model works
Project type and purpose
• This is a research/analysis tool (not a web app or microservice) for modeling battery storage dispatch in the NYISO day‐ahead market over a historical dataset (full year 2017).
• Core goal: ingest historical Locational Based Marginal Price (LBMP) CSVs, run a day‐ahead optimization for a battery asset, then output time‐series dispatch, energy state, summary revenue/cost, and visualizations.
File‐structure overview
• Top‐level:
• 2017_NYISO_LBMPs/… – hourly price CSVs by month/day
• src/ – Python modules
– read_data.py (data ingestion)
– battery_model.py (optimization logic)
• Dispatch optimization.ipynb & Price exploration.ipynb – orchestration & EDA in Jupyter
• requirements.txt & environment.yml – dependency specification
• README.md, LICENSE – documentation
• full_year_optimization_results.csv – sample output
Key architectural components
A. Data Layer
– File System: raw CSV price data (2017_NYISO_LBMPs/)
– read_data.py: parses directory, loads CSVs into Pandas DataFrame with timestamp & zone
B. Model Layer
– battery_model.py: defines the battery asset parameters and constructs a day‐ahead dispatch optimization
– Uses a solver (e.g., PuLP or CVXPy) under the hood to maximize arbitrage revenue, subject to SOE continuity, capacity, efficiency, throughput constraints
C. Orchestration & Analysis Layer
– Dispatch optimization.ipynb:
• Calls read_data to load price series
• Instantiates the battery model with given specs
• Executes optimization for each day or full horizon
• Aggregates hourly dispatch & SOE outputs
• Computes summary metrics (annual revenue, cost, throughput)
• Exports full_year_optimization_results.csv
• Generates per‐week and per‐month plots
– Price exploration.ipynb: exploratory data analysis on LBMP patterns
D. Environment & Deployment
– environment.yml / requirements.txt: Python 3.x, Pandas, NumPy, optimization solver, Jupyter
– Binder badge: interactive cloud environment
Interactions and data flow
1. User launches Jupyter notebook (locally or via Binder)
2. read_data.py reads raw CSVs → DataFrame (Price Series)
3. battery_model.py consumes DataFrame + battery specs → Optimization problem
4. Solver returns hourly dispatch schedule & SOE → DataFrame of results
5. Notebook aggregates results → summary metrics + plots → CSV & notebook outputs
Architectural patterns and principles
• Layered design: Data ingestion → Modeling → Orchestration/Visualization
• Single‐responsibility modules: each .py file has one clear purpose
• Reproducible environment via environment.yml + Binder integration
• Notebook for orchestration and ad-hoc analysis, not production code
– Clear, descriptive labels (“Load Price Data”, “Optimize Dispatch”, “Generate Plots”)