Skip to content

conect2ai/PINN-TinyML

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

19 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

   

 

Physics-Informed Neural Networks at the Edge for State-of-Charge Battery Prediction in Electric Vehicles

This repository contains the code, datasets, and resources for the paper "Physics-Informed Neural Networks at the Edge for State-of-Charge Battery Prediction in Electric Vehicles", published in IEEE Transactions on Vehicular Technology. The study presents a Physics-Informed Neural Network (PINN) framework designed for accurate, efficient, and physically consistent battery state-of-charge (SoC) estimation in electric vehicles, optimized for deployment on resource-constrained edge devices via the OBD-II interface.

📁 Repository structure:

PINN-TinyML
├── src/
│   ├── code/
│   │   └── arduino/                 # Embedded inference code (TinyML)
│   ├── data/
│   │   ├── clean/                   # Preprocessed datasets
│   │   └── raw/                     # Raw driving-cycle data
│   ├── notebooks/
│   │   ├── 01_eda.ipynb              # Exploratory Data Analysis
│   │   ├── 02_model_generator.ipynb  # Model training & quantization
│   │   └── 03_analysis.ipynb         # Performance and energy analysis
│   ├── python/
│   │   ├── extended_kalman_soc_estimator.py
│   │   ├── kalman_soc_estimator.py
│   │   ├── mlp.py                   # Baseline data-driven model
│   │   └── pinn.py                  # Physics-Informed Neural Network
│   ├── figures/
│   │   ├── conecta_logo.png
│   │   ├── heatmap_normalized_methods.pdf
│   │   └── method_comparison_bars.pdf
│   └── results/                     # Experimental outputs
├── .gitignore
├── LICENSE
├── README.md
└── requirements.txt

📤 Installation

  • Python 3.9.6 is required (validated for reproducibility).

Clone the repository and create a virtual environment:

git clone https://github.com/<your-org>/PINN-TinyML.git
cd PINN-TinyML
python -m venv myenv

Activate the environment:

myenv\Scripts\activate   # Windows
source myenv/bin/activate # Linux / macOS

Install dependencies:

pip install -r requirements.txt

🚗 Dataset

The study uses the Downloadable Dynamometer Database (D3) from Argonne National Laboratory, containing telemetry data from nine electric vehicle models (Table II). Data includes:

  • Battery current
  • Voltage
  • Temperature
  • Vehicle speed
  • Accelerator position
  • Timestamped SoC ground truth

Access the dataset: D3 Database

Preprocessing steps include outlier removal (IQR), missing value interpolation, and min-max normalization.

🧠 Proposed Approach

The proposed Physics-Informed Neural Network (PINN) integrates a first-order ordinary differential equation (ODE), derived from charge conservation, directly into the loss function to enforce physical consistency during training.

The model is optimized for TinyML deployment through the following strategies:

  • Physics-constrained loss with a tunable weighting factor $\lambda_{\text{PDE}}$

  • Post-training quantization for edge efficiency

    • Int8
    • Float32
  • Embedded deployment on the Macchina A0 platform via the OBD-II interface

Research Questions

The study addresses the following research questions (RQs):

The proposed Physics-Informed Neural Network (PINN) integrates a first-order ODE (charge conservation) into the loss function to enforce physical consistency. The model is optimized for TinyML deployment through:

  • Physics-constrained loss with tunable weight $\lambda_{\text{PDE}}$

  • Post-training quantization (Int8, Float32) for edge devices

  • Embedded deployment on Macchina A0 via the OBD-II interface

📚 Codes

Python

  • Jupyter Extended Kalman Filter (EKF)

  • Jupyter Kalman Filter (KF)

  • Jupyter Physics-Informed Neural Networks (PINN)

  • Jupyter Multilayer Perceptron (MLP)

Jupyter Notebooks

  • Python Exploratory analysis of battery and driving data

  • Python Training, physics-informed loss configuration, and quantization

  • Python Comparative evaluation of prediction accuracy, inference time, memory usage, and energy consumption and energy consumption

Arduino Code

  • Jupyter Extended Kalman Filter (EKF)

  • Jupyter Kalman Filter (KF)

  • Jupyter Physics-Informed Neural Networks (PINN) and Multilayer Perceptron (MLP)

📊 Results Overview

Key findings demonstrated in the paper include :

Model RMSE (mean) Inference Time (ms) Memory Footprint (Flash / RAM)
PINN (Int8) 0.009 12.4 ms 39.8 kB / 12.3 kB
MLP (Int8) 0.034 11.2 ms 38.1 kB / 11.9 kB
Kalman Filter 0.121 0.8 ms < 1 kB
Extended KF 36.954 1.9 ms < 1 kB

Key Findings

  • PINN reduces RMSE by 74% compared to MLP.
  • Physics regularization improves generalization and stability.
  • Int8 quantization reduces inference time by 86% with minimal accuracy loss.
  • PINN meets real-time OBD-II requirements (1 Hz update rate).

🧠 Conclusion

  • Physics-Informed Neural Networks provide:

    • Higher robustness and generalization
    • Improved interpretability
    • Better suitability for safety-critical EV applications
  • The proposed PINN architecture is:

    • Compatible with TinyML deployment
    • Energy-efficient
    • Scalable to real-world embedded systems

📄 License

This package is licensed under the MIT License - © 2023 Conect2ai.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors