Skip to content

Simulation of reflection and refraction of polarized opticial beams at plane and curved dielectric interfaces.

License

Notifications You must be signed in to change notification settings

DanielKotik/Optical-beams-MEEP

Repository files navigation

concave planar convex Airy

snap snap snap Airy

Optical-beams-MEEP

DOI Binder PyMeep Meep libctl Guile docs

FDTD simulation of reflection and refraction of polarised optical beams at plane and curved dielectric interfaces based on Meep as underlying FDTD simulation software package. A mathematical description of the currently implemented beam profiles is outlined in this Jupyter notebook.

The provided files (and features) are:

  • Scheme/Python configuration files for Gaussian beams (2d) impinging upon planar, concave and convex dielectric interfaces
  • Scheme/Python configuration file for Laguerre-Gaussian (vortex) beams (3d) impinging upon a planar dielectric interface
  • Scheme/Python configuration file for Airy beams (2d) impinging upon a planar dielectric interface
  • Python scripts for enhanced visualisation and analysis of the generated HDF5 output files
  • The waist/focus of the beams can be placed anywhere along the propagation direction - independently of the location of the source current distribution

Originally, these files have been used in studying optical beam shifts providing independent numerical simulations. With regards to their scriptability, together with the ease and widespread use of the powerful Meep tool, these scripts can easily be adapted to other and possibly more complicated beam/interface setups.

This repository is structured as follows:

├── docs : Sphinx documentation folder
├── optbeam : Cython package with exact implementations of optical beams
└── scripts : Python and Scheme scripts to use together with optbeam+PyMeep/Meep

Installation of PyMeep and optbeam

We highly recommend to install the parallel version of PyMeep via Conda:

# create conda virtual environment "pmp"
$ conda create -n pmp -c conda-forge pymeep=*=mpi_mpich_* scipy cython

# next command is optional, but recommended to enforce environment isolation (no local
# user site packages in conda environment that may shadow conda installed dependencies)
$ conda env config vars set PYTHONNOUSERSITE=True -n pmp

# activate conda environment
$ conda activate pmp

# install optbeam package inside conda environment
$ python3 -m pip install .

For detailed installation instructions of PyMeep using the Conda package manager, see the Meep documentation.

Invocation of scripts

A Scheme (extension .ctl) or Python configuration file (extension .py) may be launched with the serial or parallel version of Meep and with parameters specified via command line arguments, for example by executing commands like (notice the single quotes to specify strings and Scheme expressions):

# Scheme
$ mpirun -quiet -np X meep-mpi interface='"concave"' Gauss2d.ctl

# Python
$ mpirun -quiet -np X python3 Gauss2d.py -interface concave

or another example

# Scheme
$ mpirun -quiet -np X meep-mpi n2=1.5 e_z='(/ 1+1i 2)' e_y='(/ 1-1i 2)' LaguerreGauss3d.ctl

# Python
$ mpirun -quiet -np X python3 LaguerreGauss3d.py -n2 1.5 -e_z "(1+1j)/2" -e_y "(1-1j)/2"

with X indicating the number of cores. All possible Meep parameters that can be set from the command line are defined in expressions beginning with (define-param ... in the respective Scheme configuration files.

Visualisation

The generated HDF5 files can be processed by different visualisation tools. To get a quick impression of the data Meep comes bundled with the h5utils programs. Utilising these tools, visualisation is fairly easy performed by issuing for example the following commands:

for 2d simulations:

# real part of the field pattern, optical denser material is shaded in grey
$ h5topng -S2 -Zc dkbluered -a gray -A eps-000000000.h5 ez-000003696.h5

# intensity distribution, optical denser material is shaded in grey
$ h5topng -S2 -c hot -a yarg -A eps-000000000.h5 e2_s-000003696.h5

for 3d simulations:

# slice within the plane of incidence
$ h5topng -S2 -0 -z 0  -c hot e_real2_p-000001500.h5

# slice transversal to the incident propagation axis with INDEX specifying the slice index
$ h5topng -S2 -x INDEX -c hot e_real2_p-000001500.h5

# create a VTK file
$ h5tovtk e_real2_p-000001500.h5

A VTK file can be opened by e.g. the MayaVi or ParaView visualisation application.

The Meep Scheme tutorial provides further useful information and assistance. For a more detailed explanation of our configuration files and the physical background, please see my dissertation thesis. Coming soon.

Supported beams, interfaces and polarisation configurations

  • Gaussian beams (2d), planar, s- and p-polarisation
  • Gaussian beams (2d), concave, s- and p-polarisation
  • Gaussian beams (2d), convex, s- and p-polarisation
  • Laguerre-Gaussian (vortex) beams (3d), planar, arbitrary complex polarisation
  • Airy beams (2d), planar, s- and p-polarisation

Citing

If you use code from this repository in a published work, please cite the DOI corresponding to the specific version of Optical-beams-MEEP that you used (DOIs are listed at Zenodo.org).