Hybrid Microgrid
Simulation & Optimization Platform
Open-source Python platform built on NREL's HOPP framework for hybrid microgrid optimization. Supports multi-location processing, predictive battery dispatch, and comprehensive economic analysis.
Powerful Features for Microgrid Optimization
Comprehensive tools for renewable energy system design and analysis
System Optimization
Advanced algorithms optimize PV, wind, battery, and genset components for maximum efficiency and cost-effectiveness.
- Multi-objective optimization
- Component sizing
- Configuration analysis
Predictive Battery Dispatch
Intelligent battery management with predictive dispatch algorithms and up to 20% load reduction capability.
- Predictive dispatch
- Load management
- Demand response
Economic Analysis
Comprehensive financial modeling including LCOE, Net Present Cost, CO2 emissions, and payback analysis.
- LCOE calculation
- NPC analysis
- CO2 emissions tracking
Multi-Location Processing
Batch processing capabilities for analyzing multiple sites simultaneously with location-specific resource data.
- Batch optimization
- Resource data management
- Comparative analysis
HOPP Integration
Built on NREL's HOPP framework for comprehensive renewable energy system simulation and optimization.
- NREL data integration
- Weather modeling
- Performance simulation
Flexible Configuration
YAML-based configuration system with extensive customization options for all system parameters.
- YAML configuration
- Parameter tuning
- Custom constraints
Code Examples
Learn how to use Py-Microgrid with practical examples
# Set up NREL API key and initialize system
from py_microgrid.utilities.keys import set_developer_nrel_gov_key
from py_microgrid.tools.optimization import SystemOptimizer
from py_microgrid.simulation.resource_files import ResourceDataManager
# Set your NREL API key (get free at: developer.nrel.gov/signup)
set_developer_nrel_gov_key('your_api_key_here')
# Initialize resource data manager and download data
resource_manager = ResourceDataManager()
resource_manager.download_solar_data(lat=39.7392, lon=-104.9903)
resource_manager.download_wind_data(lat=39.7392, lon=-104.9903)
# Initialize optimizer with configuration
config_path = 'config/site_config.yaml'
optimizer = SystemOptimizer(config_path)
# Run optimization
results = optimizer.optimize()
# Access comprehensive results
print(f'LCOE: ${results.lcoe:.3f}/kWh')
print(f'NPC: ${results.npc:,.0f}')
print(f'Renewable Fraction: {results.renewable_fraction:.1f}%')
from py_microgrid.utilities import ConfigManager
from py_microgrid.tools.optimization import SystemOptimizer
from py_microgrid.simulation.resource_files import ResourceDataManager
# Define multiple locations for analysis
locations = [
{'name': 'Denver', 'lat': 39.7392, 'lon': -104.9903},
{'name': 'Phoenix', 'lat': 33.4484, 'lon': -112.0740},
{'name': 'Seattle', 'lat': 47.6062, 'lon': -122.3321}
]
# Process multiple locations
results = {}
for location in locations:
# Download resource data for each location
resource_manager = ResourceDataManager()
resource_manager.download_solar_data(lat=location['lat'], lon=location['lon'])
resource_manager.download_wind_data(lat=location['lat'], lon=location['lon'])
# Update config for this location
config_manager = ConfigManager('config/site_config.yaml')
config_manager.update_location(location['lat'], location['lon'])
# Run optimization
optimizer = SystemOptimizer(config_manager.config_path)
result = optimizer.optimize()
results[location['name']] = result
# Compare results across locations
for location, result in results.items():
print(f'{location}: LCOE=${result.lcoe:.3f}/kWh, Renewable: {result.renewable_fraction:.1f}%')
# site_config.yaml - Based on actual Py-Microgrid examples
config:
dispatch_options:
battery_dispatch: heuristic_load_following
grid_charging: true
include_lifecycle_count: false
n_look_ahead_periods: 48
pv_charging_only: false
solver: glpk
site:
data:
lat: -33.5265
lon: 149.1588
elev: 1099
tz: -6
year: 2020
urdb_label: 5ca4d1175457a39b23b3d45e
desired_schedule:
# Load profile data (hourly values)
# [250, 280, 320, 340, ...]
technologies:
pv:
system_capacity_kw: 500
wind:
system_capacity_kw: 200
battery:
system_capacity_kw: 300
system_capacity_kwh: 1200
grid:
interconnect_kw: 1000
Quick Installation
Get started with Py-Microgrid in minutes
Install Dependencies
pip install HOPP
conda install -c conda-forge glpk -y
conda install -c conda-forge coin-or-cbc -y
Clone Repository
git clone https://github.com/Hanrong-Huang/Py-Microgrid.git
cd Py-Microgrid
Get NREL API Key
# Get your free API key from:
# https://developer.nrel.gov/signup/
# Add to your environment variables