A comprehensive predictive maintenance simulation framework for Battery Energy Storage Systems (BESS) in DC microgrids, implementing real-time state-of-health estimation and anomaly detection.
- Real-time SoH Prediction: Uses LSTM/TCN models for cycle-level health estimation
- Anomaly Detection: Adaptive thresholding with dynamic alert generation
- Electrochemical Modeling: Physics-informed voltage residual computation
- Interactive Dashboard: Real-time visualization with Dash and Plotly
- REST API: Flask-based API for integration with external systems
- Edge-Compatible: Sub-500ms inference for real-time applications
- Data Quality: Cycle-level measurements with residual-based degradation indicators
- Computational Budget: <500ms processing time per cycle
- Environmental Range: -10°C to +40°C ambient temperature operation
- Safety Margins: <5% false negatives, <10% false positives
BESS/
├── data/
│ └── battery_data_generator.py # Synthetic BESS data generation
├── models/
│ └── sequence_models.py # LSTM and TCN implementations
├── utils/
│ ├── preprocessing.py # Data preprocessing and feature extraction
│ └── anomaly_detection.py # Adaptive threshold management
├── simulation/
│ └── bess_simulator.py # Main simulation engine
├── web/
│ ├── dashboard.py # Dash visualization dashboard
│ └── flask_api.py # REST API endpoints
├── main.py # Application entry point
└── requirements.txt # Python dependencies
- Install dependencies:
pip install -r requirements.txt- Run the application:
python main.py --mode bothRun a complete simulation with performance metrics:
python main.py --mode demo --model LSTMLaunch interactive web dashboard:
python main.py --mode dashboardAccess at: http://127.0.0.1:8050
Start REST API server:
python main.py --mode apiAPI available at: http://127.0.0.1:5000
Run both dashboard and API:
python main.py --mode both- Equivalent circuit model for expected voltage behavior
- Residual computation (measured - predicted) as degradation indicators
- Parameter fitting for real-time adaptation
- LSTM/TCN models for temporal pattern recognition
- Features: residuals, temperature, throughput, cycle characteristics
- Target: SoH estimation and degradation rate prediction
- Dynamic threshold: Th = μ_err + k·σ_err
- Temperature-adjusted alerting
- Rolling statistics with environmental compensation
- Cycle-level inference pipeline
- Performance monitoring and optimization
- Edge-compatible model architectures
GET /api/status- System status and current metricsPOST /api/initialize- Initialize ML modelsPOST /api/start_simulation- Begin continuous simulationPOST /api/process_cycle- Process single cycleGET /api/recent_data- Retrieve recent cycle dataGET /api/summary- Simulation performance summaryGET /api/alerts- Alert history and statistics
- Architecture: Multi-layer LSTM with dropout
- Input: (sequence_length, num_features)
- Output: SoH prediction [0, 1]
- Optimization: Adam optimizer with MAE loss
- Architecture: Temporal Convolutional Network
- Dilated convolutions for long-range dependencies
- Residual connections and dropout regularization
- Faster inference than LSTM for edge deployment
The framework tracks:
- Prediction Accuracy: MAE and RMSE for SoH estimation
- Detection Performance: True/false positive/negative rates
- Processing Speed: Per-cycle inference time
- Real-time Compliance: <500ms processing requirement
Temperature compensation factors:
- Voltage behavior normalization
- Threshold adjustment for ambient conditions
- Seasonal adaptation algorithms
- Conservative thresholding to minimize false negatives
- Multi-criteria anomaly detection
- Severity scoring for maintenance prioritization
- Historical trend analysis for early warning
This project is developed for research and educational purposes in predictive maintenance for energy storage systems.