Skip to content

Instantly share code, notes, and snippets.

@danieljfarrell
Created February 6, 2012 08:39
Show Gist options
  • Save danieljfarrell/1750807 to your computer and use it in GitHub Desktop.
Save danieljfarrell/1750807 to your computer and use it in GitHub Desktop.
Extended version of CAMFR Planar 1D example to include absolute electric field and Poynting vector profiles
#!/usr/bin/env python
#########################################################################################
#
# planar 1D DBR modified to export absolute electric field and Poynting vector profiles
#
########################################################################################
from camfr import *
#
# Define structure.
#
set_lambda(1)
GaAs_m = Material(3.5)
AlAs_m = Material(2.9)
Air_m = Material(1.0)
GaAs = Planar(GaAs_m)
AlAs = Planar(AlAs_m)
Air = Planar(Air_m)
d_GaAs = get_lambda()/4./GaAs_m.n().real
d_AlAs = get_lambda()/4./AlAs_m.n().real
s = Stack(Air(1) + GaAs(1) + 10*(GaAs(d_GaAs) + AlAs(d_AlAs)) + GaAs(0.0))
#
# Set incident angle in the first air layer
#
Air.set_theta( 0. * pi / 180. )
#
# Set internal field intensity
#
inc = zeros(N())
inc[0] = 1
s.set_inc_field(inc)
#
# Get electric field and Poynting vector profiles
#
output = file("DBR2.txt", "w")
# Write headers
print >> output, " ".join(('z', 'n', 'E', 'S'))
steps = s.length()/1000
# Write data columns
for z_point in arange(0, s.length(), steps):
z = float(z_point) # convert to python float (from numpy float)
n = s.n( (Coord(.0, .0, z))).real
E = s.field( Coord(.0, .0, z ) ).abs_E()
S = s.field( Coord(.0, .0, z ) ).abs_S()
print >> output, z, n, E, S
output.close()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment