Revolutionising electromagnetic metamaterial design through AI-driven physics simulation
This project demonstrates a cutting-edge approach to modelling surface plasmon polaritons (SPPs) on metamaterial interfaces using Physics-Informed Neural Networks (PINNs). By embedding Maxwell's equations directly into the neural network training process, we achieve unprecedented accuracy in predicting complex electromagnetic phenomena without requiring extensive experimental data.
Traditional numerical methods for electromagnetic simulation face significant challenges when dealing with metamaterials:
- Computational complexity scales poorly with frequency and structure size
- Mesh requirements become prohibitive for subwavelength features
- Convergence issues arise near plasmonic resonances
- Limited generalisability across parameter spaces
Our PINN approach overcomes these limitations by learning the underlying physics directly, enabling:
- โก Real-time field prediction across arbitrary geometries
- ๐ฏ Mesh-free computation with automatic differentiation
- ๐ Inverse design capabilities for optimal metamaterial parameters
- ๐ Scalable simulation from nanoscale to macroscale structures
SPPs are electromagnetic waves that propagate along metal-dielectric interfaces, combining light with collective electron oscillations. In metamaterials, these can be engineered to achieve:
- Subwavelength confinement beyond the diffraction limit
- Enhanced field intensities for sensing and nonlinear optics
- Negative refractive indices for cloaking applications
- Broadband operation through dispersion engineering
The electromagnetic behaviour is governed by:
โ ร E = -iฯฮผโH (Faraday's law)
โ ร H = iฯฮตโฮตแตฃE (Ampรจre's law)
โ ยท (ฮตแตฃE) = 0 (Gauss's law)
โ ยท H = 0 (No magnetic monopoles)
For uniaxial metamaterials with optical axis along แบ:
ฮตแตฃ = [ฮตโฅ 0 0 ]
[0 ฮตโฅ 0 ]
[0 0 ฮตโฅ]
Where ฮตโฅ and ฮตโฅ are engineered through subwavelength structuring.
Our PINN architecture directly embeds physical laws into the loss function:
L_total = ฮปโL_maxwell + ฮปโL_boundary + ฮปโL_data + ฮปโL_initial- L_maxwell: Residuals of Maxwell's equations at collocation points
- L_boundary: Interface boundary conditions (E/H field continuity)
- L_data: Sparse experimental/simulation data (when available)
- L_initial: Initial conditions for time-dependent problems
spp_metamaterial_pinn/
โโโ ๐ฌ src/physics/ # Core electromagnetic physics
โ โโโ maxwell_equations.py # Frequency-domain Maxwell solver
โ โโโ metamaterial.py # Anisotropic constitutive relations
โ โโโ boundary_conditions.py # Interface continuity conditions
โ
โโโ ๐ง src/models/ # Neural network architectures
โ โโโ pinn_network.py # Main PINN implementation
โ โโโ loss_functions.py # Physics-informed loss computation
โ
โโโ ๐ src/data/ # Data handling and sampling
โ โโโ domain_sampler.py # Collocation point generation
โ โโโ collocation_points.py # Adaptive sampling strategies
โ
โโโ ๐ ๏ธ src/utils/ # Utilities and visualisation
โ โโโ plotting.py # Field visualisation tools
โ โโโ metrics.py # Performance assessment
โ
โโโ โ๏ธ config/ # Configuration management
โ โโโ base_config.yaml # Default parameters
โ โโโ metamaterial_params.yaml # Material properties
โ
โโโ ๐งช tests/ # Comprehensive test suite
โ โโโ test_physics.py # Physics validation tests
โ
โโโ ๐ notebooks/ # Interactive analysis
โ โโโ model_validation.ipynb # Physics verification
โ โโโ results_analysis.ipynb # Performance evaluation
โ
โโโ ๐ scripts/ # Training and evaluation
โโโ train.py # Main training script
โโโ evaluate.py # Model assessment
- No spatial discretisation required
- Automatic handling of complex geometries
- Adaptive resolution based on field gradients
- Forward pass inference in milliseconds
- Enables interactive design exploration
- Suitable for real-time optimization loops
- Optimize metamaterial parameters for target responses
- Discover novel plasmonic structures
- Multi-objective design optimization
- Seamless transition from nanoscale to macroscale
- Handles both local field enhancement and far-field radiation
- Automatic resolution adaptation
- Real-time field plotting with interactive controls
- 3D electromagnetic field rendering
- Dispersion relation visualisation
- Poynting vector flow analysis
# Clone the repository
git clone https://github.com/yourusername/spp-metamaterial-pinn.git
cd spp-metamaterial-pinn
# Install the project and its dependencies
# For users:
pip install .
# For developers (editable install):
pip install -e .python validate_physics.pyfrom src.physics import MaxwellEquations, MetamaterialProperties
from src.models import SPPNetwork
# Define metamaterial
metamaterial = MetamaterialProperties(
eps_parallel=-2.0 + 0.1j,
eps_perpendicular=4.0 + 0.05j,
optical_axis='z'
)
# Initialize PINN
network = SPPNetwork(layers=[3, 64, 64, 64, 6])
# Train on domain
trainer = PINNTrainer(network, metamaterial)
trainer.train(epochs=10000)
# Predict fields
E_field, H_field = network.predict(coordinates)We leverage PyTorch's automatic differentiation to compute spatial derivatives:
def curl_operator(self, field, coords):
"""Compute โ ร field using automatic differentiation."""
# Partial derivatives computed via autodiff
dFz_dy = torch.autograd.grad(Fz, coords, create_graph=True)[0][:, 1]
# ... (curl computation)
return curlSmart collocation point placement based on:
- Residual magnitude: Higher density where physics violations occur
- Field gradients: Enhanced resolution near interfaces
- Geometric features: Automatic refinement around sharp boundaries
Carefully balanced multi-term loss ensures physical consistency:
L = ฮปโโโรE + iฯฮผโHโยฒ + ฮปโโโรH - iฯฮตโฮตแตฃEโยฒ +
ฮปโโboundary_conditionsโยฒ + ฮปโโtraining_dataโยฒThis project is licensed under the MIT License - see the LICENSE file for details.
- Funding: URF\R1\231460
- Inspiration: The metamaterials and machine learning communities
Author: Dr Robert Michael Jones
Email: robert.m.jones@kcl.ac.uk
Institution: Department of Physics, King's College London
ORCID: 0000-0002-5422-3088
โญ Star this repository if you find it useful! โญ
Advancing the frontiers of computational electromagnetics through AI