MIT’s MEEP (MIT Electromagnetic Equation Propagation) is a free, open-source software package for simulating electromagnetic systems. It was developed at the Massachusetts Institute of Technology (MIT) and is used by researchers and scientists to study and model the behavior of electromagnetic waves in complex structures and materials. MEEP uses a finite-difference time-domain (FDTD) method to solve Maxwell’s equations, which are the fundamental equations of electromagnetism. This allows users to simulate and visualize the propagation of electromagnetic waves through a wide range of structures, materials, and devices.

MEEP is designed to be a versatile and flexible tool for simulating a wide range of electromagnetic systems. It can be used to study the behavior of electromagnetic waves in complex structures, such as photonic crystals and metamaterials, and to model the performance of devices, such as antennas, filters, and sensors. MEEP is written in the C++ programming language and is designed to be easily extensible and customizable. It can be used on a variety of platforms, including Linux, Mac OS X, and Windows. Additionally, MEEP supports parallel computing, allowing users to take advantage of multiple processor cores and distributed computing resources to speed up their simulations.

Basic instruction

To learn more about MEEP please visit its homepage. Here I will explain minimum steps to employ MEEP engine in a sample CPP code.

  1. Download MEEP package for Windows from here.
  2. Extract it in a directory without any spaces and open the root folder (iMEEP_v.*)
  3. Open MEEP console (Console.exe). You will execute all commands in this console from now on.
  4. The default directory is ~/projects which physically locates at “root_directory\home\minGW\projects”. In the project folder there is a minimal sample CPP code (test.cpp).
  5. To compile this sample code run the following command in the console
export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig
g++ -malign-double test.cpp -o run -lmeep -lhdf5 -lz -lharminv -llapack -lblas -lm

[6] This will generate run.exe for you. Now you can execute the code with the following command

./run.exe

[7] To convert output H5 files into PNG images, run the following commands in the console. For more information about how to use “h5topng” package visit here

cd results*
h5topng -S3 -Zc /share/h5utils/colormaps/dkbluered -o image.png h5_file.h5

[8] (optional) To update 5utils programs to version 1.12.1, download this package. The package includes h5fromitxt.exe, h5fromtxt.exe, h5topng.exe, h5totxt.exe and h5tovtk.exe.

Use MEEP in C++

Here is an example of how you might use MEEP in a C++ program:

#include <meep.hpp>
using namespace meep;

int main() {
    // Set the simulation cell size and resolution
    grid_volume vol = vol3d(10, 10, 10, 0.1);

    // Create a new simulation with the specified cell size and resolution
    fields f(vol);

    // Define the material properties of the simulation
    double epsilon = 12.0;
    double mu = 1.0;
    material_type m = medium(epsilon, mu);
    f.add_material(m);

    // Define the geometry of the simulation
    structure s(vol);
    s.add_sphere(m, vec(0,0,0), 2.0);

    // Set the simulation time and time step
    double T = 50;
    double dt = 0.1;

    // Define the source for the simulation
    double fcen = 0.2;
    double df = 0.1;
    gaussian_src_time src(fcen, df);
    f.add_point_source(Ex, src, vec(0,0,0));

    // Run the simulation
    while (f.time() < T) {
        f.step();
    }

    // Output the result of the simulation
    f.output_hdf5(Ex, vol.center(), "ex.h5");

    return 0;
}

In this example, we define a simple simulation that uses MEEP to calculate the electric field (Ex) in a 3D volume of space. The simulation cell has a size of 10x10x10 and a resolution of 0.1. We define a spherical object with a radius of 2.0 in the center of the cell, and set the material properties of the simulation using the medium function. We then define a point source for the electric field and run the simulation for 50 time steps with a time step of 0.1. Finally, we output the result of the simulation to an HDF5 file.

Use MEEP in Scheme

Here is an example of how you might use MEEP in a Scheme program:

(use-modules (meep))

(define vol (vol3d 10 10 10 0.1))
(define f (make fields vol))

(define epsilon 12.0)
(define mu 1.0)
(define m (medium epsilon mu))
(fields-add-material f m)

(define s (make structure vol))
(structure-add-sphere s m (vec 0 0 0) 2.0)

(define T 50)
(define dt 0.1)

(define fcen 0.2)
(define df 0.1)
(define src (make gaussian-src-time fcen df))
(fields-add-point-source f Ex src (vec 0 0 0))

(do ((t 0 (+ t dt)))
    ((>= t T) (fields-output-hdf5 f Ex (vol-center vol) "ex.h5"))
    (fields-step f))

In this example, we define a simple simulation that uses MEEP to calculate the electric field (Ex) in a 3D volume of space. The simulation cell has a size of 10x10x10 and a resolution of 0.1. We define a spherical object with a radius of 2.0 in the center of the cell, and set the material properties of the simulation using the medium function. We then define a point source for the electric field and run the simulation for 50 time steps with a time step of 0.1. Finally, we output the result of the simulation to an HDF5 file.

Use MEEP in Python

Here is an example of how you might use MEEP in a Python program:

import meep as mp

vol = mp.Vector3(10, 10, 10)
cell = mp.vol3d(vol, 0.1)

f = mp.fields(cell)

epsilon = 12.0
mu = 1.0
m = mp.medium(epsilon, mu)
f.add_material(m)

s = mp.structure(cell)
s.add_sphere(m, mp.Vector3(), 2.0)

T = 50
dt = 0.1

fcen = 0.2
df = 0.1
src = mp.gaussian_src_time(fcen, df)
f.add_point_source(mp.Ex, src, mp.Vector3())

while f.time() < T:
    f.step()

f.output_hdf5(mp.Ex, cell.center(), "ex.h5")

In this example, we define a simple simulation that uses MEEP to calculate the electric field (Ex) in a 3D volume of space. The simulation cell has a size of 10x10x10 and a resolution of 0.1. We define a spherical object with a radius of 2.0 in the center of the cell, and set the material properties of the simulation using the medium function. We then define a point source for the electric field and run the simulation for 50 time steps with a time step of 0.1. Finally, we output the result of the simulation to an HDF5 file.

References:

  1. http://ab-initio.mit.edu/wiki/index.php/Meep_acronym_expansions