A comprehensive machine learning project for predicting self-inductance (L) and mutual inductance (M) of rectangular coupled coils used in Wireless Power Transfer systems.
- Project Overview
- Key Features
- Physics Background
- Project Structure
- Installation
- Usage Guide
- Data Description
- Models
- Results
- Contributing
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:
- Analytical Modeling: Implement mathematical formulas for calculating self-inductance (L) and mutual inductance (M) of Litz wire coils
- Data Generation: Generate training datasets using analytical formulas and FEA (Finite Element Analysis) simulations
- ML Model Training: Train various ML models (Neural Networks, XGBoost, Random Forest, etc.) to predict inductance values
- Validation: Validate ML predictions against FEA simulation results
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.
- 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
| 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 |
Self-Inductance of Litz Wire:
Mutual Inductance (Neumann's Formula):
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)
- Python 3.8+
- CUDA (optional, for GPU acceleration)
-
Clone the repository:
git clone <repository-url> cd WPT
-
Create virtual environment:
python -m venv .venv .venv\Scripts\activate # Windows # source .venv/bin/activate # Linux/Mac
-
Install dependencies:
pip install -r requirements.txt
-
Additional packages (for full functionality):
pip install torch torchvision xgboost lightgbm catboost
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")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")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)Follow the numbered notebooks in order:
00_sandbox_experiments.ipynb- Explore and experiment01_neural_network_inductance_prediction.ipynb- Train neural networks02_ml_model_training_comparison.ipynb- Compare different ML models03_parametric_study_analysis.ipynb- Analyze parameter sensitivity04_pytorch_neural_network_theory.ipynb- Understand NN theory05_final_model_evaluation.ipynb- Evaluate final models
| 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 |
| Target | Description | Unit |
|---|---|---|
L |
Self-inductance | μH |
M |
Mutual inductance | μH |
- Analytical Data: Generated using Neumann's formula implementations
- FEA Data: ANSYS Maxwell electromagnetic simulations
- MATLAB Data: Cross-validation from MATLAB implementations
| 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 |
Input Layer (8 neurons) → Dense(64, ReLU) → Dense(64, ReLU) → Output(1)
| 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 |
- XGBoost provides the best accuracy for inductance prediction
- Neural Networks offer flexibility for transfer learning from analytical to FEA data
- Air gap (h) is the most influential parameter for mutual inductance
- ML models reduce computation time by 1000x compared to FEA simulations
- Fork the repository
- Create a feature branch (
git checkout -b feature/new-feature) - Commit changes (
git commit -am 'Add new feature') - Push to branch (
git push origin feature/new-feature) - Create Pull Request
- Neumann's Formula for Mutual Inductance
- Litz Wire Self-Inductance Calculations
- ANSYS Maxwell Electromagnetic Simulation
Last Updated: December 2024