Photonics Research Group Home
Ghent University
 IMEC
intern

 

Contents: Table of Contents   Back: Python Up: Tutorial Forward: Example 2   Index: Index

1.2 Example 1 : a simple 1D grating

We go ahead with the simulation of a 1D grating. Next script shows how to

  • setup a RODIS environment
  • make the grating device
  • calculate it
  • ask some results

 
from rodis import *

# rodis data
set_lambda(1.0)
set_N(5)   
set_polarisation(TE)

# make device
GaAs = Material(3.5)
air  = Material(1.0)

front   = Slab( GaAs(0.6) )
period  = Slab( air(0.15) + GaAs(0.3) + air(0.15))
back    = Slab( air(0.6)  )

grating = Stack( front(1.) + period(0.3) + back(1.))

# start calculations
grating.calc()

# ask data
print grating.diffr_eff().R(-1)
print grating.diffr_eff().T(0)
print grating.field().R(2)
print grating.field().T(3)

figs/example1

The first line, from rodis import *, will insert the RODIS library into 'Python'. From this moment on, we can use all of the RODIS-commands. The next line is a simple comment, (all #-lines) so not read by the Python interpreter. Next block of code sets the free space wavelentgh, the number of orders used during the calculation, and the polarisation.

 
set_lambda(1.0)
set_N(5)   
set_polarisation(TE)
The polarisation will be TM by default, so you can either delete this line or write set_polarisation(TM) to change it. Now we make the materials that we will use to build the grating with, using Material(refractive index)

 
GaAs = Material(3.5)
air  = Material(1.0)
Next step is to make some layers. Slab(material1+material2) Since the width of a layer is the period of the grating all layers have the same width.

 
front   = Slab( GaAs(0.6) )
period  = Slab( air(0.15) + GaAs(0.3) + air(0.15))
back    = Slab( air(0.6)  )
Obvious, front is a slab with period 0.6, period is a slab with period 0.15 + 0.3 + 0.15 and back has a period of the same size. So we made three slabs. Ok, we just have to stack these slabs to make the device

 
grating = Stack( front(1.) + period(0.3) + back(1.))
The first and the last layer always consist of only one material! i.e the 'incidence medium' or 'reflection medium' and the 'transmission medium'

grating.calc() will start the calculation of the device. After the calculation is done, we just simply have to ask the needed data and print it on the screen.

 
print grating.diffr_eff().R(-1)
print grating.diffr_eff().T(0)
print grating.field().R(2)
print grating.field().T(3)
Since we set the number of modes to 5 (see set_N(5)), we can ask data from -5 to 5

the script will result in this output:

 
RODIS

0.0871190000258
0.689968431786
(-0.104378951709+0.451485554898j)
(0.0646782627315-0.070856654796j)


Contents: Table of Contents   Back: Python Up: Tutorial Forward: Example 2   Index: Index

This document was generated by Lieven Vanholme on June, 10 2003 using texi2html.