Skip to content

JonesRobM/Metamaterials_PINN

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

39 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

Surface Plasmon Polaritons on Metamaterials via Physics-Informed Neural Networks

Python PyTorch License: MIT

Revolutionising electromagnetic metamaterial design through AI-driven physics simulation

๐Ÿ”ฌ Overview

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.

Why This Matters

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

๐Ÿงฎ The Physics

Surface Plasmon Polaritons

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

Maxwell's Equations in Frequency Domain

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)

Metamaterial Constitutive Relations

For uniaxial metamaterials with optical axis along แบ‘:

ฮตแตฃ = [ฮตโŠฅ  0   0 ]
     [0   ฮตโŠฅ  0 ]  
     [0   0   ฮตโˆฅ]

Where ฮตโŠฅ and ฮตโˆฅ are engineered through subwavelength structuring.


๐Ÿ—๏ธ Architecture

๐Ÿง  Physics-Informed Neural Network

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

๐Ÿ“ Project Structure

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

โœจ Key Features

๐ŸŽฏ Mesh-Free Simulation

  • No spatial discretisation required
  • Automatic handling of complex geometries
  • Adaptive resolution based on field gradients

โšก Real-Time Prediction

  • Forward pass inference in milliseconds
  • Enables interactive design exploration
  • Suitable for real-time optimization loops

๐Ÿ”„ Inverse Design Capability

  • Optimize metamaterial parameters for target responses
  • Discover novel plasmonic structures
  • Multi-objective design optimization

๐Ÿ“ Multi-Scale Modelling

  • Seamless transition from nanoscale to macroscale
  • Handles both local field enhancement and far-field radiation
  • Automatic resolution adaptation

๐ŸŽจ Sophisticated Visualisation

  • Real-time field plotting with interactive controls
  • 3D electromagnetic field rendering
  • Dispersion relation visualisation
  • Poynting vector flow analysis

๐Ÿš€ Quick Start

Installation

# 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 .

Validate physics implementation

python validate_physics.py

Basic Usage

from 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)

๐Ÿ› ๏ธ Technical Details

Automatic Differentiation

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 curl

Adaptive Sampling

Smart 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

Loss Function Design

Carefully balanced multi-term loss ensures physical consistency:

L = ฮปโ‚โ€–โˆ‡ร—E + iฯ‰ฮผโ‚€Hโ€–ยฒ + ฮปโ‚‚โ€–โˆ‡ร—H - iฯ‰ฮตโ‚€ฮตแตฃEโ€–ยฒ + 
    ฮปโ‚ƒโ€–boundary_conditionsโ€–ยฒ + ฮปโ‚„โ€–training_dataโ€–ยฒ

๐Ÿ“„ License

This project is licensed under the MIT License - see the LICENSE file for details.


๐Ÿ™ Acknowledgments

  • Funding: URF\R1\231460
  • Inspiration: The metamaterials and machine learning communities

๐Ÿ“ž Contact

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

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published