optics simulation with python - diffraction
optics simulation with python - diffraction
Keywords
:
Optics,
Numerical
Experiments,
Python,
Active
Learning,
ALOP,
simulations,
Diffraction,
Physical
Optics.
1.
Introduction
The
UNESCO
program
“Active
Learning
in
Optics
and
Photonics”
(ALOP)
promotes
a
friendly
and
interactive
method
for
teaching
optics
using
simple
and
inexpensive
equipment
[1-‐3].
The
full
ALOP
manual
can
be
downloaded
from
UNESCO
[4].
Despite
the
gain
provided
by
these
new
conceptual
experiments,
diffraction
remains
a
difficult
concept
for
students.
Numerical
simulation
is
a
valuable
help
in
this
direction
and
many
simulations
are
now
available
for
free
on
the
web.
Numerical
tools
have
been
developed
to
accompany
the
ALOP
modules
[5,6].
The
dazzling
progress
in
this
area
allow
us,
thanks
to
free
distributions
like
python
and
the
notebook
associated
with
it,
to
implement
the
ALOP
modules
with
the
numerical
code
that
simulate
the
various
phenomena.
.
Among
the
multitude
of
programming
languages
available,
Python
has
experienced
the
most
rapid
growth
these
past
few
years.
One
reason
for
that
is
due
to
the
fact
that
interfacing
modules
are
multiplatform
so
the
same
program
can
be
used
to
generate
applications
for
different
Operating
Systems
(OS).
Another
important
reason
is
python
is
a
free
and
open
source
software.
In
addition
to
these
two
major
points
python
has
several
advantages
over
other
programming
language
such
as
easy
syntax.
In
addition,
it
comes
with
various
packages
(all
open
source)
such
as
1
Scipy
(Scientific
Python),
Matplotlib
(a
plotting
program),
Numpy
(Numerical
Python),
Statpy
(Statistical
Python),
etc.
There
are
numerous
texts
on
Python
[7,8].
It
should
be
emphasized
that
Python
is
a
very
intuitive
programming
language,
which
is
very
flexible
and
powerful.
2.2
Notebook
Notebook
is
a
powerful
tool
to
write
and
generate
lessons
in
various
formats
as
latex,
html
or
slides.
In
addition
to
that
it
is
possible
to
insert
parts
of
codes,
execute
them
and
generate
the
outputs.
This
ability
facilitates
greatly
the
explanation
of
programs.
The
notebook
can
be
downloaded
from:
http://ipython.org/notebook.html.
The
code
given
in
the
section
3.1.3
illustrates
how
to
interactively
affects
a
value
to
one
of
the
parameters.
3.
Fraunhofer
diffraction
In
this
example
we
will
deal
with
diffraction.
Diffraction
is
one
of
the
modules
of
the
ALOP
program[9].
Fraunhofer
is
an
application
built
using
python
programming
language
and
its
packages
like
Numpy,
Matplotlib
and
wxpython.
This
program
was
developed
under
windows
OS
and
the
same
code
can
be
compiled
under
both
linux
and
OSX.
2
⎡sin⎛πb
x ⎞⎤
I(x) ⎢ ⎝ λ D⎠⎥
=
(1)
I(0) ⎢ ⎛πb x ⎞ ⎥
⎣ ⎝ λ D⎠ ⎦
Making
these
parameters
interactive,
it
is
possible
to
perform
numerical
experiments
and
test
a
wide
variety
of
configurations.
For
instance,
this
allows
us
to
test
the
effect
of
different
wavelengths,
which
would
be
difficult
to
do
in
an
experimental
situation
due
to
lack
of
light
sources
with
variable
wavelengths.
We
face
the
same
problem
with
the
slits.
For
example,
in
ALOP
workshop
the
slits
are
manually
fabricated.
So
it
is
not
possible
to
produce
a
large
number
of
slits
different
slit
widths.
2
slider.
We
show
here,
as
an
example,
the
interface
created
for
this
application.
Figure.1:
Fraunhofer
interface
application
for
a
single
slit
3
This
first
part
affects
the
value
to
the
three
parameters
(d,
λ,
D)
and
computes
the
sinc()
function.
The
following
part
displays
the
result.
Figure.2:
Direct
display
of
the
portion
of
code
given
above
2
πb x
⎡ sin⎛
⎞⎤
I(x) ⎝ λ D⎠ ⎡ ⎛πa x ⎞⎤ 2
=
4
⎢
cos
(2)
I(0) ⎛πb
x ⎞ ⎥ ⎣ ⎝ λ D⎠⎦
⎣ ⎝ λ D⎠ ⎦
We
proceed
with
the
same
way
as
in
the
case
of
the
single
slit.
Making
these
parameters
interactive,
it
is
possible
to
perform
numerical
experiments
and
test
a
wide
variety
of
configurations.
Figure.2
shows
how
it
is
possible
to
vary
the
four
parameters
(b,
a,
λ,
D)
with
the
help
of
the
sliders
at
the
bottom.
Likewise
these
four
values
are
displayed
inside
the
plot
along
with
the
formula
changing
simultaneously
with
the
values
in
the
slider.
4
2 2
⎡sin⎛πb
x ⎞⎤ ⎡sin⎛N
πa
x ⎞⎤
I(x) ⎝ λ D⎠⎥ ⎝ λ D⎠⎥
=
4
⎢
⎢
(3)
I(0) ⎢ ⎛πb
x ⎞ ⎥ ⎢N
sin⎛πa
x ⎞⎥
⎣ ⎝ λ D⎠ ⎦ ⎣ ⎝ λ D⎠⎦
And
as
previously
done
we
transform
this
into
an
interactive
application.
Figure.3
shows
the
interface
dedicated
to
this
case.
Figure.2:
Fraunhofer
interface
application
for
the
double
slits
Figure.3:
Fraunhofer
interface
application
for
the
multiple
slits
4.
Workshop
session
In
order
to
better
spread
optical
physics
together
with
the
new
software
facilities
such
as
Python,
we
organized
a
workshop
at
the
Faculty
of
Science
of
Tunis
in
November
2014
with
15
participants.
This
was
the
first
of
(we
hope)
a
long
series.
During
this
first
workshop,
we
presented
as
a
first
part
the
basic
physics
of
diffraction
phenomena
and
the
second
part
was
dedicated
to
Python.
Two
python
distributions
were
prepared
for
the
participants
(windows
and
linux).
After
the
installation
of
the
distribution
we
tested
the
two
cases:
single
slit
and
the
Young
double
slit.
Most
of
the
participants
(53%)
found
the
session
beneficial
and
(33%)
very
beneficial
on
a
scale
of
0
to
5,
ranging
from
very
beneficial
to
useless.
The
majority
of
the
participants
were
very
enthusiastic
and
asked
for
information
on
the
next
planned
workshop
5
5.
Summary
After
the
tedious
step
of
the
Python
distribution
installation
procedure,
it
is
very
easy
to
develop
programs
and
build
applications
that
are
available
for
various
OS.
Since
this
new
environment
is
free,
this
possibility
constitutes
a
very
crucial
point
for
teaching
and
more
generally
outreach
programs.
The
next
steps
will
be
in
two
directions,
(1)
organization
of
several
workshop
sessions
and
(2)
to
develop
other
simulations
and
implement
them
on
smartphones
and
mobiles
devices
that
will
be
accompany
the
ALOP
program.
References
[1] M. Alarcon, E. Arthurs, Z. Ben Lakhdar, I. Culaba, V. Lakshminarayanan, J. Maquiling, A. Maz- zolini, J. Niemela, D.
Sokoloff : “Active learning in optics and photonics: experiences in Africa”, http://spie.org/etop/ETOP2005040.pdf,2005.
[2] Z. Ben Lakhdar, N. Derbel, Z. Dhaouadi, H. Ghalila, R. Miled, S. Lahmar, K. Berrada, R. Channa, A. Outzourhit : Active
learning in physics a way for rational thinking - a way for development. http://spie.org/etop/2007/etop07programsI.pdf ,
2007.
[3] M. Alarcon, Z. Ben Lakhdar, I. Culaba, S. Lahmar, V. Lakshminarayanan, A. Mazzolini, J. Maquil- ing, Niemela J.
“ Active learning in optics and photonics (ALOP): a model for teacher training and professional development”, Proc SPIE,
7783: 1-8, 2010.
[4] M. Alarcon, Z. Ben Lakhdar, I. Culaba, G. Denardo, V. Lakshminarayanan, J. Maquiling, A.Mazzolini, J. Niemela, D.
Sokoloff : “Active learning in optics and photonics: Training Manual” http://unesdoc.unesco.org/
images/0021/002171/217100e.pdf
[5] H. Ghalila, Z. BenLakhdar, S. Lahmar, Z. Dhouaidi, Y. Majdi: “Active Learning in Optics and Photonics: Fraunhofer
diffraction”, Proc. SPIE 9289, doi:10.1117/12.2070776; http://dx.doi.org/10.1117/12.2070776
http://spie.org/Publications/Proceedings/Paper/10.1117/12.207077
[6] V. Lakshminarayanan and R.Burman, Python Optics, unpublished technical report, University of Waterloo, 2014.
[7] H.P.Langtangen, A primer on scientific programming with Python, 4th edition, Springer, Berlin, 2014.
[8] M. Lutz, Learning Python, 5th edition, O’Reilly Media, Sebastopol, CA., 2013.
[9] Z.Ben Lakshdar, S.Lahmar, V. Lakshminarayanan, " Workshop on active learning: two examples ", Proc. SPIE 9289
doi:10.1117/12.2070726; 2013.