Skip to content

Instantly share code, notes, and snippets.

@oskooi
oskooi / oled.py
Last active June 27, 2021 18:22
Meep Simulation of 3d Organic Light Emitting Diode (OLED)
import meep as mp
from meep.materials import Al as ALU
import argparse
import matplotlib
matplotlib.use('agg')
import matplotlib.pyplot as plt
def main(args):
resolution = args.res # pixels/um
@oskooi
oskooi / oled.py
Last active July 19, 2021 04:44
DFT field monitors with yee_grid=True
import meep as mp
from meep.materials import Al as ALU
import numpy as np
lambda_min = 0.4 # minimum source wavelength
lambda_max = 0.8 # maximum source wavelength
fmin = 1/lambda_max # minimum source frequency
fmax = 1/lambda_min # maximum source frequency
fcen = 0.5*(fmin+fmax) # source frequency center
df = fmax-fmin # source frequency width
@oskooi
oskooi / oled_simple.py
Last active July 31, 2021 01:09
simplified benchmarking test
import meep as mp
lambda_min = 0.4 # minimum source wavelength
lambda_max = 0.8 # maximum source wavelength
fmin = 1/lambda_max # minimum source frequency
fmax = 1/lambda_min # maximum source frequency
fcen = 0.5*(fmin+fmax) # source frequency center
df = fmax-fmin # source frequency width
resolution = 150
@oskooi
oskooi / waveguide_mode_coeffs.py
Last active October 22, 2021 15:04
S11 and S12 of a straight waveguide
import meep as mp
import numpy as np
cell_size = mp.Vector3(14,14)
pml_layers = [mp.PML(thickness=2)]
w = 1.0
geometry = [mp.Block(center=mp.Vector3(),
size=mp.Vector3(mp.inf,w,mp.inf),
@oskooi
oskooi / ring2d_harminv.py
Created October 18, 2021 02:16
MaterialGrid and subpixel smoothing
import matplotlib
matplotlib.use('agg')
import matplotlib.pyplot as plt
import meep as mp
import numpy as np
res = 10 # pixels/μm
n = 3.4 # index of waveguide
w = 1 # width of waveguide
@oskooi
oskooi / oled.py
Last active November 25, 2021 03:57
Meep Benchmarking Simulation of Organic Light Emitting Diode (OLED)
import meep as mp
from meep.materials import Al as ALU
import numpy as np
lambda_min = 0.4 # minimum source wavelength
lambda_max = 0.8 # maximum source wavelength
fmin = 1/lambda_max # minimum source frequency
fmax = 1/lambda_min # maximum source frequency
fcen = 0.5*(fmin+fmax) # source frequency center
df = fmax-fmin # source frequency width
@oskooi
oskooi / adjoint_gradient_ring.py
Last active December 19, 2021 17:11
convergence test for adjoint gradient
import numpy as np
from autograd import numpy as npa
from autograd import tensor_jacobian_product
import meep as mp
import meep.adjoint as mpa
silicon = mp.Medium(epsilon=12.)
sxy = 5.0
cell_size = mp.Vector3(sxy,sxy,0)
import meep as mp
import meep.adjoint as mpa
import numpy as np
from autograd import numpy as npa
from autograd import tensor_jacobian_product
silicon = mp.Medium(epsilon=12)
sxy = 5.0
cell_size = mp.Vector3(sxy,sxy,0)
@oskooi
oskooi / adjoint_gradient_sweep.py
Created January 26, 2022 06:35
validation test for the adjoint gradient using the finite-difference gradient
import meep as mp
import meep.adjoint as mpa
import numpy as np
from autograd import numpy as npa
from autograd import tensor_jacobian_product
silicon = mp.Medium(epsilon=12.)
sxy = 5.
cell_size = mp.Vector3(sxy,sxy,0)
@oskooi
oskooi / cavity_farfield.py
Last active January 31, 2022 02:54
comparison of far fields from near2far and actual DFT fields in near-field regime
import meep as mp
import numpy as np
import matplotlib
matplotlib.use('agg')
import matplotlib.pyplot as plt
resolution = 25 # pixels/μm
fcen = 0.25 # pulse center frequency
df = 0.2 # pulse width (in frequency)
eps = 13. # dielectric constant of waveguide