145
Appendix A: Simulations
Simulations will have one or both of the following formats.
Script format, where the function/script is run by hitting the run button
(e.g., in MATLAB
®
2007, Debug Run (F5)).
Some of the simulations will also have the graphic user interface (GUI)
version. In this case, when you run the function, GUI appears with the
corresponding controls and display. These MATLAB les were tested on
MATLAB 2007b. Earlier versions may not work properly.
A word of caution: These simulations are to help the reader visualize and under-
stand optical concepts. They are not guaranteed to be error free, and they are not
intended to be used as ray tracing or optical design software. These simulations are
not replacements for commercially available software. Additionally, these simula-
tions are not substitutes for professional help for designing optical components and
systems.
SIMULATION A.1: BLACKBODY RADIATION
Simulation le: Blackbody_radiation.m
Purpose: To become familiar with emission spectra of hot objects
Related chapter: 2–Light Sources
iNstructioNs
1. In the upper menu: Debug Run. (Or use F5. In MATLAB 2007b or later,
use “Run” arrow icon on the menu.)
2. The program will ask: “Input temperature in deg. Kelvin:
3. Enter temperature of the hot object (e.g., 2800 for incandescent light bulb).
A normalized emission spectra will be plotted. An example of an output plot for
temperature of 3000 K is shown in Figure A.1.
Notes
Temperature range for this simulation: 20 K to 10000 K.
SIMULATION A.2: REFRACTION
Simulation le: Refraction.m
Purpose: To become familiar with principle of refraction
Related chapter: 4–Manipulation of Light
146 Appendix A: Simulations
iNstructioNs
1. In the upper menu: Debug Run. (Or use F5. In MATLAB 2007b or later,
use “Run” arrow icon on the menu.)
2. The program will ask: “Enter Refractive index in medium 1 (n1):” Enter
refractive index of the rst medium.
3. The program will ask: “Enter Refractive index in medium 2 (n2):” Enter
refractive index of the second medium.
4. The program will ask: “Input angle (deg.):” Enter angle of incidence in the
rst medium.
5. The output will be plotted and the output angle will be given at the input prompt.
Example 1
Enter Refractive index in medium 1 (n1): 1
Enter Refractive index in medium 2 (n2): 1.5
Input angle (deg.): 40
Output angle = 25.374 (deg.)
Example 2 (Input Angle Is Larger than Critical Angle)
Enter Refractive index in medium 1 (n1): 1.5
Enter Refractive index in medium 2 (n2): 1
Input angle (deg.): 50
Output angle = –50 (deg.)
FIGURE A.1 Screen capture of the plot generated by running the MATLAB simulation
“Blackbody_radiation.m.” For this example, object temperature was 3000 K.
147Appendix A: Simulations
Notes
When light is refracted, a portion of it is reected from the interface. This
reection is not shown for clarity.
If the input angle is larger than the critical angle (as specied in Chapter 8),
then instead of refraction, you will see a total internal reection.
Valid for input angle range 0 to ±90.
Example is shown in Figure A.2.
SIMULATION A.3: REFRACTION (GUI)
Simulation le: Refraction_GUI.m
Purpose: To become familiar with the principle of refraction. Same as Refraction.m,
however uses graphic user interface (GUI).
Related chapter: 4–Manipulation of Light
iNstructioNs
1. In the upper menu: Debug Run. (Or use F5. In MATLAB 2007b or later,
use “Run” arrow icon on the menu.)
2. Change GUI inputs and observe light rays. To change O
1
, either use sliders
or enter number in the box, then move the mouse outside the box and click.
To change n
1
or n
2
, enter number in the coresponding box, and click the
mouse outside the box.
Input and output angles are shown at the MATLAB prompt.
FIGURE A.2 Screen capture of the plot generated by running the MATLAB simulation
“Refractio.m.” For this example, n1 = 1, n2 = 1.5, Input angle = 45 deg., and the resulting
output angle = 28.13.

Get Optics Essentials now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.