“Active learning’ and “Optics simulations” together may be joined as “Active Learning in Simulating Optics” (ALSO). The goal of this paper is to encourage teachers and students to take an active part in developing their own codes as they design individual own experiments. There are many useful codes, both free and commercial, software or online codes, with good interfaces which reproducing perfectly analytical solutions allowing an infinite number of configurations numerically imitating experiments. For examples you can see the RAY program, the WebTOP and PHET project and also Wolfram demonstration project1,2,3,4. The basic disadvantage with these prepackaged programs is that we (students and teachers) behave as passive users without understanding the contents or the limitations of the material we use (codes or experiments). The idea here is to encourage academics to code and build their own interfaced programs more easily with minimal cost as possible. In this context, the Python environment offers many advantages compared to other object oriented languages. The most important points are the fact that it is open source, it is well documented and it also guarantees cross-platform compatibility. On the other hand optics is very well adapted to realize very simple experiments showing instantaneously the influences of different physical parameters on direct observations.. The combination of these two factors allows one to develop elaborate original lessons for laboratory activities and for numerical modeling of physical phenomena (in the case of optics, both geometrical and physical optics) with very limited means. We have already presented in previous publications the role of simulations in optics educations using the Python language5,6,7,8. Here we focus more on the coding side showing explicitly how to manage with the various toolboxes at our disposal.
ACTIVE LEARNING IN OPTICS
Since 2004 many workshops were organized throughout the word within the framework of the UNESCO project ‘‘Active Learning in Optics and Photonics” (ALOP) with the support of ICTP (Abdus Salam International Centre for Theoretical Physics, Trieste, Italy) and generously supported over the years by SPIE (SPIE – The International Society for Optics and Photonics) Other support has come from as well the Optical Society of America, The National Academies (USA), The European Optical Society, Esssilor Corporation, etc.9-15. This project promotes a hands-on method for teachers and students in optics using very simple and inexpensive material (homemade or locally available material when possible) and also avoiding as far as possible reference to mathematical/quantitative expressions. Furthermore, and in order to overcome the passive attitude of students during traditional lecture format, the teaching paradigm is Predictions, Observations, Discussions and Syntheses (PODS) in order to improve the conceptual understanding of optics. For instance, more than fifteen workshops have been organized just in Tunisia since 2005. Lessons focus on several topics usually found in any introductory university/or high school physics programs such as geometrical optics, interference and diffraction, atmospheric optics and optics in communications. Figure. 1 illustrates the context in which active learning procedure works.
Organization of ALSO workshops
We propose here a new series of workshops (denoted as ALSO workshops) keeping the hands-on approach applied to the same contents e.g. optics but adding mathematical solutions and their numerical modeling. The idea here is to append to those experiments, such as those shown in Figure.1, codes that allow the manipulation of the experimental configurations that can help to generalize and better understand the concepts previously discussed. As for the experiments, we should give a special care to the training during the coding encouraging students to be active during the development of the codes applying the same PODS method. The main drawback here could possibly be the price of computers. These workshops should last almost the same time e.g. two or three days (the full ALOP workshops last for 5 days and cover 5 modules as well as a pre- and post- workshop conceptual evaluation test). We will choose only two or three modules per workshop and for each module we will manage half day for experiment and half day for the program development.
How to start programming
Starting to program is always something complicated. We never know exactly at which level we should start. Should we explain bit and addressing and occupying memory or should we start with syntax and instructions? Part of the answer to this question resides in what we want to do. As physics educators, in the context of the active learning and hands-on teaching, we suggest starting with subsections of programs carrying out specific tasks. Generally, an entire program can be divided into two parts: one dedicated to analytical solutions and the other for displaying curves and graphs. For example let’s focus on the diffraction-interference phenomena and more precisely on the Young double slit experiment. Here, the normalized intensity is expressed as:
‘b’ stand for the width of the slits, ‘a’ stand for the distance between slits, ‘D’ is the distance of the screen to the plan of the slits and ‘λ’ is the monochromatic wavelength of the incident light.
This example is very convenient for numerous reasons. It is very easy and inexpensive to realize experimentally and at the same time it highlights phenomena, such as interference and diffraction, which are not easy to understand and teach. The material shown on the left of Figure.1 is sufficient to do that. Slits are made manually on the plate in front of the laser simply using knife-edge. For the Young double slits we try to make two slits as parallel and identical as possible. So it fits well the hands-on approach we whish to promote. Similarly this hands-on approach could be applied on the numerical modeling. The program bellow simulates the Young double slit configuration and as highlighted it can be divided in two parts one dedicated to the mathematical solution and the other for the graphics.
You can copy this script, past it into python editor and run it as it is. This will generate Figure 2
The hands-on method appears through the ability to easily change the physical parameters (b, a, D, λ) and then determining the different patterns favoring predictions and discussions (OPDS). Of course it is not always easy to experimentally change the wavelength (λ) but thanks to the simulation we can vary it simply through the ‘lamda’ variable (see script) expanding the possibilities of OPDS. This point shows clearly the complementarity between experiments and programming.
Another interesting aspect here from the point of view of interactive learning in programming is the fact that we can focus on some basic and important notions we systematically encounter when modeling. This has to do with discretization. For instance, let us change in the script above the number of mesh point ‘N’ and give it the value N=30. The result is displayed in Figure.3.
As we can rapidly observe on this curve is that the number of peaks inside the central diffraction envelope goes from 5 to only 2 peaks. Actually, when we choose the number of mesh points for any discretization problem we have to deal with resolution problems and here resides many basic aspects in physics, raising many interesting questions.
The second part of the program is fully dedicated to the graphs and here also we can take time to learn how to better manipulate graphics libraries and determine the appropriate physical phenomena representation.
Interfacing the programs
Interfacing the programs is the next step that we shall realize after having manually tested the correctness of the script. This operation allows us to vary interactively the physical parameters without the need to return to the script. Practically, it involves associating widgets with curves into the graphics, which allow us to modify and extract the important information. Typical widgets come in the form of buttons, menus, box or control on the cursers. All these tools transform the static solutions in quantities similar to the results observed in real experiment, dynamically changing when varying one of the physical parameters. Of course all these tools give us a lot off opportunity in achieving a real hands-on experiences for both the experimental and the numerical point of view. Indeed adding widgets into graphics is equivalent to adding diagnostics in experiences and this is also a good way to push students to become active learners.
Designing a Graphical User Interface (GUI) for an application remains a difficult task and we are not going to develop here the complete steps to achieve this. However there are some procedures that need to be considered which can be roughly summarized in two main steps: the first step is to create a file containing all the elements devoted for interaction with the mathematical function and the second is to convert this file into a language that can be understood by Python. Fortunately the Qt toolkit installed with Python environment provides the necessary material to do that. We have at our disposal the ‘Qt Designer’ to build interactively our interface and the actual version of the command ‘pyuic5’. Figure.4 shows the configuration built for the Young double slit with ‘Qt Designer’
‘Qt Designer’, similarly to other software (Visual Basic, Real Studio, …), allows building GUI by simply dragging widgets listed as icons in the left panel of the windows and control their characteristics (name, size, location, …) with the tools in the right panel. We show here as an example the selection of the slider associated with the wavelength named ‘slider_lambda’ (right panel) accompanied by other information given in the yellow part for the other widgets. After putting in place all the physical parameters (b, a, D, λ) we have to connect them with the intensity ‘I’ implemented in the script given above. How to do this? When saving the configuration shown in Figure.4 we generate a file named by the title on the top of the main window, here ‘Ui_DoubleSlit1D’ with the extension ‘.ui’. This code is translated into Python running on the terminal by the following command ‘pyuic5 -x Ui_DoubleSlit1D.ui -o Ui_DoubleSlit1D.py’. This generates a program in Python language that can be imported as any kind of functions or libraries into our previous script. This is shown in the script bellow where we only exhibit the major additions to the program.
Finally the result of this second version is illustrated in Figure 5 showing how the light intensity will vary when manipulating the different widgets displayed on the left panel.
Indeed, the program has increased in complexity but let us focus on the points we are concerned with, i.e. teaching and interactive learning. So we can see here how the values can be varied using the widgets for the physical parameters (a, b, D, λ) instead of the fixed value adopted in the previous static script. We recognize for example, in Figure.4 ‘slider_lambda’ associated with the ‘lamda’ variable for the wavelength. The lines starting with ‘@pyqtSlot’ in the script insure the new computation of the intensity function ‘I’ each time one of the widgets is manipulated. So we can see, from this Young double slit example, how we can interactively control any mathematical expression by taking the control of its parameters.
Otherwise and as we noted the implementation of the interface shown in Figure.4 requires numerous operations such as the line ‘from Ui_DoubleSlit1D import Ui_mainWindow’ inserted in the header but also the need to define: a _main_ routine, a ‘DoubleSlit’ class and two functions ‘_init_’ and ‘fig1’. This part is perhaps the most subtle and delicate to transmit to teachers and students because we have to insert them manually. The only way out here is to convince participants to firstly accept these notions without understanding all their meanings because our main goal deals with optics and physics and not the subtleties of writing software. The content of the file ’Ui_DoubleSlit1D.py’ is also very complicated but we can consider it as a black box. Nevertheless, for all these topics (and more) we can find many documents and guides online16,17,18.
Providing opportunities for developing countries to carry out experiments during classroom which they cannot otherwise afford due to lack of means is one of the main goal of this work. The other one is to promote the active learning and hands-on activities during classroom encouraging students to be active learners. Numerical simulation in physics and more specifically in optics is a good way to reach this goal because it is possible to accompany very simple experiments with inexpensive homemade/custom built materials. We have shown in this work that it is possible to elaborate lessons based on the active learning approach for both the experiments in optics and also for the development of codes. This second point is just as important as the first because it also favors questioning and discussions. We can apply similarly to experiments the method based on the Predictions, Observations, Discussions and Syntheses (PODS), which help better understand the basic concepts.
Carnicer, A., Andilla, J., Ferre, J., et al. “Teaching (and learning) optics using interactive simulations: the JavaOptics course”, Proc. SPIE 9664, Ninth International Topical Meeting on Education and Training in Optics and Photonics, 96641G, (2005), doi: 10.1117/12.22077251.Google Scholar
Foley, J.T., Zoughi, M., Herring, S.D., Morris, M., Gilbert, P.J., Moore, D.T., “The Optics Project on the Web: WebTOP”, Proc. SPIE 9663, Eighth International Topical Meeting on Education and Training in Optics and Photonics, 96630K, (2003), doi: 10.1117/12.2207350; http://dx.doi.org/10.1117/12.2207350Google Scholar
Ghalila, H., Ben Lakhdar, Z., Lahmar, S., Dhouaidi, Z., Majdi, Y., “Active Learning in Optics and Photonics: Fraunhofer diffraction”, Education and Training in Optics and Photonics: ETOP 2014, Proc. of SPIE Vol. 9289, 92892V, OSA, IEEE, ICO · doi: 10.1117/12.2070776.Google Scholar
Ammar, A., Burman, R., Ghalila, H., Ben Lakhdar, Z., Varadharajan, L.S., Lahmar, S., and Lakshminarayanan. V., “Optics simulations with Python: Diffraction” Education and Training in Optics and Photonics: ETOP 2015, Proc. SPIE Vol. 9793, 97930K, (2015), doi: 10.1117/12.2223072.Google Scholar
Lakshminarayanan, V., and Burman, R., “Optics Tutorials with Python”, Tech. Report, Univ. of Waterloo, 2015, doi: 10.13140/RG.2.1.2940.2325, (2015).Google Scholar
Lakshminarayanan, V., Ghallila, H., Varadharajan, L.S., Ammar, A., Understanding Optics With Python, CRC Press/Taylor and Francis, Boca Raton, FL., (2017).Google Scholar
Lakshminarayanan, V., “Interactive lecture demonstrations, active learning, and the ALOP project”, Proc. SPIE 8065, 80650S (2011); doi: 10.1117/12.889508Google Scholar
Alarcon, M., Arthurs, E., Ben Lakhdar, Z., Culaba, I., Denardo, G., Lakshminarayanan, V., Maquiling, J., Mazzolini, A., Niemela, J., Sokoloff, D., “Active learning in optics and photonics: Training Manual” http://unesdoc.unesco.org/images/0021/002171/217100e.pdfGoogle Scholar
Riverbank Computing Limited, 2016, http://pyqt.sourceforge.net/Docs/PyQt5/designer.htmlGoogle Scholar