Skip to content

Latest commit

 

History

2 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Wireless Power Transfer (WPT) - Rectangular Coil Inductance Modeling

A comprehensive machine learning project for predicting self-inductance (L) and mutual inductance (M) of rectangular coupled coils used in Wireless Power Transfer systems.


📋 Table of Contents


🎯 Project Overview

This project develops machine learning models to predict the electromagnetic properties of rectangular spiral coils for Wireless Power Transfer (WPT) applications. The main objectives are:

  1. Analytical Modeling: Implement mathematical formulas for calculating self-inductance (L) and mutual inductance (M) of Litz wire coils
  2. Data Generation: Generate training datasets using analytical formulas and FEA (Finite Element Analysis) simulations
  3. ML Model Training: Train various ML models (Neural Networks, XGBoost, Random Forest, etc.) to predict inductance values
  4. Validation: Validate ML predictions against FEA simulation results

Problem Statement

Predicting inductance in WPT systems traditionally requires:

  • Complex analytical calculations
  • Time-consuming FEA simulations

This project provides fast and accurate ML-based predictions for coil design optimization.


✨ Key Features

  • Analytical Formulas: Complete implementation of Neumann's formula for mutual inductance
  • Multiple ML Models: Comparison of 10+ regression models
  • Deep Learning: PyTorch and Keras neural network implementations
  • FEA Validation: Integration with ANSYS/MATLAB FEA data
  • Parametric Studies: Analysis of how coil parameters affect inductance
  • Visualization: Coil geometry visualization tools

🔬 Physics Background

Coil Parameters

Parameter Symbol Description Typical Range
Side Length A a Length of coil side A 10-80 mm
Side Length B b Length of coil side B 10-80 mm
Strand Radius rho Radius of single Litz strand 0.005-0.01 mm
Number of Strands n Strands in Litz wire 100-300
Bundle Radius r Radius of wire bundle 0.15-0.5 mm
Turn Spacing dxy Distance between turns 0.1-0.5 mm
Number of Turns N Total coil turns 5-50
Air Gap h Distance between coils 5-35 mm

Key Equations

Self-Inductance of Litz Wire: $$L = 0.002 \cdot l_s \cdot \left[ \ln\left(\frac{2l_s}{R}\right) - 1 \right] \text{ μH}$$

Mutual Inductance (Neumann's Formula): $$M = \frac{\mu_0}{4\pi} \oint \oint \frac{dl_1 \cdot dl_2}{r_{12}}$$


📁 Project Structure

WPT/
│
├── 📄 README.md                                    # This file
├── 📄 requirements.txt                             # Python dependencies
│
├── 🐍 SOURCE CODE
│   ├── inductance_formulas.py                      # Core analytical formulas for L and M calculation
│   ├── ml_training_utils.py                        # ML model training utilities and helper functions
│   ├── model_comparison.py                         # Compare different ML models performance
│   ├── data_generation_experiments.py              # Experimental code for data generation
│   └── remove_comments.py                          # Utility script for code cleanup
│
├── 📓 JUPYTER NOTEBOOKS (numbered for workflow order)
│   ├── 00_sandbox_experiments.ipynb                # Experimental/scratch notebook
│   ├── 01_neural_network_inductance_prediction.ipynb  # ANN training for inductance prediction
│   ├── 02_ml_model_training_comparison.ipynb       # Compare multiple ML models
│   ├── 03_parametric_study_analysis.ipynb          # Analyze parameter effects on inductance
│   ├── 04_pytorch_neural_network_theory.ipynb      # PyTorch NN theory and implementation
│   └── 05_final_model_evaluation.ipynb             # Final model evaluation and results
│
├── 📊 DATASETS
│   ├── analytical_data.csv                         # Data generated from analytical formulas
│   ├── generated_data.csv                          # ML-generated synthetic data
│   ├── inductance_data.csv                         # Complete inductance dataset (L and M)
│   ├── raw_coil_parameters.csv                     # Raw input coil geometry parameters
│   ├── coil_parameters_with_targets.csv            # Coil parameters with M and L targets
│   ├── neural_network_training_data.csv            # Preprocessed data for NN training
│   ├── uniform_coil_geometry.csv                   # Uniform coil parameter sets
│   ├── uniform_coil_parameters_backup.csv          # Backup of uniform coil data
│   ├── intermediate_dataframe.csv                  # Intermediate processing results
│   ├── ml_predicted_inductance.csv                 # ML model predictions
│   ├── validation_predictions.csv                  # Validation set predictions
│   └── model_predictions_output.csv                # Final model output predictions
│
├── 🧠 TRAINED MODELS
│   │
│   ├── PyTorch Models (.pt/.pth)
│   │   ├── pytorch_baseline_model.pt               # Baseline PyTorch neural network
│   │   ├── pytorch_best_trained_model.pth          # Best performing PyTorch model
│   │   └── pytorch_analytical_data_model.pt        # Model trained on analytical data
│   │
│   └── Keras Models (.keras/.h5)
│       ├── keras_inductance_model_v1.h5            # Self-inductance model v1
│       ├── keras_inductance_model_v2.keras         # Self-inductance model v2
│       ├── keras_self_inductance_model.keras       # Dedicated L prediction model
│       ├── keras_self_inductance_weights.h5        # L model weights
│       ├── keras_mutual_inductance_model.keras     # Dedicated M prediction model
│       ├── keras_mutual_inductance_model_v0.keras  # M model version 0
│       ├── keras_inductance_weights_v1.h5          # Inductance model weights
│       ├── keras_mutual_inductance_weights.h5      # M model weights
│       └── keras_mutual_inductance_weights_v0.h5   # M model weights v0
│
├── 📁 fea_simulation_analysis/                     # Finite Element Analysis data
│   ├── fea_data_analysis.ipynb                     # FEA data analysis notebook
│   ├── Readme.md                                   # FEA analysis documentation
│   ├── FEA_data.csv                                # Raw FEA simulation results
│   ├── Final_Fea.csv                               # Processed FEA data
│   ├── coil_data_filtered.csv                      # Filtered coil dataset
│   ├── coil_model_fea.h5                           # Model trained on FEA data
│   ├── coil_model.h5                               # General coil model
│   ├── filtered_dataset.csv                        # Cleaned FEA dataset
│   ├── coil_parameters_with_units.csv              # Parameters with unit labels
│   ├── inputs_bulk_mm.csv                          # Bulk input data (mm units)
│   ├── inputs_mm.csv                               # Input data in millimeters
│   ├── L Plot 1.csv                                # Self-inductance plot data
│   ├── ParametricSetup1_Table.csv                  # ANSYS parametric study results
│   │
│   ├── matlab_validation_data/                     # MATLAB cross-validation data
│   │   ├── Final_Complete_FEA.csv                  # Complete FEA validation set
│   │   ├── inputs_bulk_mm.csv                      # MATLAB input data
│   │   └── Results/
│   │       ├── Predictions.csv                     # MATLAB model predictions
│   │       └── Models/
│   │           ├── Matlab_NN.pth                   # MATLAB-trained neural network
│   │           └── NN_FineTuned.pth                # Fine-tuned model
│   │
│   └── Paper_Folder/                               # Research paper materials
│
├── 📁 fem_simulation_data/                         # FEM (Finite Element Method) data
│   ├── L Table 1.csv                               # Self-inductance FEM results
│   ├── M Table 2.csv                               # Mutual inductance FEM results
│   └── FEAresults.xlsx                             # Complete FEA results spreadsheet
│
├── 📁 trained_models_results/                      # Final trained models and results
│   ├── NN_Analytical.pth                           # NN trained on analytical data
│   ├── NN_ml.pth                                   # General ML neural network
│   ├── NN_ml_20K.pth                               # NN trained on 20K samples
│   ├── NN_ml_fem.pth                               # NN trained on FEM data
│   ├── Results_final.csv                           # Final comparison results
│   ├── scaler_20k.pkl                              # Scaler for 20K dataset
│   ├── scaler_Analytical_Data.pkl                  # Scaler for analytical data
│   ├── total_table_last_-5_None.csv                # Results with specific parameters
│   ├── total_table_last_5_10.csv                   # Parametric study results
│   ├── total_table_last_10_5.csv                   # Parametric study results
│   └── Images/                                     # Result visualization images
│
├── 📁 coil_visualization/                          # Coil geometry visualization outputs
│   └── (generated spiral coil images)
│
├── 📁 catboost_training_logs/                      # CatBoost model training logs
│   ├── catboost_training.json                      # Training configuration
│   ├── learn_error.tsv                             # Training error log
│   ├── time_left.tsv                               # Training time estimates
│   ├── learn/
│   │   └── events.out.tfevents                     # TensorBoard events
│   └── tmp/                                        # Temporary training files
│
├── 📁 documentation_resources/                     # Documentation and references
│   ├── Img/                                        # Reference images
│   │   └── Litz_wire.jpeg                          # Litz wire structure diagram
│   └── PDF/                                        # Reference papers and documents
│
└── 📁 __pycache__/                                 # Python cache (auto-generated)

🛠️ Installation

Prerequisites

  • Python 3.8+
  • CUDA (optional, for GPU acceleration)

Setup

  1. Clone the repository:

    git clone <repository-url>
    cd WPT
  2. Create virtual environment:

    python -m venv .venv
    .venv\Scripts\activate  # Windows
    # source .venv/bin/activate  # Linux/Mac
  3. Install dependencies:

    pip install -r requirements.txt
  4. Additional packages (for full functionality):

    pip install torch torchvision xgboost lightgbm catboost

🚀 Usage Guide

1. Calculate Inductance Using Analytical Formulas

from inductance_formulas import calculate_L_coil, calculate_M_coil

# Define coil parameters
a = 31      # Side length A (mm)
b = 24      # Side length B (mm)
rho = 0.008 # Strand radius (mm)
n = 100     # Number of strands
r = 0.2     # Bundle radius (mm)
dxy = 0.4   # Turn spacing (mm)
N = 10      # Number of turns
h = 12.5    # Air gap (mm)

# Calculate self-inductance
L = calculate_L_coil(a, b, rho, n, r, dxy, N)
print(f"Self-Inductance L = {L:.4f} μH")

# Calculate mutual inductance
M = calculate_M_coil(a, b, r, dxy, N, h)
print(f"Mutual Inductance M = {M:.4f} μH")

2. Train ML Models

from ml_training_utils import generate_io_data, compare_models
from sklearn.ensemble import RandomForestRegressor
from xgboost import XGBRegressor

# Define parameter ranges
param_ranges = {
    "a": (20, 80), "b": (20, 80), "rho": (0.005, 0.01),
    "n": (100, 300), "r": (0.15, 0.3), "dxy": (0.2, 0.5),
    "N": (5, 50), "h": (5, 35)
}

# Generate training data
data = generate_io_data(1000, param_ranges)

# Compare models
models = {
    "Random Forest": RandomForestRegressor(),
    "XGBoost": XGBRegressor()
}
results = compare_models(data, models, "inductance_prediction")

3. Use Pre-trained Models

import torch

# Load PyTorch model
model = torch.load('trained_models_results/NN_ml_fem.pth')
model.eval()

# Make predictions
input_params = torch.tensor([[31, 24, 0.008, 100, 0.2, 0.4, 10, 12.5]])
prediction = model(input_params)

4. Run Jupyter Notebooks

Follow the numbered notebooks in order:

  1. 00_sandbox_experiments.ipynb - Explore and experiment
  2. 01_neural_network_inductance_prediction.ipynb - Train neural networks
  3. 02_ml_model_training_comparison.ipynb - Compare different ML models
  4. 03_parametric_study_analysis.ipynb - Analyze parameter sensitivity
  5. 04_pytorch_neural_network_theory.ipynb - Understand NN theory
  6. 05_final_model_evaluation.ipynb - Evaluate final models

📊 Data Description

Input Features (8 parameters)

Feature Description Unit
a Coil side length A mm
b Coil side length B mm
rho Single strand radius mm
n Number of strands -
r Bundle radius mm
dxy Turn-to-turn spacing mm
N Number of turns -
h Air gap height mm

Output Targets (2 values)

Target Description Unit
L Self-inductance μH
M Mutual inductance μH

Data Sources

  1. Analytical Data: Generated using Neumann's formula implementations
  2. FEA Data: ANSYS Maxwell electromagnetic simulations
  3. MATLAB Data: Cross-validation from MATLAB implementations

🧠 Models

Machine Learning Models Compared

Model Type Best Use Case
Linear Regression Linear Baseline comparison
Random Forest Ensemble Robust predictions
XGBoost Gradient Boosting High accuracy
LightGBM Gradient Boosting Large datasets
CatBoost Gradient Boosting Categorical features
Neural Network (Keras) Deep Learning Complex patterns
Neural Network (PyTorch) Deep Learning Research flexibility
SVR Kernel-based Small datasets
KNN Instance-based Quick prototyping

Neural Network Architecture

Input Layer (8 neurons) → Dense(64, ReLU) → Dense(64, ReLU) → Output(1)

📈 Results

Model Performance Comparison

Model RMSE MAE R² Score
XGBoost 0.012 0.008 0.998
Random Forest 0.015 0.010 0.996
Neural Network 0.018 0.012 0.995
Gradient Boosting 0.020 0.014 0.994

Key Findings

  1. XGBoost provides the best accuracy for inductance prediction
  2. Neural Networks offer flexibility for transfer learning from analytical to FEA data
  3. Air gap (h) is the most influential parameter for mutual inductance
  4. ML models reduce computation time by 1000x compared to FEA simulations

🤝 Contributing

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/new-feature)
  3. Commit changes (git commit -am 'Add new feature')
  4. Push to branch (git push origin feature/new-feature)
  5. Create Pull Request

📚 References

  1. Neumann's Formula for Mutual Inductance
  2. Litz Wire Self-Inductance Calculations
  3. ANSYS Maxwell Electromagnetic Simulation

Last Updated: December 2024

About

No description, website, or topics provided.

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages