Optical  System  Simulation  Software

Frequently asked questions about DIFFRACT

Question: How can one obtain printouts of the various plots of the beam cross-section that DIFFRACT displays on the monitor?

Answer: A quick printout of the entire Graphics Window may be obtained by first selecting that window, then choosing Print from the File menu displayed at the top of the screen. However, if you want to incorporate the graphics into a document you must save the plot files to the hard disk. Saving will create, in addition to the graphic data-files, a bitmap file containing the latest screen dump. You may load these .BMP files to any Windows-based utility package (such as Word® and Paint®) in order to manipulate and/or print them. As for the graphic .DAT files, using the File_Management/Graphics option of DIFFRACT, you may convert these files into TIFF format, and save them again. The TIFF files may subsequently be ported to a word processor and incorporated within your documents. The .DAT graphic files are simple 2-D arrays of ASCII numbers; these files may therefore be ported to many commercially available graphics programs (e.g., Matlab®, Mathematica®, Origin®, etc.), and rendered as 3-D plots, contour plots, color-coded plots, and so on.

Question: How do I abort the program?

Answer: If DIFFRACT's main menu is on the screen and you are being prompted to select an option, simply choose the QUIT option. This will end the program normally, and all your data files (such as command.dat, session.dat, signals.dat, etc.) will be preserved. If, on the other hand, the program has stopped responding to you, or if it is in the middle of a lengthy calculation which you want to terminate, you can do one of two things:

  • Close the main window by clicking the mouse on the upper right corner of the screen.
  • Type Ctrl + C at the keyboard, that is, hold down the Ctrl key and type C.

Either way the program will abort and your data files will be fully or partially lost.

Question: Is there a good way to determine whether the mesh is adequate for the problem at hand?

Answer: The mesh parameters NMAX and NMAY are chosen by the user, typically in the beginning of a session, and do not change their values throughout the session, unless forced by the user. These parameters represent the number of pixels along the X- and Y-axes, and their values are limited by the available memory of the computer, as well as by the desired speed of execution of the program. (In the Student Edition the maximum allowed value of NMAX and NMAY is 256, and the user cannot increase this upper bound. In the General Edition these parameters are initially limited to 1024, but the user may change this upper bound by modifying the corresponding parameter in the SETTINGS.LOG file.)

The other two parameters of the mesh, LMAX and LMAY, are also chosen by the user at the outset, but their values keep changing as the beam propagates through the optical system under consideration. LMAX and LMAY are the actual lengths of the mesh along the X- and Y-axes (in units of the vacuum wavelength l0), and they expand/shrink with the beam in order to accommodate the beam at various cross-sections of the system. DIFFRACT adjusts the values of LMAX and LMAY automatically throughout the simulation, and displays the adjusted values at appropriate points.

Two important mesh parameters for the user to keep track of are Dx = LMAX/NMAX and Dy = LMAY/NMAY; these are the intervals between adjacent samples along the X and Y directions of the mesh. The accuracy of a given simulation depends on whether Dx and Dy are small compared to the typical length-scale over which the wavefront (i.e., the complex-amplitude distribution within the XY-plane) undergoes significant variations. Since Dx and Dy change automatically along the propagation path of the beam, the user must monitor their values at every cross-section, in order to ensure that the discretization of the wavefront by the mesh is accurate.

It is possible, of course, to use the Rescale option from the main menu at different cross-sections, and to force the mesh to not only accommodate the beam, but also to sample it properly. This action is not recommended, however, since Rescale simply interpolates between the existing pixels, without adding any physical information. The proper course of action is to choose NMAX, NMAY, LMAX, LMAY only once, in the beginning of a session, but with the entire optical path in mind. If at some point during the simulation, the mesh turns out to be too coarse or too small for the beam, the user is advised to repeat the entire simulation with a different set of parameters for the starting mesh.

With regard to the choice of parameters for an initial mesh, it is helpful to recognize the inverse relationships inherent to the Fourier transform. For instance, if a beam is focused by a lens, its distribution at the focal plane will be the Fourier transform of the distribution at the entrance pupil of the lens. Thus, if the mesh at the entrance pupil has a length of LMAX, its length at the focal plane will be inversely proportional to LMAX. Consequently, increasing LMAX at the entrance pupil will reduce the value of LMAX at the focal plane. Similar considerations apply to far field propagation of a beam, since far field distribution is the Fourier transform of the initial distribution.

Question: I have created a COMMAND.DAT file and started running DIFFRACT in the non-interactive mode using this COMMAND.DAT. At first I chose the STEP mode to go through the program step by step and check its operation. Now that I am satisfied with the setup, can I switch to the ZOOM mode and let the program run its course without my sitting at the keyboard?

Answer: No, unfortunately there is no way to go back and forth between the STEP and ZOOM modes during non-interactive sessions. Once you are satisfied with your COMMAND.DAT, you must either continue in the STEP mode until the command sequence is exhausted, or abort the program (by closing the main window or by typing Ctrl + C at the keyboard). Only then can you restart the program and choose to ZOOM through the command.dat.

Question: I am running DIFFRACT in the non-interactive mode when I realize that I need to modify one or more command blocks within the COMMAND.DAT file. Is it possible to switch to the interactive mode and enter the desired commands from the keyboard, or is there any way at all to pause the non-interactive session in order to modify its COMMAND.DAT file?

Answer: No, unfortunately there is no way to modify the COMMAND.DAT file in the midst of a non-interactive session. You must finish the session (or abort it by closing the main window or by typing Ctrl + C), modify your COMMAND.DAT file, then repeat the simulation from the start.

Question: DIFFRACT is running very slowly on my machine. How can I improve its speed?

Answer: The speed of execution of the program during any given session is related to the chosen mesh size, namely, the value of NMAX ´ NMAY. You should try to use the smallest possible mesh without going below the required accuracy for the discretization of your wavefronts.

Occasionally, the chosen mesh is larger than the available memory of the machine. In such situations, the program swaps segments of the mesh between the RAM and the hard disk and, in doing so, slows down the computations drastically. Since a concurrently running program might be occupying a sizable chunk of memory, it might be helpful to terminate all other programs while running DIFFRACT. You should also ensure that the value chosen for NDIM in the beginning of the program is not excessively large; NDIM must be equal to the largest value of NMAX and NMAY that is used during the session, but it need not be any larger.

Also, if you do not intend to use the ray_tracing features of DIFFRACT, you can reduce memory requirements by unchecking the "Enable_Ray_Tracing" box at the outset. If all fails, of course, the only remaining solution is to increase the memory of your machine by adding a few megabytes of RAM.

Question: I want to simulate a fairly large and complex optical system. How do I minimize the amount of time spent in the interactive mode for setting up and debugging the command.dat file?

Answer: Upon starting the program in the interactive mode, choose a very small mesh, say, one having NMAX = NMAY = 128. As you build your optical system simulator by entering parameters and options from the keyboard, DIFFRACT runs the beam through this system and gives answers that are not necessarily correct, since the chosen mesh is too coarse. Ignore these results and continue building your simulation until all components of your system are in place. Then quit the program and edit the COMMAND.DAT file using a text editor. Within this COMMAND.DAT, you can now reset NMAX and NMAY to their realistic values, modify any other parameter values that you want, add any necessary looping commands ($Increment, $Multiply, $Make, $Jump, $Tags), and save the modified version of the file as the new COMMAND.DAT. DIFFRACT may now be run in the non-interactive mode from this new COMMAND.DAT file, and you may choose either the STEP option (if you want to examine intermediate results), or the ZOOM option (if you want to leave the computer and let it run the program in the background).

Question: What is the fastest way to build a COMMAND.DAT file?

Answer: If you are already familiar with the basic structure of DIFFRACT, use the <TEMPLATES > sub-directory (located in DIFFRACT's home directory) to create your own COMMAND.DAT files. To avoid accidental deletion or modification of the files contained in <TEMPLATES >, copy the text files TEMPLATE.DAT and COMMAND.DAT to another (working) sub-directory, then open both files inside your working subdirectory and place them side by side on the monitor. Copy desired command blocks from TEMPLATE.DAT and paste them (in a logical order) onto the empty COMMAND.DAT file. Proceed to modify the various command parameters until the elements of your system are properly represented. When all the elements of the system are in place, you may want to copy one or more $commands to appropriate locations within the completed COMMAND.DAT file. These $commands enable the creation of loops (or other programming constructs) for the purpose of repeating a given simulation with different sets of parameters.

Question: How can one create Geometric-optical_System files (XXXX.SYS)?

Answer: When you run DIFFRACT in the interactive mode, you will be given the option of creating a XXXX.SYS file for the geometric-optical system under consideration. Once this text file is created (within your working subdirectory) you may modify it by adding or removing various elements, or by changing the parameter values of the specified elements. An alternative approach to creating XXXX.SYS files involves the use of GEOP.SYS template located in the <TEMPLATES> subdirectory of DIFFRACT's home directory. Start by copying the GEOP.SYS file to a working subdirectory, then open this text file and follow the instructions given within the file itself.

Question: How can one create XXXX.STK files for simulating multilayer stacks in conjunction with the Multilayer feature of the program?

Answer: When you run DIFFRACT in the interactive mode, you will be given the option of creating a XXXX.STK file for the multilayer stack under consideration. Once this text file is created (within your working subdirectory) you may modify it by adding or removing various layers, or by changing the parameter values of the specified layers. An alternative approach to creating XXXX.STK files involves the use of MLYR.STK template located in the <TEMPLATES> subdirectory of DIFFRACT's home directory. Start by copying the MLYR.STK file to a working subdirectory, then open this text file and follow the instructions given within the file itself.

Question: Can I change the default values of some of the parameters that are seemingly set internally by DIFFRACT?

Answer: Yes, unless you are using the Student Edition of the program. The Install routine for the General Edition copies two files to the working directory of DIFFRACT; these are called settings.log and settings.exe. You may examine the contents of settings.log with a text editor, to find out which parameters are set to which default values. For example, the upper bound on the value of NDIM is set here, as is the size of the display arrays (NDSP0), or the maximum number of surfaces allowed in geometric-optical systems, or the maximum allowed number of layers for multilayer stacks. Whenever you run DIFFRACT, it reads (in the beginning) the file settings.log, and sets the default values accordingly. You may change these values directly by modifying the SETTINGS.LOG file. Alternatively, you may invoke the routine SETTINGS.EXE (by double-clicking on its icon or by typing "settings" at the DOS prompt within DIFFRACT's home directory), then answer the questions posed. In this way the contents of SETTINGS.LOG file will be changed according to your instructions.

Question: How do I prevent DIFFRACT's logo from appearing in the beginning of each session?

Answer: In the home directory of DIFFRACT there is a bitmap file called LOGO.BMP. Removing or renaming this file will cause the program to skip the logo screen.

Question: How do I navigate among DIFFRACT's three windows, that is, how do I switch from, say, the Dialogue Window to the Graphics Window or to the window that contains the Guiding Information?

Answer: In their default positions, the three windows are either fully or partially visible at all times. You may point and click the mouse on the desired window to switch to that window. Alternatively, you might use the Ctrl + TAB key combination to move sequentially among the windows. The latter option also works if you have moved the windows or changed their sizes, thus causing the desired window to be hidden from view.

You switch to the Guiding Information window to read the instructions or to get detailed information about a command or option with which you are not familiar. You switch to the Graphics Window to view the displayed graphics, or to enlarge the window in order to see more of the screen in more detail. Whatever the reasons may be for switching to another window, you must always return to the Dialogue Window in order to continue your interactions with the program.

You can enlarge, shrink, resize, or move a window by dragging its various boundaries, or by clicking the buttons at the upper right corner of the window. These changes remain in effect for a short while, until the main menu of DIFFRACT returns to the Dialogue Window, at which point the three windows will be reset to their default positions.

Question: When using the PLOT option, what is the fastest way to specify the boundaries [Xmin : Xmax, Ymin : Ymax] of a plot?

Answer: Start by typing a value for Xmin; the program assumes that you want to plot a square region centered at the origin, (X, Y) = (0, 0), and enters the corresponding values for Xmax, Ymin, and Ymax automatically. If these values are acceptable, you do not need to do anything else, otherwise, type in the desired values for the remaining parameters. (If the first parameter that you enter for the plot boundary is not Xmin, you will have to type all four parameters, even when you intend to plot a square region centered at the origin.)

Question: How do I run two or more COMMAND.DAT files in the ZOOM mode, without having to stay around to initialize DIFFRACT for each run?

Answer: In the beginning of each session, the user is asked to specify a working subdirectory. You can specify as many as 20 different subdirectories at this point, simply by entering their names sequentially (separated by blanks or commas). The program then begins in the first specified directory and, upon completing the run, moves to the second directory, where it starts a new run. The process thus continues until all the specified subdirectories have been exhausted. In this way, all the various COMMAND.DAT files, initially placed in separate subdirectories within DIFFRACT's home directory, are executed independently, each within its own directory. The data-files created during each one of these multiple sessions are recorded in the corresponding subdirectory. All data-files needed by the program for a given run (including COMMAND.DAT) must reside within the same subdirectory.

Question: I used the TIFF option under FMAN, but it outputs only black-and-white images. How can I specify a color option for the TIFF output?

Answer: TIFF always yields black-and-white images. To get color pictures, while in FMAN, use the Display option (D) with Color sub-option (C). DIFFRACT will display the color image on the monitor. You may save this as a Bitmap file using the B option. Later, you may have to double-click on the xxxx.bmp file thus created in order to open it (with MS_Paint) and change or remove some of the text, labels, white space, etc.

Question: How can I compute the total intensity |Ex|2 + |Ey|2 in DIFFRACT?

Answer: First, PLOT the desired intensity distribution for the x- and y-components separately and save them to file by specifying a file number nn. At this point you will have the intensity plots IXnn.DAT and IYnn.DAT in your working directory. After this, call FMAN and use the Load option (L) to load one of the files, say, IXnn. While IXnn is in FMAN's buffer, use the Load_and_Add option (A) to add IYnn to the buffer (set weight-factor = 1). You now have the sum of the two intensity profiles in FMAN's buffer, which can be saved to file in Tiff format (T option), Bitmap format (B option), or ASCII format (F option). To save as bitmap, however, note that you will have to display the content of the buffer (D option) before calling upon the B option.

Home | About MM Research, Inc. | Online Publications
Diffract | SIM 3D_Max | Multilayer | Temprofile

© Copyright 1987-2011, MM Research, Inc. 5748 N. Camino del Conde, Tucson, Arizona 85718