Skip to content

An AI-driven solution to optimize battery performance, efficiency, and longevity. Features include real-time mode switching (Performance, Eco, Balanced, Custom), SOC and temperature predictions, dynamic cooling adjustments, and a user-friendly GUI with interactive visualizations. Ideal for electric vehicles and energy storage systems. ๐Ÿš—๐Ÿ”‹๐Ÿ“Š

Notifications You must be signed in to change notification settings

yasirusama61/AI_BMS_Optimization

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

30 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

๐Ÿš€ AI Battery Management System (AI BMS) โ€“ Battery Performance Optimization

Python Framework License Contributions Welcome


๐ŸŒŸ Project Overview

This project is part of the AI Battery Management System (AI BMS) initiative. The goal is to develop a real-time mode selection interface that allows users to optimize battery performance, efficiency, and longevity.

Users can choose between several operational modes, including:

  • โšก Performance Mode
  • ๐ŸŒฑ Eco Mode
  • โš–๏ธ Balanced Mode
  • ๐Ÿ› ๏ธ Custom Mode

Modes dynamically adjust parameters such as cooling, fan speed, and temperature settings.


๐Ÿ“Š User Interface Prototype

Below is a prototype of the AI Battery Management System (AI BMS) optimization interface:

UI Prototype

Key Features of the Interface:

  1. Mode Selection:

    • Users can choose between:
      • โšก Performance Mode: Maximize performance at the potential expense of battery life.
      • ๐ŸŒฑ Eco Mode: Optimize energy efficiency and extend battery life.
      • โš–๏ธ Balanced Mode: A middle ground between performance and efficiency.
      • ๐Ÿ› ๏ธ Custom Mode: Configure user-defined parameters.
  2. Custom Mode Settings:

    • Options to adjust:
      • Cooling Mode (Normal, Silent, Aggressive)
      • Fan Speed via slider
      • Flow Rate via slider
      • Temperature Threshold via slider
    • Enable/Disable advanced settings:
      • โœ… Overheat Protection
      • โœ… Fast Charging
  3. Impact Visualizations:

    • Performance Impact: Bar chart showing mode-specific performance effects.
    • Efficiency Impact: Highlights energy efficiency in each mode.
    • Longevity Impact: Demonstrates how modes affect battery lifespan.
  4. Interactive Controls:

    • Apply, Save, Cancel buttons for user actions.
    • Real-time visualization of the selected mode's impact.

โœจ Features

  • ๐Ÿ”„ Mode Switching: Users can select operational modes that dynamically adjust system parameters like fan speed and cooling temperature.
  • ๐Ÿ› ๏ธ Custom Mode: Users can personalize parameters such as fan speed and temperature thresholds, and see real-time effects on battery performance.
  • ๐Ÿ“ˆ Dynamic Updates: Real-time graphs display the impact of mode changes on performance, efficiency, and battery longevity.
  • ๐Ÿค– Auto Adjustments: AI models automatically switch modes based on operating conditions.
  • ๐Ÿš— Applications: Used in electric vehicles and energy storage systems to optimize battery performance in real time.

๐Ÿ› ๏ธ Technologies Used

  • Programming Language: ๐Ÿ Python
  • GUI Framework: PyQt5 / Tkinter
  • Real-time Visualization: Matplotlib ๐Ÿ“Š
  • AI Models: SOC estimation and temperature prediction using LSTM
  • Data Handling: Pandas, NumPy

๐Ÿ”„ AI-Based Mode Selection

In this project, we replaced the static threshold-based mode selection logic with a Machine Learning (ML) model. The ML model dynamically selects the optimal mode (Performance, Eco, or Balanced) based on real-time battery conditions, including SOC (State of Charge), temperature, and current.

๐Ÿ“Š Data for Mode Selection

The mode selection model is trained on a comprehensive dataset with the following key features:

๐Ÿ”‘ Feature ๐ŸŒŸ Description
SOC State of Charge (%): Indicates the battery's charge level.
Temperature Predicted Battery Temperature (ยฐC): Key factor for thermal management.
Current Current Draw (A): Positive for discharging, negative for charging.
FanSpeed Fan Speed (RPM): Reflects the cooling system's fan intensity.
PumpDutyCycle Pump Duty Cycle (%): Percentage of time the pump is active for cooling.
CoolingIntensity Cooling Intensity: Defines the cooling level (Low or High).
Mode Target Mode: The operational mode (Performance, Eco, Balanced).

๐Ÿ› ๏ธ How These Features Are Used:

  • SOC & Temperature: Drive the selection of the most efficient or performance-oriented mode.
  • Current: Helps manage discharging/charging scenarios and mode transitions.
  • FanSpeed & PumpDutyCycle: Regulate the cooling system to maintain thermal efficiency.
  • CoolingIntensity: Adjusts dynamically to match mode-specific requirements.
  • Mode: Acts as the target variable for supervised learning.

This dataset enables the mode selection model to make real-time, data-driven decisions for optimizing battery performance, thermal regulation, and longevity.

Hereโ€™s a snapshot of the data used to train the mode selection model:

Data snapshot


๐Ÿ“‹ Legend

  • SOC (%): State of Charge of the battery (in percentage), indicating the battery's available capacity.
  • Temperature (ยฐC): Battery temperature in Celsius, critical for thermal management.
  • Current (A):
    • Positive values represent discharging (battery providing power).
    • Negative values represent charging (battery receiving power).
  • Fan Speed (RPM): Cooling system's fan speed in revolutions per minute, reflecting thermal regulation.
  • Pump Duty Cycle (%): The percentage of time the cooling pump is active, significantly influencing heat dissipation.
  • Cooling Intensity: Indicates the required cooling level:
    • High: Used in Performance Mode for aggressive cooling.
    • Medium: Balanced cooling for moderate conditions.
    • Low: Energy-efficient cooling, typical for Eco Mode.
  • Mode:
    • Performance: Optimized for maximum power output and cooling.
    • Eco: Focused on energy efficiency and extending battery life.
    • Balanced: A trade-off between performance and energy efficiency.

๐Ÿ› ๏ธ How the AI Model Works

  1. Input Features: The model takes SOC, temperature, and current as input.
  2. Prediction: Based on historical training data, the model predicts the optimal mode.
  3. Dynamic Adjustments:
    • Cooling intensity and current are adjusted dynamically based on the selected mode.
    • Warnings are generated for exceeding critical thresholds.

๐Ÿ“ˆ Advantages of AI-Based Mode Selection

  • Dynamic Decision-Making: The model adapts to real-time battery conditions for optimal performance.
  • Proactive Adjustments: Predicts potential issues and makes adjustments before they occur.
  • Improved Efficiency: Balances battery performance, efficiency, and longevity better than static thresholds.

๐Ÿค– Machine Learning Integration

This project utilizes Machine Learning (ML) for intelligent mode selection, leveraging a cutting-edge Gradient Boosting Model (GBM) for dynamic decision-making. The model predicts the optimal operational modeโ€”Performance, Eco, or Balancedโ€”based on real-time battery conditions.

๐Ÿ“Š Data Utilization

The dataset used for training includes the following features:

  • SOC (State of Charge): Battery's charge percentage.
  • Temperature (ยฐC): Real-time battery temperature.
  • Current (A): Positive for discharging, negative for charging.
  • Fan Speed (RPM): Cooling system's operational speed.
  • Mode (Target): Labeled modes (Performance, Eco, Balanced) optimized for specific conditions.

๐Ÿ› ๏ธ Mode Selection Model Training

  1. Objective:
    • Train a supervised classification model to dynamically select the optimal mode based on real-time battery data.
  2. Algorithm:
    • XGBoost (Extreme Gradient Boosting) was chosen for its speed, accuracy, and ability to handle complex, non-linear data relationships.
  3. Training Process:
    • A labeled dataset with historical battery conditions was used to train the model.
    • The model's hyperparameters were tuned using grid search to achieve optimal performance.
  4. Outcome:
    • The XGBoost model achieved high accuracy in predicting the best mode for various battery conditions.
    • Feature importance analysis revealed that Temperature and SOC are the most influential factors.

๐Ÿš€ Real-Time Integration

  • The trained XGBoost model is integrated into the system to process real-time battery data and predict the best mode on the fly.
  • Based on the selected mode:
    • Cooling intensity and current limits are dynamically adjusted.
    • Warnings are triggered when critical thresholds (e.g., temperature limits) are exceeded.

๐Ÿ” Benefits of ML-Based Mode Selection

  • Dynamic Adjustments: Modes adapt intelligently to match real-time battery conditions.
  • Optimized Performance: Balances high power output, energy efficiency, and battery health.
  • High Predictive Accuracy: XGBoost provides robust and reliable predictions even with complex datasets.

By leveraging a state-of-the-art Gradient Boosting Model, this project achieves smarter and more adaptive battery management, empowering users with seamless and efficient operation.


๐Ÿงฎ Confusion Matrix

The confusion matrix below illustrates the performance of the mode selection model, showing how accurately it predicts each mode based on the dataset:

Confusion Matrix

Purpose:

  • Highlights the model's accuracy for each mode (Performance, Eco, Balanced).
  • Identifies areas where the model performs well or needs improvement.

๐Ÿ“Š Feature Importance

Below is a bar chart showing the importance of each feature used in the mode selection model:

Feature Importance

๐ŸŽฏ Decision Boundary Visualization

The scatter plot below illustrates how the model predicts modes based on SOC and Temperature:

Decision Boundary

๐Ÿ“Š Analyzing the Plots

1. Feature Importance Plot

  • Temperature: Most critical factor for mode selection, influencing cooling and performance decisions.
  • SOC (State of Charge): Second most important, reflecting the battery's charge level and its effect on mode choice.
  • Current: Moderately significant, affecting charging and discharging scenarios.
  • Fan Speed: Least significant, possibly an indirect predictor.

Insight: Focus on improving data quality for Temperature and SOC, and consider simplifying the model by removing less significant features like Fan Speed.


2. Decision Boundary Visualization

  • Regions:
    • Pink: Performance Mode.
    • Green: Eco Mode.
    • Blue: Balanced Mode.
  • Observations:
    • Clear separation between regions indicates effective classification.
    • Slight overlap near boundaries may lead to edge case misclassifications.

Insight: Optimize the model (e.g., hyperparameter tuning) to improve boundary handling and test with real-world data to ensure robustness.


These analyses confirm the importance of the features and demonstrate the model's classification accuracy, reinforcing the ML-driven approach for mode selection.


๐Ÿ–ผ๏ธ Visualization

Below is a snapshot of real-time output based on AI-driven mode selection:

Real-Time Simulation


๐Ÿ“‚ Project Structure

AI_BMS_Optimization/
โ”‚
โ”œโ”€โ”€ data/               # Data storage
โ”‚   โ”œโ”€โ”€ raw/            # Raw input data
โ”‚   โ”œโ”€โ”€ processed/      # Preprocessed data ready for use
โ”‚   โ””โ”€โ”€ sample_input.csv # Example data for testing
โ”‚
โ”œโ”€โ”€ src/                # Source code
โ”‚   โ”œโ”€โ”€ gui.py          # GUI implementation (PyQt/Tkinter)
โ”‚   โ”œโ”€โ”€ real_time_mode_switching.py # Core script for mode switching
โ”‚   โ”œโ”€โ”€ models.py       # Includes SOC and temperature prediction models
โ”‚   โ”œโ”€โ”€ utils.py        # Helper functions (e.g., data preprocessing)
โ”‚
โ”œโ”€โ”€ docs/               # Documentation
โ”‚   โ””โ”€โ”€ README.md       # Description, usage, and instructions
โ”‚
โ”œโ”€โ”€ tests/              # Test scripts
โ”‚   โ”œโ”€โ”€ test_models.py  # Unit tests for SOC and temperature models
โ”‚
โ”œโ”€โ”€ requirements.txt    # Dependencies
โ””โ”€โ”€ .gitignore          # Ignore unnecessary files

๐Ÿ”„ Modes

Mode Description
โšก Performance Prioritizes maximum battery performance by increasing cooling and fan speed, potentially reducing battery lifespan.
๐ŸŒฑ Eco Focuses on battery longevity and energy efficiency by lowering cooling intensity and regulating power usage.
โš–๏ธ Balanced Strikes a balance between performance and efficiency with moderate cooling and power settings.
๐Ÿ› ๏ธ Custom Empowers users to define parameters like fan speed and cooling thresholds, observing real-time effects.

๐Ÿง  How It Works

  1. Real-Time Data Collection:

    • The system continuously monitors and collects real-time battery parameters, including:
      • ๐ŸŒก๏ธ Temperature
      • โšก Voltage
      • ๐Ÿ”‹ SOC (State of Charge)
      • ๐Ÿ”„ Current
      • ๐ŸŒฌ๏ธ Fan Speed
      • ๐Ÿ’ง Pump Duty Cycle
  2. AI-Powered Predictions:

    • AI models predict key battery metrics such as:
      • SOC (State of Charge)
      • Temperature trends
    • Predictions help dynamically optimize battery performance and longevity.
  3. Interactive Graphical Interface:

    • The GUI, built with PyQt5/Tkinter, allows users to:
      • Seamlessly switch between modes.
      • Visualize real-time impacts on battery performance via dynamic Matplotlib plots.

๐Ÿค– Dynamic Mode Switching

  • AI-Driven Adjustments:

    • The system automatically adjusts cooling intensity, fan speed, and other parameters based on:
      • The selected mode (Performance, Eco, Balanced, or Custom).
      • Predicted SOC and temperature from AI models.
  • Custom Mode:

    • Users can manually fine-tune settings like cooling thresholds and fan speeds.
    • The system provides real-time feedback to help users evaluate their custom configurations.

๐Ÿš€ Installation

To set up the project locally, follow these steps:

  1. Clone the repository:

git clone https://github.com/yasirusama61/AI_BMS_Optimization.git cd AI_BMS_Optimization

  1. Install the dependencies

pip install -r requirements.txt

  1. Run the GUI: To start the GUI for the mode selection interface, run:

python src/gui.py

Data Used

  • Battery Operation Data: Voltage, Current, SOC, Temperature, Pump Duty Cycle, and Fan Speed.
  • Environmental Data: Ambient temperature data (Tx) to dynamically adjust system performance.
  • Historical Performance Data: Used to train the AI models on performance metrics under different conditions.

๐Ÿ“Š Real-Time Output Example

The AI Battery Management System (AI BMS) provides real-time predictions and dynamically adjusts battery parameters based on the selected mode. Below is an example of the output generated during a simulation:

๐Ÿ” Highlighted Output

  • Mode: Balanced
  • Predicted Temperature (ยฐC): Real-time temperature predictions using the AI model.
  • Cooling: Cooling intensity automatically adjusted (Low or High).
  • Adjusted Current (A): Battery current modified dynamically.
  • Warnings: Alerts for exceeding critical thresholds.

๐Ÿ–ผ๏ธ Sample Output

Sample output readings


๐Ÿšจ What These Outputs Show

  1. Real-Time Adjustments:

    • The system adjusts cooling intensity and current dynamically based on real-time predictions.
    • High Cooling is activated when the predicted temperature exceeds the mode's threshold.
  2. Warnings:

    • Alerts (โš ๏ธ) indicate when critical thresholds (e.g., temperature limits) are exceeded.
  3. Insight into Mode Functionality:

    • The Balanced Mode prioritizes stability with controlled cooling and current.

๐Ÿ“ Insights for Developers

  • The table demonstrates the AI system's capability to adapt to dynamic battery conditions in real time.
  • Warnings help highlight potential issues that require attention, such as exceeding the temperature threshold.

๐Ÿค Contributing

We welcome contributions! Please feel free to fork the repository, submit pull requests, or report issues.

About

An AI-driven solution to optimize battery performance, efficiency, and longevity. Features include real-time mode switching (Performance, Eco, Balanced, Custom), SOC and temperature predictions, dynamic cooling adjustments, and a user-friendly GUI with interactive visualizations. Ideal for electric vehicles and energy storage systems. ๐Ÿš—๐Ÿ”‹๐Ÿ“Š

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages