Note: This is a fork of the original NanoComp/meep repository. This fork adds an original Spherical Cow Cloak study (Pendry-style transformation-optics invisibility cloak with full FDTD stability analysis), plus comprehensive documentation including a Four-Approach Cloaking Comparison: 148 Physics Tutorials with theory and code walkthroughs for every Python example and test, an Architecture Guide, a Developer Guide, a User Guide with 10 educational use cases and Windows installation instructions, a Quick Start Explained walkthrough, and a Test Report from running all 148 Python examples and tests. All original source code remains unchanged.
Meep is a free and open-source software package for electromagnetics simulation via the finite-difference time-domain (FDTD) method spanning a broad range of applications.
- Free and open-source software under the GNU GPL.
- Complete scriptability via Python, Scheme, or C++ APIs.
- Simulation in 1d, 2d, 3d, and cylindrical coordinates.
- Distributed memory parallelism on any system supporting MPI.
- Portable to any Unix-like operating system such as Linux, macOS, and FreeBSD.
- Precompiled binary packages of official releases via Conda.
- Variety of arbitrary material types: anisotropic electric permittivity ε and magnetic permeability μ, along with dispersive ε(ω) and μ(ω) including loss/gain, nonlinear (Kerr & Pockels) dielectric and magnetic materials, electric/magnetic conductivities σ, saturable gain/absorption, and gyrotropic media (magneto-optical effects).
- Materials library containing predefined broadband, complex refractive indices.
- Perfectly matched layer (PML) absorbing boundaries as well as Bloch-periodic and perfect-conductor boundary conditions.
- Exploitation of symmetries to reduce the computation size, including even/odd mirror planes and 90°/180° rotations.
- Subpixel smoothing for improving accuracy and shape optimization.
- Custom current sources with arbitrary time and spatial profile as well as a mode launcher for waveguides and planewaves, and Gaussian beams.
- Frequency-domain solver for finding the response to a continuous-wave (CW) source as well as a frequency-domain eigensolver for finding resonant modes.
- ε/μ and field import/export in the HDF5 data format.
- GDSII file import for planar geometries.
- Field analyses including discrete-time Fourier transform (DTFT), Poynting flux, mode decomposition (for S-parameters), energy density, near to far transformation, frequency extraction, local density of states (LDOS), modal volume, scattering cross section, Maxwell stress tensor, absorbed power density, arbitrary functions; completely programmable.
- Adjoint solver for inverse design and topology optimization.
- Visualization routines for the simulation domain involving geometries, fields, boundary layers, sources, and monitors.
Featured study -- Can you cloak a spherical cow? This fork investigates Pendry's transformation-optics invisibility cloak using Meep's FDTD engine, pushing it to its stability limits and documenting exactly where and why it breaks.
Ez field cross-sections comparing an empty reference (undisturbed plane wave), a bare dielectric sphere (strong scattering shadow), and a cloaked sphere. The cloak bends wavefronts around the object, but heavy regularization required for Yee-grid stability limits the cloaking effectiveness. See the Visualization Guide for a detailed walkthrough of how to read these plots.
- Transformation optics implementation -- Full Pendry cloak with anisotropic, inhomogeneous epsilon/mu tensors derived from the coordinate mapping r' = R1 + r(R2-R1)/R2, converted from cylindrical to Cartesian coordinates at every grid point
- Mie theory validation -- Bare-sphere scattering cross-section matches analytical Mie series to <1% error, confirming the simulation methodology is correct
- Yee grid stability analysis -- Systematic measurement of the FDTD stability boundary: off-diagonal permittivity components exceeding ~1.3x the diagonal cause unconditional instability that cannot be fixed by reducing the Courant number
- Regularization trade-off -- The minimum stable regularization (eps_min >= 0.55) flattens the gradient-index profile that the cloak relies on, destroying the cloaking effect. This is a fundamental FDTD limitation, not a bug.
- Alternative approaches -- The 2D cylindrical implementation achieves stable cloaking with full eps+mu tensors, demonstrating that the physics works when the numerics cooperate
| File | Approach | Key Result |
|---|---|---|
spherical_cow_cloak.py |
3D reduced-parameter cloak | Mie-validated scattering; documents Yee grid stability limits |
spherical_cow_cloak_2d.py |
2D full Pendry cloak (eps+mu) | Stable cloaking with anisotropic tensors in 2D |
spherical_cow_cloak_viz.py |
Visualization suite | Field maps, scattering spectra, 3D plotly, GIF animation |
spherical_cow_cloak_comparison.py |
Four-approach comparison (3D cancellation, 2D Pendry, multi-shell, carpet) | Successfully cloaks a true 3D sphere; head-to-head comparison of all methods |
| Guide | What you'll learn |
|---|---|
| Cloak Simulation Report | Full technical analysis: Yee grid stability measurements, Courant number experiments, regularization trade-offs, and 5 mitigation strategies |
| Visualization Guide | How to read the field plots and scattering spectra, relate them to the physics, and judge whether results make sense |
| Cloaking Comparison Guide | Physics behind all four cloaking approaches, how to read comparison plots, and which method to use when |
# Quick run (3D, ~12 seconds)
python python/examples/spherical_cow_cloak.py --quick --cow-material dielectric
# 2D simulation (full Pendry cloak)
python python/examples/spherical_cow_cloak_2d.py
# Generate all visualizations from saved data
python python/examples/spherical_cow_cloak_viz.py
# Four-approach comparison (3D + 2D, ~5-8 min)
python python/examples/spherical_cow_cloak_comparison.py --method all --quickThe fastest way to get started on Linux or macOS is through the conda-forge channel (Windows users: install via WSL2):
conda create -n mp -c conda-forge pymeep
conda activate mpFor MPI-parallel support, install the MPICH variant instead:
conda create -n pmp -c conda-forge pymeep=*=mpi_mpich_*
conda activate pmpSave the following as my_first_sim.py:
import meep as mp
import matplotlib.pyplot as plt
# Simulation cell: 16 x 8 micrometers with PML absorbing boundaries
cell = mp.Vector3(16, 8)
pml_layers = [mp.PML(1.0)]
# A dielectric waveguide (epsilon=12) running along the x-axis
geometry = [
mp.Block(size=mp.Vector3(mp.inf, 1, mp.inf),
center=mp.Vector3(),
material=mp.Medium(epsilon=12))
]
# Gaussian pulse source exciting the Hz field at one end of the guide
sources = [
mp.Source(mp.GaussianSource(frequency=0.15, fwidth=0.1),
component=mp.Hz,
center=mp.Vector3(-7))
]
sim = mp.Simulation(cell_size=cell,
boundary_layers=pml_layers,
geometry=geometry,
sources=sources,
resolution=10)
sim.run(until=100)
# Plot the Hz field
sim.plot2D(fields=mp.Hz)
plt.savefig("waveguide_hz.png", dpi=150)
print("Field plot saved to waveguide_hz.png")Run the simulation with:
python my_first_sim.pyFor more examples and step-by-step tutorials, see the online manual.
We ran all 148 Python files from python/examples/ and python/tests/ against pymeep 1.31.0 on Python 3.13 with NumPy 2.x under WSL2. See guides/TEST_REPORT.md for the full report.
| Result | Count | Pct |
|---|---|---|
| Pass | 76 | 51% |
| Fail | 25 | 17% |
| Timeout | 47 | 32% |
None of the 25 failures are bugs in meep itself. All are caused by environment issues:
| Root Cause | Files | Fix |
|---|---|---|
Missing parameterized package |
10 | pip install parameterized |
| NumPy 2.x removed APIs | 2 | np.trapz → np.trapezoid, np.complex_ → np.complex128 |
Missing h5topng tool |
2 | sudo apt install h5utils |
| Missing data files | 2 | Needs pre-generated data or companion script |
| Scripts requiring CLI args | 3 | Not bugs — run with required arguments |
| Outdated example API calls | 4 | Needs upstream fixes (API signature changes) |
| Missing optional packages | 2 | pip install gdspy / pip install jax |
The 47 timeouts are due to CPU contention from parallel batch execution, not actual hangs. Files that timed out in one run frequently passed in the other.
Quick fix for the most common issue:
pip install parameterized # fixes 10 of 25 failures
sudo apt install h5utils # fixes 2 more| Resource | Description |
|---|---|
| guides/tutorials/ | 148 Physics Tutorials: deep-dive theory + code walkthroughs for every Python example and test |
| guides/QUICKSTART_EXPLAINED.md | Quick Start Explained: physics, simulation setup, and results walkthrough |
| guides/USER_GUIDE.md | User Guide: installation, tutorials, and 10 worked use cases |
| guides/DEVELOPER_GUIDE.md | Developer Guide: building from source, testing, and contributing |
| guides/ARCHITECTURE.md | Architecture Documentation: system design, diagrams, and code reference |
| guides/TEST_REPORT.md | Test Report: results from running all 148 Python examples and tests |
| guides/CLOAK_SIMULATION_REPORT.md | Cloak Report: FDTD limitations, Yee grid stability analysis, and mitigation strategies |
| guides/CLOAK_VISUALIZATION_GUIDE.md | Visualization Guide: how to read field plots and scattering spectra with physics interpretation |
| CLAUDE.md | AI Assistant Guide: instructions for Claude Code |
| Online Manual | Full documentation on Read the Docs |
| Platform | Support | Notes |
|---|---|---|
| Linux | Full | Install via Conda or build from source |
| macOS | Full | Install via Conda or build from source |
| Windows | Via WSL2 or Docker | No native Conda package — see USER_GUIDE.md for setup instructions |
Conda packages are the recommended path for new users on Linux and macOS. Windows users should use WSL2 (Ubuntu) or Docker. Building from source gives the most flexibility for advanced configurations (MPI, custom prefix, debug builds).
For users who need custom build options such as MPI parallelization, OpenMP threading, or debug symbols, Meep can be built from source using GNU Autotools. The build requires several external libraries: FFTW3, GSL, LAPACK, HDF5, harminv, libctl, and MPB.
sh autogen.sh
./configure --enable-maintainer-mode --prefix=$HOME/local \
--with-libctl=$HOME/local/share/libctl
make -j$(nproc)
make checkFull instructions including dependency installation, configure options, and CI build details are in guides/DEVELOPER_GUIDE.md.
src/ - C++ core FDTD engine (libmeep)
python/ - Python interface and SWIG bindings
scheme/ - Scheme/Guile interface
tests/ - C++ test suite
libpympb/ - Python MPB eigenmode solver bindings
guides/ - Project guides (architecture, developer, user, test report)
guides/tutorials/ - 148 physics tutorials (theory + code walkthroughs)
We kindly request that you cite the following paper in any published work for which you used Meep:
- A. Oskooi, D. Roundy, M. Ibanescu, P. Bermel, J.D. Joannopoulos, and S.G. Johnson, MEEP: A flexible free-software package for electromagnetic simulations by the FDTD method, Computer Physics Communications, Vol. 181, pp. 687-702 (2010) (pdf).

