| |
1.5 Example 4: loop and write
In this last example, we will
calculate the zeroth order reflection of a grating for
a number of distinct polarisations, using a loop.
All data will be written to a file.
This is how the script looks like:
| from rodis import *
import math
PI = math.pi
# rodis data
set_lambda(1.0)
set_N(10)
set_alpha(0.0)
set_delta(PI/4)
set_psi(0.0)
# make device
AlAs = Material(2.9 - 0.1j)
air = Material(1.0)
start = Slab( air(3.) )
ridge = Slab( air(1.) + AlAs(2.))
end = Slab( AlAs(3.) )
grating = Stack( start(1.) +ridge(1.) + end(1.))
# writefile
outfile = file("rodis.out",'w')
for i in range(-10, 11):
set_psi(i*PI/20)
grating.calc()
print >> outfile, i ,"\t", abs(grating.field().R_TM(0))
outfile.close()
|
Quite straight foreward. The script will scan the whole
range(-10,11) i.e.
(-10,-9,-8,-7,-6,-5,-4,-3,-2,-1,0,1,2,3,4,5,6,7,8,9,10)
That way, we scan the grating in 20 steps, starting with psi = -pi/2
and ending with pi/2.
The "rodis.out"-file will be saved in the script's directory.
\t inserts a tab, \n inserts a new line.
That's it. So far.
In next chapter you can learn some more the gratings
and specific rodis-code/terminology.
This document was generated
by Lieven Vanholme on June, 10 2003
using texi2html.
|