[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

1.5 Example 5: field profiles in a stack

In this example, we will excite the stack from example 2 with a certain incident field distribution and calculate the resulting field in the stack.

 
#!/usr/bin/env python

####################################################################
#
# Calculate field profiles in a stack.
#
####################################################################

from camfr import *

set_lambda(1)
set_N(20)
set_polarisation(TE)

# Define materials.

GaAs = Material(3.5)
air  = Material(1.0)

# Define stack.

set_lower_PML(-0.1)
set_upper_PML(-0.1)

slab  = Slab(air(2) + GaAs(.5) + air(2))
space = Slab(air(4.5))

stack = Stack(space(0) + slab(0.5) + space(0))

# Set incident field and calculate stack.

inc = zeros(N())
inc[0] = 1
stack.set_inc_field(inc)

stack.calc()


# Save the field to a file.
# Do some interactive plotting.

stack.plot()

The new code is in the following lines:

 
inc = zeros(N())
inc[0] = 1
stack.set_inc_field(inc)

These commands prepare a column vector named inc describing the incident field. This vector consists of N elements, one for each eigenmode. Initially, all elements are zero, but afterwards, we set the element corresponding to the fundamental mode equal to one. This vector is then used as the incident field.

stack.plot() brings up a widget which can show and animate the field profile in a stack, write the pictures to files, ... . Once again, you can zoom in these widgets by drawing a rectangle with the left mouse button pressed.

If you want to do some post-processing of the field data yourself, you can access it by commands like stack.field(Coord(x,0,z)).


[ < ] [ > ]   [ << ] [ Up ] [ >> ]

This document was generated by root on August, 27 2008 using texi2html 1.76.