Meep C-plus-plus Tutorial

From AbInitio

(Difference between revisions)
Jump to: navigation, search
Revision as of 01:34, 23 October 2005 (edit)
Ardavan (Talk | contribs)

← Previous diff
Revision as of 01:53, 23 October 2005 (edit)
Ardavan (Talk | contribs)

Next diff →
Line 9: Line 9:
The particular cavity we will investigate is 1D waveguide bounded by two distributed bragg reflectors whose parameters we set up as follows: The particular cavity we will investigate is 1D waveguide bounded by two distributed bragg reflectors whose parameters we set up as follows:
- const double half_cavity_width = 0.5*0.68;+ const double half_cavity_width = 0.5*0.68;
- const double air_slit_width = 0.38;+ const double air_slit_width = 0.38;
- const double grating_periodicity = 0.48;+ const double grating_periodicity = 0.48;
- const double half_waveguide_width = 1.0;+ const double half_waveguide_width = 1.0;
- const double num_air_sluts = 15.0;+ const double num_air_sluts = 15.0;
- const double high_dielectric = 12.0;+ const double high_dielectric = 12.0;
- const double low_dielectric = 11.5;+ const double low_dielectric = 11.5;
-Meep supports periodic matching layers (PML) and absorbing boundary conditions: +Meep supports periodic matching layers (PML) and absorbing boundary conditions. The PML begins at the edge of the computational cell/volume and works inwards. Hence, we specify the size of the computational cell as follows:
- const double pml_thickness = 1.0;+ const double pml_thickness = 1.0;
 + const double x_center = 7.7 + pml_thickness;
 + const double y_center = 10.5 + pml_thickness;
 +To specify a dielectric structure in Meep, we define a function that takes as input one parameter, a position vector, and returns the value of the dielectric at that position.
 +
 + double eps(const vec &p) {
 + const vec r = p - vec(v_center, y_center);
 + double dx = fabs(r.x() - half_cavity_width);
 + if (dx > 0 && dx < num_air_slits*grating_periodicty) {
 + while (dx > grating_periodicity) dx -= grating_periodicity;
 + if (dx < air_slit_width) return 1.0;
 + }
 + if (fabs(r.y()) < half_waveguide_width)
 + return high_dielectric;
 + else
 + return low_dielectric;
 + }
 +
 +
 +
[[Category:Meep]] [[Category:Meep]]

Revision as of 01:53, 23 October 2005

Meep
Download
Release notes
FAQ
Meep manual
Introduction
Installation
Tutorial
Reference
C++ Tutorial
C++ Reference
Acknowledgements
License and Copyright

Computing the Quality Factor of a Resonator

In this first tutorial, we will write the script to compute the quality factor of a cavity in 2D cartesian co-ordinates. The control file will be a C++ file (having extension *.cpp). In order to use all the classes and subroutines available in Meep, the first two lines of any control file must be the following:

#include <meep.hpp>
using namespace meep;

The particular cavity we will investigate is 1D waveguide bounded by two distributed bragg reflectors whose parameters we set up as follows:

const double half_cavity_width = 0.5*0.68;
const double air_slit_width = 0.38;
const double grating_periodicity = 0.48;
const double half_waveguide_width = 1.0;
const double num_air_sluts = 15.0;
const double high_dielectric = 12.0;
const double low_dielectric = 11.5;

Meep supports periodic matching layers (PML) and absorbing boundary conditions. The PML begins at the edge of the computational cell/volume and works inwards. Hence, we specify the size of the computational cell as follows:

const double pml_thickness = 1.0;
const double x_center = 7.7 + pml_thickness;
const double y_center = 10.5 + pml_thickness;

To specify a dielectric structure in Meep, we define a function that takes as input one parameter, a position vector, and returns the value of the dielectric at that position.

double eps(const vec &p) {
  const vec r = p - vec(v_center, y_center);
  double dx = fabs(r.x() - half_cavity_width);
  if (dx > 0 && dx < num_air_slits*grating_periodicty) {
    while (dx > grating_periodicity) dx -= grating_periodicity;
    if (dx < air_slit_width) return 1.0; 
  }
  if (fabs(r.y()) < half_waveguide_width) 
    return high_dielectric;
  else
    return low_dielectric;
 }
Personal tools