Top Banner
C ALCULATING PC W AVEGUIDE P ROPERTIES Mark Patterson – 2009 October 29
68

C ALCULATING PC W AVEGUIDE P ROPERTIESwiki.phy.queensu.ca/hughes/images/f/fd/MPB_tutorial.pdf · MPB uses Guile and Libctl to control its simulations. EVERYTHING YOU NEED TO KNOW

Jul 21, 2020

Download

Documents

dariahiddleston
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: C ALCULATING PC W AVEGUIDE P ROPERTIESwiki.phy.queensu.ca/hughes/images/f/fd/MPB_tutorial.pdf · MPB uses Guile and Libctl to control its simulations. EVERYTHING YOU NEED TO KNOW

CALCULATING PC WAVEGUIDE PROPERTIES

Mark Patterson – 2009 October 29

Page 2: C ALCULATING PC W AVEGUIDE P ROPERTIESwiki.phy.queensu.ca/hughes/images/f/fd/MPB_tutorial.pdf · MPB uses Guile and Libctl to control its simulations. EVERYTHING YOU NEED TO KNOW

PROBLEM DEFINITION

We want to calculate the properties of an ideal PC waveguide mode:

Dispersion: omega(k),

Group velocity: d omega(k) / d k,

Bloch mode electric and magnetic field.

Page 3: C ALCULATING PC W AVEGUIDE P ROPERTIESwiki.phy.queensu.ca/hughes/images/f/fd/MPB_tutorial.pdf · MPB uses Guile and Libctl to control its simulations. EVERYTHING YOU NEED TO KNOW

COMPUTATIONAL METHODS

FDTD PWE

Calculate eigen-frequencies ✓ ✓

Calculate group velocity - ✓

Obtain fields - ✓

Sweep over k-space - ✓

Fast - ✓

Radiation or other loss ✓ ✗

Finite Size ✓ ✗

GUI Interface ✓ ✗

✓ easy to do. - difficult. ✗ don’t try.

Page 4: C ALCULATING PC W AVEGUIDE P ROPERTIESwiki.phy.queensu.ca/hughes/images/f/fd/MPB_tutorial.pdf · MPB uses Guile and Libctl to control its simulations. EVERYTHING YOU NEED TO KNOW

COMPARISON OF BAND STRUCTURES

0 0.1 0.2 0.3 0.4 0.51.2

1.4

1.6

1.8

2

2.2

2.4

2.6

2.8x 1014

Wavevector, k [2!/a]

Freq

uenc

y [H

z]

0 0.1 0.2 0.3 0.4 0.50

0.05

0.1

0.15

0.2

0.25

0.3

0.35

Wavevector [2!/a]

Freq

uenc

y [c

/a]

MPB FDTD

Page 5: C ALCULATING PC W AVEGUIDE P ROPERTIESwiki.phy.queensu.ca/hughes/images/f/fd/MPB_tutorial.pdf · MPB uses Guile and Libctl to control its simulations. EVERYTHING YOU NEED TO KNOW

FDTD

Lumerical FDTD (commercial) or Radiant (see Cole).

Necessary for structures with material loss, radiation loss, or finite size.

Using Fourier techniques, frequency resolution converges linearly with simulation time. Some improvements can be made using harminv (http://ab-initio.mit.edu/wiki/index.php/Harminv).

Page 6: C ALCULATING PC W AVEGUIDE P ROPERTIESwiki.phy.queensu.ca/hughes/images/f/fd/MPB_tutorial.pdf · MPB uses Guile and Libctl to control its simulations. EVERYTHING YOU NEED TO KNOW

LUMERICAL TUTORIALS

http://www.lumerical.com/fdtd_online_help/fdtd_online_help_summary.php

3D slab structure with square lattice: http://www.lumerical.com/fdtd_online_help/pc_bandstructure_3d_planar.php

2D structure with triangular lattice (supercell technique): http://www.lumerical.com/fdtd_online_help/pc_bandstructure_triangular_lattice.php

Page 7: C ALCULATING PC W AVEGUIDE P ROPERTIESwiki.phy.queensu.ca/hughes/images/f/fd/MPB_tutorial.pdf · MPB uses Guile and Libctl to control its simulations. EVERYTHING YOU NEED TO KNOW

MPB

MPB: MIT Photonic Bands; uses the plane wave expansion technique.

Free (GPL) software written by Stephen Johnson and John Joannopoulos et al.

They also have an FDTD, MEEP.

Mature software: started development in 1999. Last updated in 2003.

Johnson still answers questions on the mailing list.

Page 9: C ALCULATING PC W AVEGUIDE P ROPERTIESwiki.phy.queensu.ca/hughes/images/f/fd/MPB_tutorial.pdf · MPB uses Guile and Libctl to control its simulations. EVERYTHING YOU NEED TO KNOW

PLANE WAVE EXPANSION

Write Maxwell wave equation as an eigenvalue problem.

Expand the mode in plane waves (spatial Fourier transform) for evaluating the curls.

Use fancy matrix methods to calculate the eigen-frequencies and -vectors (field profiles).

!"!

1!r(r)

!"H(r, ")"

=#"

c

$2H(r, ")

! = minh

h†Ah

h†h

Page 10: C ALCULATING PC W AVEGUIDE P ROPERTIESwiki.phy.queensu.ca/hughes/images/f/fd/MPB_tutorial.pdf · MPB uses Guile and Libctl to control its simulations. EVERYTHING YOU NEED TO KNOW

WAVEGUIDE SUPERCELL

The plane wave expansion technique models periodic media only.

For a waveguide, we use a supercell.

You cannot obtain radiation modes with this method.

Page 11: C ALCULATING PC W AVEGUIDE P ROPERTIESwiki.phy.queensu.ca/hughes/images/f/fd/MPB_tutorial.pdf · MPB uses Guile and Libctl to control its simulations. EVERYTHING YOU NEED TO KNOW

UNITS

Lengths are dimensionless, usually one normalizes to the periodicity, a.

Frequencies are in units of c/a.

Wave vectors are in units of 2π/a. The band edge is at 0.5.

Page 12: C ALCULATING PC W AVEGUIDE P ROPERTIESwiki.phy.queensu.ca/hughes/images/f/fd/MPB_tutorial.pdf · MPB uses Guile and Libctl to control its simulations. EVERYTHING YOU NEED TO KNOW

OVERVIEW

CTL Filempb Console

(frequency, group

velocity)

Command line

Command Line

mpbi

mpb-mpi

mpbi-mpi

HDF5 Files (Fields) MATLAB

Input Compute Output Analyse

Page 13: C ALCULATING PC W AVEGUIDE P ROPERTIESwiki.phy.queensu.ca/hughes/images/f/fd/MPB_tutorial.pdf · MPB uses Guile and Libctl to control its simulations. EVERYTHING YOU NEED TO KNOW

OVERVIEW

CTL Filempb Console

(frequency, group

velocity)

Command line

Command Line

mpbi

mpb-mpi

mpbi-mpi

HDF5 Files (Fields) MATLAB

Input Compute Output Analyse

Page 14: C ALCULATING PC W AVEGUIDE P ROPERTIESwiki.phy.queensu.ca/hughes/images/f/fd/MPB_tutorial.pdf · MPB uses Guile and Libctl to control its simulations. EVERYTHING YOU NEED TO KNOW

OVERVIEW

CTL Filempb Console

(frequency, group

velocity)

Command line

Command Line

mpbi

mpb-mpi

mpbi-mpi

HDF5 Files (Fields) MATLAB

Input Compute Output Analyse

Page 15: C ALCULATING PC W AVEGUIDE P ROPERTIESwiki.phy.queensu.ca/hughes/images/f/fd/MPB_tutorial.pdf · MPB uses Guile and Libctl to control its simulations. EVERYTHING YOU NEED TO KNOW

OVERVIEW

CTL Filempb Console

(frequency, group

velocity)

Command line

Command Line

mpbi

mpb-mpi

mpbi-mpi

HDF5 Files (Fields) MATLAB

Input Compute Output Analyse

Page 16: C ALCULATING PC W AVEGUIDE P ROPERTIESwiki.phy.queensu.ca/hughes/images/f/fd/MPB_tutorial.pdf · MPB uses Guile and Libctl to control its simulations. EVERYTHING YOU NEED TO KNOW

OVERVIEW

CTL Filempb Console

(frequency, group

velocity)

Command line

Command Line

mpbi

mpb-mpi

mpbi-mpi

HDF5 Files (Fields) MATLAB

Input Compute Output Analyse

Page 17: C ALCULATING PC W AVEGUIDE P ROPERTIESwiki.phy.queensu.ca/hughes/images/f/fd/MPB_tutorial.pdf · MPB uses Guile and Libctl to control its simulations. EVERYTHING YOU NEED TO KNOW

MPB INPUT

Page 18: C ALCULATING PC W AVEGUIDE P ROPERTIESwiki.phy.queensu.ca/hughes/images/f/fd/MPB_tutorial.pdf · MPB uses Guile and Libctl to control its simulations. EVERYTHING YOU NEED TO KNOW

WHAT LANGUAGE ARE WE USING?

Lisp is a very old (50 years) programming language.

Scheme is a dialect of Lisp.

GNU Guile is intended to provide a scripting and extensibility interface for libraries and programs. It is promoted by the GNU project and uses Scheme.

Libctl is an extension to Guile intended for running scientific simulations. It is written by Steven Johnson.

MPB uses Guile and Libctl to control its simulations.

Page 19: C ALCULATING PC W AVEGUIDE P ROPERTIESwiki.phy.queensu.ca/hughes/images/f/fd/MPB_tutorial.pdf · MPB uses Guile and Libctl to control its simulations. EVERYTHING YOU NEED TO KNOW

E V E RY T H I N G Y O U N E E D T O K N O W A B O U T L I S P

Page 20: C ALCULATING PC W AVEGUIDE P ROPERTIESwiki.phy.queensu.ca/hughes/images/f/fd/MPB_tutorial.pdf · MPB uses Guile and Libctl to control its simulations. EVERYTHING YOU NEED TO KNOW

SCHEME PRIMER

Comments begin with a semicolon:

Everything is a function:

… even creating and setting variables:

; This is a comment

(function-name value1 value2)

(define sq32 1) ; Define n and initialize value(set! sq32 (/ (sqrt 3) 2)) ; Change value

Page 21: C ALCULATING PC W AVEGUIDE P ROPERTIESwiki.phy.queensu.ca/hughes/images/f/fd/MPB_tutorial.pdf · MPB uses Guile and Libctl to control its simulations. EVERYTHING YOU NEED TO KNOW

LIBCTL INPUT FILES

Usually, provide a *.ctl file to run the simulation. Think of the ctl file as a shell script, but with more parentheses.

Alternatively, mpb can be started interactively and controlled from a command prompt. You would manually type the commands from the ctl file.

Special variables are used as inputs to the simulation.

A ctl file can just run a simulation or be a complex script.

Page 22: C ALCULATING PC W AVEGUIDE P ROPERTIESwiki.phy.queensu.ca/hughes/images/f/fd/MPB_tutorial.pdf · MPB uses Guile and Libctl to control its simulations. EVERYTHING YOU NEED TO KNOW

INPUT PARAMETERS

(define-param) is an alternative to (define). It allows the default value to be overridden on the command line.

Proper use of this means you can run lots of simulations with a single shared ctl file.

(define-param a 475e-9)(define-param h (/ 180e-9 a))

Page 23: C ALCULATING PC W AVEGUIDE P ROPERTIESwiki.phy.queensu.ca/hughes/images/f/fd/MPB_tutorial.pdf · MPB uses Guile and Libctl to control its simulations. EVERYTHING YOU NEED TO KNOW

DESCRIBE THE SUPERCELL LATTICE

Set the geometry variable.

For a non-rectangular lattice, use basis1, basis2, basis3:

What I use for a waveguide:

(set! geometry-lattice (make lattice (size 1 1 (* 10 thickness)) (basis1 sq32 0.5) (basis2 sq32 -0.5)))

(set! geometry-lattice (make lattice (size 1 (+ (* supercell-yi sq32) (* 2 dy)) supercell-z)))

(set! geometry-lattice (make lattice (size 1 5 no-size)))

Page 24: C ALCULATING PC W AVEGUIDE P ROPERTIESwiki.phy.queensu.ca/hughes/images/f/fd/MPB_tutorial.pdf · MPB uses Guile and Libctl to control its simulations. EVERYTHING YOU NEED TO KNOW

DESCRIBE THE SUPERCELL LATTICE

Set the geometry variable.

For a non-rectangular lattice, use basis1, basis2, basis3:

What I use for a waveguide:

(set! geometry-lattice (make lattice (size 1 1 (* 10 thickness)) (basis1 sq32 0.5) (basis2 sq32 -0.5)))

(set! geometry-lattice (make lattice (size 1 (+ (* supercell-yi sq32) (* 2 dy)) supercell-z)))

(set! geometry-lattice (make lattice (size 1 5 no-size)))

One of the special input variables

Page 25: C ALCULATING PC W AVEGUIDE P ROPERTIESwiki.phy.queensu.ca/hughes/images/f/fd/MPB_tutorial.pdf · MPB uses Guile and Libctl to control its simulations. EVERYTHING YOU NEED TO KNOW

DESCRIBE THE SUPERCELL LATTICE

Set the geometry variable.

For a non-rectangular lattice, use basis1, basis2, basis3:

What I use for a waveguide:

(set! geometry-lattice (make lattice (size 1 1 (* 10 thickness)) (basis1 sq32 0.5) (basis2 sq32 -0.5)))

(set! geometry-lattice (make lattice (size 1 (+ (* supercell-yi sq32) (* 2 dy)) supercell-z)))

(set! geometry-lattice (make lattice (size 1 5 no-size))) Unit cell dimensions in units of the basis vectors.

One of the special input variables

Page 26: C ALCULATING PC W AVEGUIDE P ROPERTIESwiki.phy.queensu.ca/hughes/images/f/fd/MPB_tutorial.pdf · MPB uses Guile and Libctl to control its simulations. EVERYTHING YOU NEED TO KNOW

DESCRIBE THE SUPERCELL LATTICE

Set the geometry variable.

For a non-rectangular lattice, use basis1, basis2, basis3:

What I use for a waveguide:

(set! geometry-lattice (make lattice (size 1 1 (* 10 thickness)) (basis1 sq32 0.5) (basis2 sq32 -0.5)))

(set! geometry-lattice (make lattice (size 1 (+ (* supercell-yi sq32) (* 2 dy)) supercell-z)))

(set! geometry-lattice (make lattice (size 1 5 no-size))) Unit cell dimensions in units of the basis vectors.

One of the special input variablesFor a 2D structure, use no-size.

Page 27: C ALCULATING PC W AVEGUIDE P ROPERTIESwiki.phy.queensu.ca/hughes/images/f/fd/MPB_tutorial.pdf · MPB uses Guile and Libctl to control its simulations. EVERYTHING YOU NEED TO KNOW

DESCRIBE THE SUPERCELL LATTICE

Set the geometry variable.

For a non-rectangular lattice, use basis1, basis2, basis3:

What I use for a waveguide:

(set! geometry-lattice (make lattice (size 1 1 (* 10 thickness)) (basis1 sq32 0.5) (basis2 sq32 -0.5)))

(set! geometry-lattice (make lattice (size 1 (+ (* supercell-yi sq32) (* 2 dy)) supercell-z)))

(set! geometry-lattice (make lattice (size 1 5 no-size))) Unit cell dimensions in units of the basis vectors.

One of the special input variablesFor a 2D structure, use no-size.

Page 28: C ALCULATING PC W AVEGUIDE P ROPERTIESwiki.phy.queensu.ca/hughes/images/f/fd/MPB_tutorial.pdf · MPB uses Guile and Libctl to control its simulations. EVERYTHING YOU NEED TO KNOW

DESCRIBE THE SUPERCELL LATTICE

Set the geometry variable.

For a non-rectangular lattice, use basis1, basis2, basis3:

What I use for a waveguide:

(set! geometry-lattice (make lattice (size 1 1 (* 10 thickness)) (basis1 sq32 0.5) (basis2 sq32 -0.5)))

(set! geometry-lattice (make lattice (size 1 (+ (* supercell-yi sq32) (* 2 dy)) supercell-z)))

(set! geometry-lattice (make lattice (size 1 5 no-size))) Unit cell dimensions in units of the basis vectors.

Override default Cartesian basis.

One of the special input variablesFor a 2D structure, use no-size.

Page 29: C ALCULATING PC W AVEGUIDE P ROPERTIESwiki.phy.queensu.ca/hughes/images/f/fd/MPB_tutorial.pdf · MPB uses Guile and Libctl to control its simulations. EVERYTHING YOU NEED TO KNOW

DESCRIBE THE SUPERCELL LATTICE

Set the geometry variable.

For a non-rectangular lattice, use basis1, basis2, basis3:

What I use for a waveguide:

(set! geometry-lattice (make lattice (size 1 1 (* 10 thickness)) (basis1 sq32 0.5) (basis2 sq32 -0.5)))

(set! geometry-lattice (make lattice (size 1 (+ (* supercell-yi sq32) (* 2 dy)) supercell-z)))

(set! geometry-lattice (make lattice (size 1 5 no-size))) Unit cell dimensions in units of the basis vectors.

Override default Cartesian basis.

One of the special input variablesFor a 2D structure, use no-size.

Page 30: C ALCULATING PC W AVEGUIDE P ROPERTIESwiki.phy.queensu.ca/hughes/images/f/fd/MPB_tutorial.pdf · MPB uses Guile and Libctl to control its simulations. EVERYTHING YOU NEED TO KNOW

DESCRIBE THE STRUCTURE

(set! geometry (list

(make block (material (make dielectric (index ind))) (size infinity infinity h) (center 0 0 0) )

(make cylinder (material air) (center 0.5 (+ (* 1 sq32) dy) 0) (radius r1) (height infinity) ) (make cylinder (material air) (center 0.5 (- (* -1 sq32) dy) 0) (radius r1) (height infinity) ) (make cylinder (material air) (center 0 (+ (* 2 sq32) dy) 0) (radius r ) (height infinity) ) (make cylinder (material air) (center 0 (- (* -2 sq32) dy) 0) (radius r ) (height infinity) )))

The structure is described by setting geometry:

Start with a block of dielectric:

And drill holes in it:

Page 31: C ALCULATING PC W AVEGUIDE P ROPERTIESwiki.phy.queensu.ca/hughes/images/f/fd/MPB_tutorial.pdf · MPB uses Guile and Libctl to control its simulations. EVERYTHING YOU NEED TO KNOW

DESCRIBE THE STRUCTURE

(set! geometry (list

(make block (material (make dielectric (index ind))) (size infinity infinity h) (center 0 0 0) )

(make cylinder (material air) (center 0.5 (+ (* 1 sq32) dy) 0) (radius r1) (height infinity) ) (make cylinder (material air) (center 0.5 (- (* -1 sq32) dy) 0) (radius r1) (height infinity) ) (make cylinder (material air) (center 0 (+ (* 2 sq32) dy) 0) (radius r ) (height infinity) ) (make cylinder (material air) (center 0 (- (* -2 sq32) dy) 0) (radius r ) (height infinity) )))

The structure is described by setting geometry:

Start with a block of dielectric:

And drill holes in it:

Page 32: C ALCULATING PC W AVEGUIDE P ROPERTIESwiki.phy.queensu.ca/hughes/images/f/fd/MPB_tutorial.pdf · MPB uses Guile and Libctl to control its simulations. EVERYTHING YOU NEED TO KNOW

DESCRIBE THE STRUCTURE

(set! geometry (list

(make block (material (make dielectric (index ind))) (size infinity infinity h) (center 0 0 0) )

(make cylinder (material air) (center 0.5 (+ (* 1 sq32) dy) 0) (radius r1) (height infinity) ) (make cylinder (material air) (center 0.5 (- (* -1 sq32) dy) 0) (radius r1) (height infinity) ) (make cylinder (material air) (center 0 (+ (* 2 sq32) dy) 0) (radius r ) (height infinity) ) (make cylinder (material air) (center 0 (- (* -2 sq32) dy) 0) (radius r ) (height infinity) )))

The structure is described by setting geometry:

Start with a block of dielectric:

And drill holes in it:

Page 33: C ALCULATING PC W AVEGUIDE P ROPERTIESwiki.phy.queensu.ca/hughes/images/f/fd/MPB_tutorial.pdf · MPB uses Guile and Libctl to control its simulations. EVERYTHING YOU NEED TO KNOW

K-POINTS

The calculation is performed once for each Bloch wavevector specified in the k-points list variable.

(define Gamma (vector3 0 0 0))

(define K (lattice->reciprocal (vector3 0.5 0 0) ) )

(set! k-points (interpolate (- numk 2) (list Gamma K)))

Create vector3 variables for the symmetry points:

Remember, this is in reciprocal space:

Create a list of evenly sampled points.

Page 34: C ALCULATING PC W AVEGUIDE P ROPERTIESwiki.phy.queensu.ca/hughes/images/f/fd/MPB_tutorial.pdf · MPB uses Guile and Libctl to control its simulations. EVERYTHING YOU NEED TO KNOW

K-POINTS

The calculation is performed once for each Bloch wavevector specified in the k-points list variable.

(define Gamma (vector3 0 0 0))

(define K (lattice->reciprocal (vector3 0.5 0 0) ) )

(set! k-points (interpolate (- numk 2) (list Gamma K)))

Create vector3 variables for the symmetry points:

Remember, this is in reciprocal space:

Create a list of evenly sampled points.

This list could have more than 2 entries.

Page 35: C ALCULATING PC W AVEGUIDE P ROPERTIESwiki.phy.queensu.ca/hughes/images/f/fd/MPB_tutorial.pdf · MPB uses Guile and Libctl to control its simulations. EVERYTHING YOU NEED TO KNOW

OPTIONAL PARAMETERS

Number of grid points per lattice unit length:

Number of sub-cell points for calculating average ε:

Frequency eigensolver tolerance, a relative value:

Number of bands to solve for (you should always set this):

(set! resolution (vector3 24 24 24))

(set! mesh-size 10)

(set! tolerance 1e-8)

(set! num-bands 18)

Page 36: C ALCULATING PC W AVEGUIDE P ROPERTIESwiki.phy.queensu.ca/hughes/images/f/fd/MPB_tutorial.pdf · MPB uses Guile and Libctl to control its simulations. EVERYTHING YOU NEED TO KNOW

RUN THE SIMULATION

The (run*) commands start the simulation.

It is useful to use alternate run commands to enforce a desired symmetry and e.g. suppress the TM modes.

You can have multiple (run*) commands in one file.

(run display-group-velocities fix-efield-phase output-efield)

(run-zeven) (run-yodd) (run-te)

Page 37: C ALCULATING PC W AVEGUIDE P ROPERTIESwiki.phy.queensu.ca/hughes/images/f/fd/MPB_tutorial.pdf · MPB uses Guile and Libctl to control its simulations. EVERYTHING YOU NEED TO KNOW

RUN THE SIMULATION

The (run*) commands start the simulation.

It is useful to use alternate run commands to enforce a desired symmetry and e.g. suppress the TM modes.

You can have multiple (run*) commands in one file.

(run display-group-velocities fix-efield-phase output-efield)

Run command

(run-zeven) (run-yodd) (run-te)

Page 38: C ALCULATING PC W AVEGUIDE P ROPERTIESwiki.phy.queensu.ca/hughes/images/f/fd/MPB_tutorial.pdf · MPB uses Guile and Libctl to control its simulations. EVERYTHING YOU NEED TO KNOW

RUN THE SIMULATION

The (run*) commands start the simulation.

It is useful to use alternate run commands to enforce a desired symmetry and e.g. suppress the TM modes.

You can have multiple (run*) commands in one file.

(run display-group-velocities fix-efield-phase output-efield)

Run command Commands to execute after solving each k-point.

(run-zeven) (run-yodd) (run-te)

Page 39: C ALCULATING PC W AVEGUIDE P ROPERTIESwiki.phy.queensu.ca/hughes/images/f/fd/MPB_tutorial.pdf · MPB uses Guile and Libctl to control its simulations. EVERYTHING YOU NEED TO KNOW

RUN THE SIMULATION

The (run*) commands start the simulation.

It is useful to use alternate run commands to enforce a desired symmetry and e.g. suppress the TM modes.

You can have multiple (run*) commands in one file.

(run display-group-velocities fix-efield-phase output-efield)

Run command Commands to execute after solving each k-point.

(run-zeven) (run-yodd) (run-te)

Page 40: C ALCULATING PC W AVEGUIDE P ROPERTIESwiki.phy.queensu.ca/hughes/images/f/fd/MPB_tutorial.pdf · MPB uses Guile and Libctl to control its simulations. EVERYTHING YOU NEED TO KNOW

RUN THE SIMULATION

The (run*) commands start the simulation.

It is useful to use alternate run commands to enforce a desired symmetry and e.g. suppress the TM modes.

You can have multiple (run*) commands in one file.

(run display-group-velocities fix-efield-phase output-efield)

Run command Commands to execute after solving each k-point.

(run-zeven) (run-yodd) (run-te)

Page 41: C ALCULATING PC W AVEGUIDE P ROPERTIESwiki.phy.queensu.ca/hughes/images/f/fd/MPB_tutorial.pdf · MPB uses Guile and Libctl to control its simulations. EVERYTHING YOU NEED TO KNOW

INTERPRETING SYMMETRIES

Page 42: C ALCULATING PC W AVEGUIDE P ROPERTIESwiki.phy.queensu.ca/hughes/images/f/fd/MPB_tutorial.pdf · MPB uses Guile and Libctl to control its simulations. EVERYTHING YOU NEED TO KNOW

ADVANCED SCRIPTING

You can do full blown scripting within the ctl file. I have examples for programatically generating device geometry and fitting the band structure to experiments by tweaking the geometry.

Libctl has support for 3-vectors 3x3 matrices, complex numbers, minimization, root finding, derivatives and integrals.

MPB can compute field energy, energy in objects, and do math with fields.

Page 43: C ALCULATING PC W AVEGUIDE P ROPERTIESwiki.phy.queensu.ca/hughes/images/f/fd/MPB_tutorial.pdf · MPB uses Guile and Libctl to control its simulations. EVERYTHING YOU NEED TO KNOW

CTL BEST PRACTICE

Use (define-param) liberally and make the ctl file generic.

Always display-group-velocities.

Always output-efield.

Recycle code.

Don’t use the targeted eigensolver. It is slow and inaccurate.

Page 44: C ALCULATING PC W AVEGUIDE P ROPERTIESwiki.phy.queensu.ca/hughes/images/f/fd/MPB_tutorial.pdf · MPB uses Guile and Libctl to control its simulations. EVERYTHING YOU NEED TO KNOW

RUNNING SIMULATIONS

Page 45: C ALCULATING PC W AVEGUIDE P ROPERTIESwiki.phy.queensu.ca/hughes/images/f/fd/MPB_tutorial.pdf · MPB uses Guile and Libctl to control its simulations. EVERYTHING YOU NEED TO KNOW

RUNNING SIMULATIONS (COMMAND LINE)

mpb r=0.3 simulation.ctl > simulation.out

mpb-split 2 r=0.3 simulation.ctl > simulation.out

Starts 2 serial jobs, each with half of the k-points.

mpbi, mpbi-splitAssumes ε(-x) = ε*(x)Twice as fast, half the memory.No error checking!

Page 46: C ALCULATING PC W AVEGUIDE P ROPERTIESwiki.phy.queensu.ca/hughes/images/f/fd/MPB_tutorial.pdf · MPB uses Guile and Libctl to control its simulations. EVERYTHING YOU NEED TO KNOW

RUNNING SIMULATIONS (COMMAND LINE)

mpb r=0.3 simulation.ctl > simulation.out

mpb-split 2 r=0.3 simulation.ctl > simulation.out

Starts 2 serial jobs, each with half of the k-points.

mpbi, mpbi-splitAssumes ε(-x) = ε*(x)Twice as fast, half the memory.No error checking!

Capture the console output.

Page 47: C ALCULATING PC W AVEGUIDE P ROPERTIESwiki.phy.queensu.ca/hughes/images/f/fd/MPB_tutorial.pdf · MPB uses Guile and Libctl to control its simulations. EVERYTHING YOU NEED TO KNOW

RUNNING SIMULATIONS (COMMAND LINE)

mpb r=0.3 simulation.ctl > simulation.out

mpb-split 2 r=0.3 simulation.ctl > simulation.out

Starts 2 serial jobs, each with half of the k-points.

mpbi, mpbi-splitAssumes ε(-x) = ε*(x)Twice as fast, half the memory.No error checking!

Override a (define-param) variable. Always check this.

Capture the console output.

Page 48: C ALCULATING PC W AVEGUIDE P ROPERTIESwiki.phy.queensu.ca/hughes/images/f/fd/MPB_tutorial.pdf · MPB uses Guile and Libctl to control its simulations. EVERYTHING YOU NEED TO KNOW

RUNNING SIMULATIONS (COMMAND LINE)

mpb r=0.3 simulation.ctl > simulation.out

mpb-split 2 r=0.3 simulation.ctl > simulation.out

Starts 2 serial jobs, each with half of the k-points.

mpbi, mpbi-splitAssumes ε(-x) = ε*(x)Twice as fast, half the memory.No error checking!

Override a (define-param) variable. Always check this.

Capture the console output.

Page 49: C ALCULATING PC W AVEGUIDE P ROPERTIESwiki.phy.queensu.ca/hughes/images/f/fd/MPB_tutorial.pdf · MPB uses Guile and Libctl to control its simulations. EVERYTHING YOU NEED TO KNOW

RUNNING SIMULATIONS (COMMAND LINE)

mpb r=0.3 simulation.ctl > simulation.out

mpb-split 2 r=0.3 simulation.ctl > simulation.out

Starts 2 serial jobs, each with half of the k-points.

mpbi, mpbi-splitAssumes ε(-x) = ε*(x)Twice as fast, half the memory.No error checking!

Override a (define-param) variable. Always check this.

Capture the console output.

Page 50: C ALCULATING PC W AVEGUIDE P ROPERTIESwiki.phy.queensu.ca/hughes/images/f/fd/MPB_tutorial.pdf · MPB uses Guile and Libctl to control its simulations. EVERYTHING YOU NEED TO KNOW

RUNNING SIMULATION IN PARALLEL

MPB is parallelized (MPI). Use mpb-mpi and mpbi-mpi.

Sometimes it crashes the node, but Cole said he’d fix it.

Running across nodes tends to be slow.

This transposes x and y.

Page 51: C ALCULATING PC W AVEGUIDE P ROPERTIESwiki.phy.queensu.ca/hughes/images/f/fd/MPB_tutorial.pdf · MPB uses Guile and Libctl to control its simulations. EVERYTHING YOU NEED TO KNOW

OUTPUT

Page 52: C ALCULATING PC W AVEGUIDE P ROPERTIESwiki.phy.queensu.ca/hughes/images/f/fd/MPB_tutorial.pdf · MPB uses Guile and Libctl to control its simulations. EVERYTHING YOU NEED TO KNOW

OUTPUT

Prints the frequencies and, if specified, group velocity to the console.

Saves dielectic data to epsilon.h5 file. If specified, creates files for E, D, and H field files.

e.g.: e.k05.b16.zeven.h5

Always check the epsilon.h5 file.

Delete the extra field files promptly.

Page 53: C ALCULATING PC W AVEGUIDE P ROPERTIESwiki.phy.queensu.ca/hughes/images/f/fd/MPB_tutorial.pdf · MPB uses Guile and Libctl to control its simulations. EVERYTHING YOU NEED TO KNOW

HDF5 FILES

The fields are save in HDF5 files.

A data file for structured binary data.

Modern MAT files are actually HDF5 files in disguise.

Tools:Use h5utils and mpb-data on command line.Use hdf5* in MATLAB.Use PyTables in Python.

Page 54: C ALCULATING PC W AVEGUIDE P ROPERTIESwiki.phy.queensu.ca/hughes/images/f/fd/MPB_tutorial.pdf · MPB uses Guile and Libctl to control its simulations. EVERYTHING YOU NEED TO KNOW

ANALYSIS

Page 55: C ALCULATING PC W AVEGUIDE P ROPERTIESwiki.phy.queensu.ca/hughes/images/f/fd/MPB_tutorial.pdf · MPB uses Guile and Libctl to control its simulations. EVERYTHING YOU NEED TO KNOW

COMMAND LINE TOOLS

h5ls

Examine the structure of the data file.

mpb-data

Set-up derived fields such as converting to a rectangular grid.

h5topng

Visualize fields on slices through the volume.

Page 56: C ALCULATING PC W AVEGUIDE P ROPERTIESwiki.phy.queensu.ca/hughes/images/f/fd/MPB_tutorial.pdf · MPB uses Guile and Libctl to control its simulations. EVERYTHING YOU NEED TO KNOW

H5TOPNG

Part of h5utils.

Useful for quick checks of the structure.

Read the man page.

h5topng -0x0 epsilon.h5

Page 57: C ALCULATING PC W AVEGUIDE P ROPERTIESwiki.phy.queensu.ca/hughes/images/f/fd/MPB_tutorial.pdf · MPB uses Guile and Libctl to control its simulations. EVERYTHING YOU NEED TO KNOW

MATLAB TOOLBOX

See the wiki to get the source.

Provides the MPBBandstructure class for parsing console output and loading fields. Start by creating a new object based on an output file:

mpb = MPBBandstructure(file, 'zeven') ;

Some functions have implicit assumptions about a rectangular supercell.

If you used (run-zeven).

Page 58: C ALCULATING PC W AVEGUIDE P ROPERTIESwiki.phy.queensu.ca/hughes/images/f/fd/MPB_tutorial.pdf · MPB uses Guile and Libctl to control its simulations. EVERYTHING YOU NEED TO KNOW

MPBBANDSTRUCTURE OBJECT

>> display(mpb) ;MPBBandstructure object: k: [5x1 double] kVect: [5x3 double] freqs: [5x18 double] vg: [5x18 double] vgVect: [5x 3x18 double] numK: 5 numBands: 18 pathroot: '/home/mark/Masters/Matlab Library/MPB/

test_data/waveguide' filename: 'waveguide.out' symmetry: 'zeven' isMPI: false interchange: [0x0 struct] vars: [1x1 struct]

Page 59: C ALCULATING PC W AVEGUIDE P ROPERTIESwiki.phy.queensu.ca/hughes/images/f/fd/MPB_tutorial.pdf · MPB uses Guile and Libctl to control its simulations. EVERYTHING YOU NEED TO KNOW

PLOTTING BAND STRUCTURES

0 0.05 0.1 0.15 0.2 0.25 0.3 0.35 0.4 0.45 0.50

0.05

0.1

0.15

0.2

0.25

0.3

0.35

Wavevector [2!/a]

Freq

uenc

y [c

/a]

clf ;plotBands(mpb) ; % Plot all the bandsplotBands(mpb, 13, 'r') ; % Highlight the waveguide band

Page 60: C ALCULATING PC W AVEGUIDE P ROPERTIESwiki.phy.queensu.ca/hughes/images/f/fd/MPB_tutorial.pdf · MPB uses Guile and Libctl to control its simulations. EVERYTHING YOU NEED TO KNOW

epsilon.h5: epsilon, x=centre+0

y

z

epsilon.h5: epsilon, x=1

y

z

epsilon.h5: epsilon, y=centre+0

x

z

epsilon.h5: epsilon, z=centre+0

xy

VISUALIZING STRUCTURESplotFields3D(mpb, 'epsilon') ;

Page 61: C ALCULATING PC W AVEGUIDE P ROPERTIESwiki.phy.queensu.ca/hughes/images/f/fd/MPB_tutorial.pdf · MPB uses Guile and Libctl to control its simulations. EVERYTHING YOU NEED TO KNOW

e.k42.b13.zeven.h5: e, x=centre+0

y

z

e.k42.b13.zeven.h5: e, x=1

y

z

e.k42.b13.zeven.h5: e, y=centre+0

x

z

e.k42.b13.zeven.h5: e, z=centre+0

xy

VISUALIZING FIELDS

plotFields3D(mpb, mpb.numK, 13, 'e') ;

Page 62: C ALCULATING PC W AVEGUIDE P ROPERTIESwiki.phy.queensu.ca/hughes/images/f/fd/MPB_tutorial.pdf · MPB uses Guile and Libctl to control its simulations. EVERYTHING YOU NEED TO KNOW

USING THE FIELDS

Use readField() to load epsilon and field data.

Returns a 4D (x-by-y-by-z-by-component) matrix.

Takes care of transposition for MPI runs and band interchanges.

>> epsilon = readField(mpb, 'epsilon') ;>> epsilonCentre = ...

epsilon(ceil(end/2), ceil(end/2), ceil(end/2)) ;>> disp(['The membrane has a dielectric constant of ' ...

num2str(epsilonCentre) '.']) ;The membrane has a dielectric constant of 12.0826.

Page 63: C ALCULATING PC W AVEGUIDE P ROPERTIESwiki.phy.queensu.ca/hughes/images/f/fd/MPB_tutorial.pdf · MPB uses Guile and Libctl to control its simulations. EVERYTHING YOU NEED TO KNOW

USING THE FIELDS 2

Use getScale() to get the coordinates.

>> [scaleX scaleY scaleZ] = getScale(mpb) ;>> e = readField(mpb, ki, band, 'e') ;>> ey = e(:,:,:,2) ;% I could also have used ey = readField(mpb, ki, band, 'y') ;>> [maxi maxi] = max(ey(:)) ;>> [xi yi zi] = ind2sub(size(ey), maxi) ;>> disp(['The maximum value of the electric field ' ...

'y-component occurs at (x,y,z) = (' ...num2str(scaleX(xi)) ', ' num2str(scaleY(yi)) ', ' ...num2str(scaleZ(zi)) ').']) ;

The maximum value of the electric field y-component occurs at (x,y,z) = (0, 0.3997, 0).

Page 64: C ALCULATING PC W AVEGUIDE P ROPERTIESwiki.phy.queensu.ca/hughes/images/f/fd/MPB_tutorial.pdf · MPB uses Guile and Libctl to control its simulations. EVERYTHING YOU NEED TO KNOW

USER DATA

It can be useful to associate data (parameters, band index) with the output file.

Add (usually by hand) to the top of the output file:

These will be automatically loaded into MATLAB:

POSTPROCESS: Set vars double a to 4.14e-7POSTPROCESS: Set vars double r to 0.286POSTPROCESS: Set vars integer band to 13

>> disp(mpb.vars)

a: 4.1400e-07 r: 0.2860 band: 13

Page 65: C ALCULATING PC W AVEGUIDE P ROPERTIESwiki.phy.queensu.ca/hughes/images/f/fd/MPB_tutorial.pdf · MPB uses Guile and Libctl to control its simulations. EVERYTHING YOU NEED TO KNOW

INTERCHANGE BANDS

25 30 35 40 45 500.26

0.265

0.27

0.275

0.28

0.285

0.29

0.295

0.3

0.305

Wave vector index

Freq

uenc

y [c

/a]

25 30 35 40 45 500.26

0.265

0.27

0.275

0.28

0.285

0.29

0.295

0.3

0.305

Wave vector index

Freq

uenc

y [c

/a]

POSTPROCESS: Swap bands 7 8 indices 32 to 34

Without Swap Command With Swap Command

Page 66: C ALCULATING PC W AVEGUIDE P ROPERTIESwiki.phy.queensu.ca/hughes/images/f/fd/MPB_tutorial.pdf · MPB uses Guile and Libctl to control its simulations. EVERYTHING YOU NEED TO KNOW

FLAG MPI

Did you remember that you have to transpose the fields if you use mpb-mpi?

POSTPROCESS: MPI

Page 67: C ALCULATING PC W AVEGUIDE P ROPERTIESwiki.phy.queensu.ca/hughes/images/f/fd/MPB_tutorial.pdf · MPB uses Guile and Libctl to control its simulations. EVERYTHING YOU NEED TO KNOW

MISC. ADVICE

Save parameters and the band index with output files.

The POSTPROCESS lines must be at the top.

Use MPBBandstructures and inputs to later calculations.

If you are interpolating fields between k-points, be careful of the phase.

Cache the fields if you load them a lot.

Page 68: C ALCULATING PC W AVEGUIDE P ROPERTIESwiki.phy.queensu.ca/hughes/images/f/fd/MPB_tutorial.pdf · MPB uses Guile and Libctl to control its simulations. EVERYTHING YOU NEED TO KNOW

QUESTIONS?