Designs are coded in Scheme language files. More than one design can
be specified in a design file, permitting sharing of code. A variety
of design examples are contained in the validation suites
`dielectric.scm', `metallic.scm', and `granular.scm'.
The graphs output by these suites are shown and discussed in
http://people.csail.mit.edu/jaffer/FreeSnell/dielectric.html,
http://people.csail.mit.edu/jaffer/FreeSnell/metallic.html, and
http://people.csail.mit.edu/jaffer/FreeSnell/granular.html
The index-of-refraction of dielectric materials often varies little with wavelength. In these cases the index-of-refraction can be a number. It is often convenient to give a symbolic name to numbers. For example:
(define ZnS 2.2) ;znscub +0.01i (define Ge 4.2) ;ge
After these definitions, layers can reference the identifiers:
(optical-stack
(substrate 1)
(layer ZnS 528.64e-9)
(layer Ge 178.96e-9)
(layer ZnS 250.12e-9)
(layer Ge 123.17e-9)
...
Sometimes the index-of-refraction is specified as a formula of wavelength. The Refractive index database at http://refractiveindex.info gives a formula for the refractive-index of the plastic PMMA over the range 0.4358.um to 1.052.um. We can use its formula as a Scheme function:
;; n^2 = C1 + C2*wl^2 + C3*wl^-2 + C4*wl^-4 + C5*wl^-6 + C6*wl^-8
(define PMMA
(let ((C1 2.399964)
(C2 -8.308636E-2)
(C3 -1.919569E-1)
(C4 8.720608E-2)
(C5 -1.666411E-2)
(C6 1.169519E-3))
(lambda (w) ; wavelength in meters
;; wavelength in microns and limited to valid range
(let* ((wl (max 0.4358 (min 1.052 (* w 1e6))))
(wl^-2 (/ 1 wl wl)))
(sqrt (+ C1
(* C2 wl wl)
(* (+ C3 (* (+ C4 (* (+ C5 (* C6
wl^-2))
wl^-2))
wl^-2))
wl^-2)))))))
For more compliated material properties FreeSnell retrieves the wavelength-dependent index-of-refraction by calling functions which interpolate values from the materials database (see section Material Databases).
(require 'FreeSnell)
(require 'databases)
(require 'database-interpolate)
(defvar nk (open-database (or (getenv "NK_DATABASE_PATH") "nk.rwb")
'rwb-isam))
(defvar ge (interpolate-from-table (open-table nk 'ge) 2))
(defvar zns (interpolate-from-table (open-table nk 'znscub) 2))
...
In this example ge and zns can be passed as arguments to
layer and substrate.
For dielectric films embedded with spherical metal granules much smaller than the thickness of the film and the wavelengths under consideration, Maxwell Garnett Theory provides a means to calculate the effective n and k. The thickness of the granular film must be several times the granule size; otherwise the more complicated machinations of [Granfilm] are required.
granular-IR returns a complex index-of-refraction for the
composite layer.
(define (ruby-glass w) (granular-IR (Au w) 8.0e-6 1.5))
layer or substrate.
Substrate arguments must be first or last and default to having an
index-of-refraction of 1. A substrate has arbitrarily large
thickness, and is the source or sink of test inputs (radiation).
If ir is a number, then the index-of-refraction is ir at
all wavelengths. If ir is a procedure then the
index-of-refraction at wavelength w is (ir
w).
If the number thick is smaller than 1/50, then it is taken as the actual thickness. Note that the effective optical thickness will be larger than the actual thickness because light is slowed by the index-of-refraction.
If the number thick is larger than 1/50, then the thickness is
thick times nominal divided by the real-part of the
index-of-refraction at nominal, where nominal is either
the third argument nom or the value set by the nominal
function. This is a convenient notation for the fractional optical
wavelengths often used to specify filter elements.
Layers specified by layer model the interference effects of
reflections of reflections. This is correct for thin layers or if the
modeled optical system will be illuminated by coherent light. But
layers thicker than several wavelengths have variations extremely
sensitive to incident angle.
Incoherent illumination will average over the wiggles. For these layers FreeSnell computes the transmitted and reflected power ratios, rather than E-fields.
If ir is a number then the index-of-refraction is ir at
all wavelengths. If ir is a procedure then the
index-of-refraction at wavelength w is (ir
w).
If substrates are not specified, then their index-of-refraction defaults to 1 (vacuum).
To place a substrate between two sets of layers, use layer*
instead.
nominal commands are allowed interspersed with layer
commands. The arguments to optical-stack are considered in
order from the first to the last.
optical-stack, or a value returned by a call
to IR. The other arguments should be values returned by the
functions in sections section Ranges and Units, section Traces, and
section Color-Swatches.
Plot-response creates a graph, data file, or color patches as
directed by its arguments. If more than one optical stack is given,
the same quantities are computed for each optical stack; but all are
plotted to a single graph.
stack-colors is called more than
once, then its color arguments are appended together.
stack-colors causes the traces from each optical stack to be
drawn in its corresponding color.
According to the symbol sym, sets the disposition of plots to be:
| eps | filebase.eps |
| ps | filebase.ps |
| png | filebase.png |
| jpg | filebase.jpg |
| jpeg | filebase.jpeg |
| filebase.pdf | |
| #t | views filebase.eps using ps:viewer.
|
If output-format is not used, then the output-format defaults
to the value of top-level identifier *output-format*, which
defaults to #t.
If a pair of nonnegative exact integers, k1 and k2 follows sym, then the plot will be k1 pixels horizontally and k2 pixels vertically.
The output-format command does not affect the data written by
output-data.
If a string fnt is supplied, then it names the PostScript font
which will be used. The default value is Times.
If a nonnegative real number x follows the fnt, then x is the fontsize.
If two strings follow, then they are used as the templates whose printed representation using fnt is used to size the left and right margins respectively. If not specified, the templates default to `-.0123456789'.
If x is not specified and k1 is, then the font height will be k1/33. If neither is specified, then the font height will be 12.
The font command does not affect the data written by
output-data.
str1 and str2 are printf format strings for the first number and the rest of the numbers printed on one line. If #f is passed, then the corresponding numbers are written with full Scheme precision and tab delimited.
marker command does not affect the data written
by output-data.
These functions specify whether the plot holds angle constant and
varies wavelength; holds wavelength constant and varies angle; or
plots components of the index-of-refraction of a material. Multiple
invocations of any one of these functions puts all those specified
traces in one plot. To generate separate plots call
plot-response multiple times.
The type of a trace appearing in a plot is specified by a symbol. The first ten in this table are for separate polarizations. The rest average the two polarizations.
| T_s | S-plane transmission |
| R_s | S-plane reflection from top |
| B_s | S-plane reflection from bottom |
| A_s | S-plane absorption from top |
| L_s | S-plane absorption from bottom |
| T_p | P-plane transmission |
| R_p | P-plane reflection from top |
| B_p | P-plane reflection from bottom |
| A_p | P-plane absorption from top |
| L_p | P-plane absorption from bottom |
| T | tranmission |
| R | reflection from top |
| B | reflection from bottom |
| A | absorption from top |
| L | absorption from bottom |
A trace can also be a quoted scheme expression combining numbers and
the symbols listed above with the operators +, -,
*, /, ln, log_10, and average. The
following example computes the reflectivity relative to a substrate
reflectivity of 0.023:
(incident 45 '(/ (- R_p .023) .023))
The angle argument can also be a list of angles in degrees. In this case the plots of trace1, trace2, ... will be averaged over the angles given.
This is useful when profiling materials whose thicknesses are several times wavelengths of interest. Plots at a single angle of incidence can oscillate wildly with wavelength as the reflections go in and out of phase, constructively and destructively interfering.
The following statement will cause plot-response to compute the
reflected color (average of both polarizations) at 30 degrees from the
surface normal.
(color-swatch 30 'R)
If there are any color-swatch statements passed to
plot-response, then a file named
filebase-color.png will be written containing 64x64
pixels color squares, one for each color computed. The squares are
arrayed horizontally in the order they are passed to
plot-response. Vertically, one such row is generated for each
optical stack.
The filebase string is that set by the title command.