1. Introduction to Rayica

1.1 Overview

1.2 Getting Started

1.3 General Architecture of Rayica

1.3.1 A Simple System

1.3.2 Calling Conventions

Options
Required Parameters
The Subtle Semicolon

1.3.3 Components

Components in a System
Complex Components

1.3.4 Light Sources

Basic Light Sources
Two-dimensional Sources
Gaussian Sources
Coincident Light Sources
Random Light Sources
Nested Light Sources
Aperture Stops
Connections Between Sources and Rays

1.3.5 Rays

Ray Properties and Queries
Using Rays to Understand Your System
Finding the Focus

1.3.6 The Ray Tracing Process

AnalyzeSystem Function
Sequential and Nonsequential Ray Tracing

1.1 Overview

Rayica is a new generation of optical design software.  It offers unprecedented  flexibility and builds upon the enormous repertoire of symbolic, numeric, and  graphic capabilities of Mathematica.  With its searchable component database of more than 6800  commercial optical parts, you can design optical systems faster than ever  before.  Yet Rayica does not limit you to predefined components, nor constrain you by limited  script languages.  Whatever you can conceive doing, you can do with Rayica.
Rayica has a modular building-block architecture that makes addition of  custom components a snap.  Aspheric lenses, custom surfaces, resonating  cavities, and optical fibers represent just a few of the possibilities, from  mundane to exotic.  Rayica is limited only by your imagination and the unbounded  possibilites of Mathematica.  Rayica is like a well-stocked workshop, ready for any project.  If a component  or analysis function doesn't exist in Rayica, you have the tools to build it yourself.
Rayica is an open-source package; unlike other optical software  packages, Rayica conceals nothing about its internal operations.  The simple  building-block architecture of Rayica also makes it easy to learn.
The power of Rayica lies not only in the components of optical systems, but also in the rays  themselves.  These are full-fledged system objects in their own right.  You  can tag specific rays with descriptive labels and follow them through a  complex system.  Optical ray-tracing can be sequential or nonsequential.  The  ray-tracing engine can even perform traces with arbitrary precision, beyond  standard machine precision.
Rayica introduces tremendous performance gains over the first release.   Speed improvements of two orders of magnitude have been observed.  These  improvements address a critical concern of system designers who must iterate  designs several times to obtain optimal systems.  Rayica presents several new user options for speed performance.
In Mathematica Version 4 or later, you can now rotate optical system graphics  interactively with your mouse.

Go to list of topics

1.2 Getting Started

First read about the general architecture of Rayica, then exercise the simple examples.  This activity should take between two  and four hours.
Once you have mastered the basic aspects of Rayica, you can explore the more advanced aspects of the system.  In many cases,  you can begin designing your own systems by modifying or combining examples  from the manual.
You can learn a great deal from the Help Browser, and Rayica has its own section in the Help Browser.  Once you have installed Rayica, be sure to rebuild your help index so that this section becomes  available to you.
Information about any Rayica object or function may also be obtained by the built-in Mathematica ? or Information command.  

In[32]:=

? Mirror

Mirror[aperture, options] and Mirror[aperture, thickness, options]  denote a planar  ... ircle, rectangle, or polygon depending  on the number and type of elements listed by it.

An information query given after loading Rayica.

Go to list of topics

1.3 General Architecture of Rayica

Rayica presents a high-level interface that allows you to manipulate virtual  optical systems instead of Rayica data constructs.  You will seldom, if ever, need to deal with Rayica's internal data structures.  However, an understanding of the design  architecture is still important for proper usage.
Rayica builds upon simple foundational concepts.  These concepts are systems, components, sources, and rays.  A system comprises a set of optical components and sources.  The components are lenses, mirrors, prisms, and other optical objects that interact with  rays.  A source is a light which emits rays.  Finally, a ray encodes information about surface intersections, optical path lengths,  physical path lengths, and light intensity.

Go to list of topics

1.3.1 A Simple System

To make this discussion concrete, load Rayica and define a simple system.

In[1]:=

Needs["Rayica`Rayica`"]

+++++++++++++++++++++++++

Rayica build-date March 18, 2004) was loaded in 58 s and needs 5913 kilobytes of memory on top of 3495 kilobytes already used

In[3]:=

myComponent = PlanoConvexLens[50, 25, 5] ; RowBox[{RowBox[{mySource, =, RowBox[{Move, [, RowBo ... ]}], ;}] mySystem = {mySource, myComponent} ; AnalyzeSystem[mySystem, PlotTypeSideView] ;

[Graphics:HTMLFiles/index_5.gif]

Load Rayica and define a simple system. Later you will learn about a  method to expedite the loading of Rayica.

The system has one lens and one light source.  The whole system is stored  in a single Mathematica variable, mySystem.  This variable holds a Mathematica list, indicated by the curly braces { }and elements being separated by  commas.  The two elements of mySystem are mySource and myComponent.  Rayica systems can contain arbitrary numbers of components and sources.

There are several points to note about this example.  In the absence of  other infomation, Rayica always selects built-in defaults.  In this instance, Rayica assumes that myComponent is made of the default material for a PlanoConvexLens, namely BK7 glass.  That assumption is how Rayica determines the refraction through myComponent.

Not all parameters can assume default values.  Components usually require certain explicit parameters related to their  type.  A PlanoConvexLens requires specifications for focal length, aperture diameter, and lens  thickness, in that order.  Every component has its own explicit parameter  requirements.  Use the Help Browser to find out what parameters you need for  any given component.

You are free to employ any system of units.  The parameters of myComponent could be millimeters, centimeters, inches, or any other unit of length.   The best strategy is to adopt a convention for units in your Rayica work and stay with it.  For example, you might assume that all dimensions  are millimeters.  Realize, however, that Rayica does use specific units in certain situations.  The Rayica catalog database contains thousands of predefined commercial optical  components with inherent units.  If the units of a catalog component do not  match your working units, then you will have to convert them as appropriate.   Built-in units, where used, are usually microns for wavelengths, millimeters  for physical length, and degrees for angles.

Rayica has functions for positioning components and light sources in all six  degrees of freedom.  The light source in this example is a ConeOfRays that has been positioned by the Move command.  Move is a translational positioning command.  ConeOfRays is one of several different light sources available in Rayica.  Each offers a unique geometric distribution of rays.  The  cross-sectional cone angle here is 30 degrees, and the cone origin is  positioned 31.33 units to the left along the optic axis.  Rayica uses the x-axis as the optic axis by default, but you are free to  coordinate your system in any way you see fit.

AnalyzeSystem performs the ray-trace and produces a graphic of the system.  The rays in  this example terminate at the back surface of the lens simply because we did  not specify any other boundary for the system.  Rayica cannot determine where else the rays should go, so they stop.  In most  cases you will employ the Boundary component to provide Rayica with an enclosing termination surface for the system.  The rays appear  green to match their default wavelength specification of 0.532 microns, which  is green light.

Finally, we used options; an option is seen with its name preceding the arrow symbol  (→), and its setting following.  We used one option, NumberOfRays, to cause the light source to produce exactly 40 rays.

Another option called PlotType, with a setting of SideView, determined the output graphics format.  The resulting graphic is not  photo-realistic.  Rayica renders approximate images of optical components using polygons.   Ray-tracing analysis still follows the true shape of the component.  Usually  this shape is smooth and continuous.

Go to list of topics

1.3.2 Calling Conventions

Options

Mathematica options are the standard mechanism for default parameters.  A large  majority of Mathematica functions have options, and Rayica is no exception.  Options allow you to change only those parameters that  are necessary.  Options greatly simplify Mathematica input by providing descriptive names and by minimizing the quantity of  function parameters.
Here is a display of options associated with PlanoConvexLens.

In[7]:=

ColumnForm[Options[PlanoConvexLens]]

Out[7]=

Labels→"L"
LabelPositions→Automatic
ComponentDescription→Automatic
ComponentMedium→BK7
Temperature→Temperature
Tension→Tension
Transmittance→Transmittance
GraphicDesign→Automatic
CurvatureDirection→Front
RowBox[{DesignWaveLength, →, 0.5461}]
OffAxis→ {0, 0}
SwitchDirectionOnReflection→True
Automatic→ {SurfaceRendering→Empty, EdgeRendering→Mesh, CrossRendering→ {{Fill, Trace}}}
Sketch→ {SurfaceRendering→Trace, EdgeRendering→Empty, CrossRendering→ {{Fill, Trace}}}
Wire→ {SurfaceRendering→Mesh, EdgeRendering→Mesh, CrossRendering→ {{Fill, Trace}}}
Solid→ {SurfaceRendering→ {{Fill, Trace}}, EdgeRendering→Fill, CrossRendering→Empty}

Available options for PlanoConvexLens.

Use the Options command any time you are curious about the default options for a  particular function, whether in Mathematica or Rayica.

Options may be input in any order.  They are case-sensitive.  You set  options with an arrow, entered as a hyphen followed by a greater-than sign.   Mathematica may coalesce these two characters into one arrow symbol → for  you.  The default value of an option never changes.  Each time you call a  function having options, but cannot accept a particular default, you must  override the default.

There are methods for expediting option entry.  As with any other Mathematica input, if you don't remember the exact name or spelling of an option,  type a few initial letters, then press the command-completion hotkey ( [CTRL]-K for Windows and ⌘-K for Macintosh).  Mathematica then presents you with a list of candidate inputs, all of which start  with those letters.  Selecting one element from the pop-up menu completes the  typing for you.

Mathematica also allows you to create variables that contain your custom option  settings.  

In[8]:=

myOpts = Sequence[PlotType  Full3D, WorkingPrecision16] ; AnalyzeSystem[mySystem, myOpts] ;

[Graphics:HTMLFiles/index_8.gif]

The variable myOpts can now be used in subsequent calls to AnalyzeSystem.  It holds settings for two options called PlotType and WorkingPrecision.  The Sequence wrapper is necessary here because myOpts is inserted in sequence with other input parameters whenever it is used.

Rayica uses options to maintain information about various objects.  Sometimes we  refer to the "properties" or "attributes" of an Rayica object.  These terms may usually be viewed as synonyms for the more  technical Mathematica term "options."  Thus the statement that object Thing has property Prop set to 10, and attribute Att set to 20, just means Thing[Prop → 10, Att → 20] in the Mathematica sense.

Go to list of topics

Required Parameters

Most functions have one or more required parameters.   These are always given in a particular order and appear ahead of all option  settings.  

In[10]:=

mySource = ConeOfRays[20, NumberOfRays40] ; (* GOOD *)

The input calls ConeOfRays with one required parameter set to 20 and one option set to 40.   In Mathematica, options must always follow the required parameters.  Try  defining mySource as above, but with the option first, followed by the required  parameter.

In[11]:=

mySource = ConeOfRays[NumberOfRays40, 20] ; (* BAD *)

This input produces an error.

The most important fact about required function parameters is  that functions may allow them in different combinations.  These are different  ways of calling the same function effectively.  An example is Grating.  From the online Help Browser, Grating offers three distinct input formats.

Grating[gratingfunction, aperture, options], Grating[gratingfunction, aperture, thickness, options], and Grating[surfacefunction, gratingfunction, aperture, thickness, options] denotes a diffractive component that splits incoming rays into multiple  diffracted orders according to the gratingfunction parameter and the DiffractedOrders option.

You are free to use any one of the alternative input formats.  You must  supply each of the required parameters for whichever format you choose.  In  all cases, the options come last, after the required parameters for your chosen input format.

Some functions have no required parameters.  In these cases you just enter the options by themselves, if any are needed.

Go to list of topics

The Subtle Semicolon

Mathematica interprets command lines ending with a semicolon in a special way.  Most  command lines result in some sort of output.  The semicolon supresses such  output.  

In[12]:=

x = 5

Out[12]=

5

In[13]:=

y = 10 ;

These two assignments are not fundamentally different, but the second assignment uses a semicolon to supress the output.  Arithmetic operations work similarly.

In[14]:=

x + y

Out[14]=

15

In[15]:=

z = x + y ;

The computation of x+y was performed in both cases.  Only one of them wrote output to the  screen.  At this point the variable z is defined and set equal to 15.  To find out the value of z, just enter it.

In[16]:=

z

Out[16]=

15

Use semicolons to prevent your screen from becoming cluttered with unnecessary output data.

Go to list of topics

1.3.3 Components

Components are the fundamental building blocks of Rayica.  Define optical systems as three-dimensional arrangements of  components and sources.  Rayica represents optical components as Component objects.  This category includes standard optical components, like lenses  and mirrors, but also certain non-standard objects.  Not all Rayica components represent physical optical components; an understanding of  this fact is important.  For example, a Boundary or Screen object need not correspond to any physical device.  Such components,  nonetheless, perform essential functions in Rayica.

The purpose of components is to hold information about ordered surfaces.   This information is used for ray tracing.  Differentiation among components  is achieved by various Rayica functions that add, delete, or change the settings of a Component.  Sometimes these funtions are described as genetic because they modify  traits of an object, just as biological genes modify physical traits.  In  most cases you will not need to worry about how Rayica accomplishes this action.

All Rayica components are Component objects.  When you input PlanoConvexLens, you effectively create a Component with special attributes related to the shape and behavior of a  plano-convex lens.  Rayica offers dozens of predefined component types such as this.  You will  almost never deal with a Component directly.  Instead, you will use stock components in the Rayica library such as PlanoConvexLens.  Peruse the Help Browser to acquaint yourself with the built-in  component types (Add-Ons Å Rayica Å Optics).

Go to list of topics

Components in a System

Here is a system incorporating multiple components of different kinds.   The system is expressed as a Mathematica list and is bracketed by curly braces.  The system list is the first  argument to the function AnalyzeSystem.  The second argument is an Rayica option called PlotType, which is set to TopView.

In[17]:=

AnalyzeSystem[ {WedgeOfRays[20], Move[PlanoConvexLens[100, 50, 10, Cur ... ;Boundary[{-60, -70, -100}, {350, 250, 100}] }, PlotTypeTopView] ;

[Graphics:HTMLFiles/index_20.gif]

A typical Rayica system.

This system has one source and eight components.  This system was entered  without the use of intermediate variables such as mySource.  Note that the light source is at the origin of the system coordinates.   Components are moved relative to this point.  An outer Boundary defines the termination boundary for the rays; this is one component of  the system.  An inner ClearBoundary serves as a fiducial marker; this is a second component.  There is also a  Screen (S), a third component.  This screen does not affect the rays passing  through it.  The remaining five components are standard optical elements.  Rayica has assigned them default labels that you did not have to enter.  In  addition to the eight components of this system, there is one light source, a  WedgeOfRays.  All told this system has nine Rayica objects.

The ordering of components within a system is important.  Generally  speaking, the system list must follow the anticipated light path for your  system.  In the system above the order is PlanoConvexLens, WedgePrism, Screen, CylindricalMirror, BeamSplitter, BiConvexLens, ClearBoundary, Boundary.  In subsequent chapters you will learn more about how Rayica orders tracing through systems.

PlotType is an option for Rayica graphics output.  Rayica graphics are Mathematica graphics, and, therefore, incorporate all the options of Mathematica graphics.  Options like Frame and FrameTicks are standard Mathematica options for two-dimensional graphics.

Go to list of topics

Complex Components

Components can be complex.  This is an example of a CompoundLens object.  It too is a Component, but a complicated one.  Look in the Help Browser for information about  how to define a CompoundLens.

[Graphics:HTMLFiles/index_21.gif]

A single Component with multiple internal surfaces.

Both PlanoConvexLens and CompoundLens create a Component object.  Ultimately the Component object is the one actually used for ray tracing.  In principle, you could  enter the equivalent Component objects directly by yourself.  However, Rayica gives you ready-made interfaces like PlanoConvexLens and CompoundLens to do the job for you.  This way you can concentrate on your system  instead of programming.  Two other Rayica functions that build complex components are LensDoublet and LensTriplet.

CompoundLens creates a single Component object.  This component does not exist until you call CompoundLens.  Sometimes you need to meld pre-existing components into a single,  aggregate component.  The Rayica functions BuildComponent and Resonate accomplish such aggregation.  You will learn more about these functions  later.

Go to list of topics

1.3.4 Light Sources

Rayica represents light sources as Source objects.  Just as all components are Component objects, all light sources are Source objects.  Light sources, in turn, generate the Ray objects that propagate through your system.  You will almost  never need to create Ray or Source objects yourself because Rayica presents a full suite of candidate sources.

To obtain meaningful results, you must position your light sources  properly.  Light sources usually propagate light in one direction.  The  default direction is along the optic axis (the x-axis in Mathematica).  The same positioning commands that work with components also work  with light sources.  Sources may be moved and rotated in arbitrary fashion.  By default,  however, light sources emerge from the origin toward the positive optic  axis.

Go to list of topics

Basic Light Sources

Rayica light sources typically distribute outgoing rays uniformly  across some geometric surface or path.  Optional settings exist for  nonuniform or random distribution along the same geometry.  

In[18]:=

AnalyzeSystem[{ConeOfRays[45, NumberOfRays  30], Boundary[100]}, Axes  True] ;

[Graphics:HTMLFiles/index_23.gif]

A simple geometric light source called ConeOfRays.

Often you will want the light source to emit rays from a single point, as  with ConeOfRays, but according to some other distribution.  The most general Rayica source that performs this function is PointOfRays.

In[19]:=

AnalyzeSystem[{PointOfRays[{40, 20}, NumberOfRays  5], Boundary[100]}, Axes  True] ;

[Graphics:HTMLFiles/index_25.gif]

A PointOfRays light source.  The rays form a grid pattern, but emanate from a common  point.

PointOfRays may be called in a number of different ways.  We have called it with a  list of two numbers {40, 20} that defines a rectangular distribution of rays.  This rectangle  subdivides into grid positions on each side according to the NumberOfRays option (five in this case).

In optics and physics, you often deal with so-called point sources.  These  are conceived as isotropic sources that emanate equally in all directions.   PointOfRays is the mechanism you would use to generate such a source.  There is a  detailed example of this particular case in the Help Browser.  However you  should realize that most optical design work does not demand true point  source testing.

If you want parallel (collimated) rays, use GridOfRays.

In[20]:=

AnalyzeSystem[{GridOfRays[{40, 20}, NumberOfRays  5], Boundary[100]}, Axes  True] ;

[Graphics:HTMLFiles/index_27.gif]

A GridOfRays light source.  The parallel rays form a grid pattern.

Go to list of topics

Two-dimensional Sources

All Rayica sources emit into three-dimensional space, but some of them constrain  their emission to a plane.  WedgeOfRays is one such source.

In[21]:=

AnalyzeSystem[{WedgeOfRays[30, NumberOfRays  10], Boundary[100]}, Axes  True] ;

[Graphics:HTMLFiles/index_29.gif]

A WedgeOfRays light source.  The emission is contained within a plane.

Another source in this category is LineOfRays.  Planar sources can be moved and rotated like any other source.  These  operations will alter the orientation of the plane.

Go to list of topics

Gaussian Sources

One of the most important of all sources is GaussianBeam.

GaussianBeam[beamspotsize, fulldivergence, options] and GaussianBeam[complexbeamparameter, options] takes either the output beam spotsize radius (specified at 1/e of the axial value of the electric field amplitude peak in the starting plane) and far-field beam fulldivergence (specified as the full angle in radians) or the complex beam parameter as input. Unlike most other types of sources can either be constrained to a plane or emit on all three-dimensions according to the FullForm option.

In[80]:=

RowBox[{RowBox[{AnalyzeSystem, [, RowBox[{RowBox[{{, RowBox[{RowBox[{GaussianBeam, [, RowBox[{ ... rm  False}], ]}], ,, Move[ Boundary[100], -5]}], }}], ,,  , Axes  True}], ]}], ;}]

[Graphics:HTMLFiles/index_31.gif]

A GaussianBeam light source with its emission constrained to a plane with FullForm → False.

In[81]:=

RowBox[{RowBox[{AnalyzeSystem, [, RowBox[{RowBox[{{, RowBox[{RowBox[{GaussianBeam, [, RowBox[{ ... orm  True}], ]}], ,, Move[ Boundary[100], -5]}], }}], ,,  , Axes  True}], ]}], ;}]

[Graphics:HTMLFiles/index_33.gif]

A unconstrained GaussianBeam light source with FullForm → True. Note the square shape of the beam. This is simplifies wavefront calculations.

Go to list of topics

Coincident Light Sources

Light sources can be coincident.  Here is an example  in which coincident light sources create concentric cones of rays.

In[22]:=

concentricSources = Table[ConeOfRays[angle, NumberOfRays  30], {angle, 15, 45, 15}] ; AnalyzeSystem[{concentricSources, Boundary[100]}, Axes  True] ;

[Graphics:HTMLFiles/index_35.gif]

Light sources may be coincident.  Here all sources emerge from the origin.

The Mathematica command Table generated a list of ConeOfRays functions.  The parameter to ConeOfRays was the iteration parameter of Table.  The same method works with non-angular sources like CircleOfRays.

In[24]:=

concentricSources = Table[CircleOfRays[diameter, NumberOfRays  30], {diameter, 20, 60, 20}] ; AnalyzeSystem[{concentricSources, Boundary[100]}, Axes  True] ;

[Graphics:HTMLFiles/index_37.gif]

These light sources are also coincident at the origin.

Go to list of topics

Random Light Sources

Sometimes you want a light source with a random character.  The MonteCarlo option fills this requirement.

In[71]:=

randomParallelLight = AnalyzeSystem[{GridOfRays[{75, 75}, NumberOfRays20, MonteCarloTrue], Boundary[100]}, PlotTypeFull3D, RayLimit150, Axes  True] ;

[Graphics:HTMLFiles/index_39.gif]

A random-pattern parallel source.

Here is a random point source.

In[75]:=

randomPointSource = AnalyzeSystem[{PointOfRays[{75, 75}, NumberOfRays20, MonteCarlo ... 54;Stratified], Boundary[100]}, PlotTypeFull3D, RayLimit150, Axes  True] ;

[Graphics:HTMLFiles/index_41.gif]

A random-pattern point source.

Go to list of topics

Nested Light Sources

You can also embed light source functions within each other to build customized light sources.  You can build up complex sources very quickly this way.  Here is an example with three embedded sources.

nested2DLight = AnalyzeSystem[{LineOfRays[WedgeOfRays[WedgeOfRays[3], 30], 30], Boundary[100]}, PlotTypeTopView] ;

[Graphics:HTMLFiles/index_43.gif]

A two-dimensional nested light.

Here is a three-dimensional nested source.

In[4]:=

nested3DLight = AnalyzeSystem[{PointOfRays[ConeOfRays[15, NumberOfRays15], {75, 75}], Boundary[100]}, Axes  True] ;

[Graphics:HTMLFiles/index_45.gif]

A three-dimensional nested light source.

Go to list of topics

Aperture Stops

You can further customize or shape light sources by means of an aperture.   Use Rayica's ApertureStop function to create such an aperture.

Here is a stop with four separate apertures.  One way to construct such a  stop is by positioning four separate ApertureStop objects.

circleAperture = ApertureStop[{50, 50}, 25] ; slitAperture = ApertureStop[{50, 50}, {5, 30}] ; ... ], Translate[ellipseAperture, {25, -25, -25}], Boundary[{0, -50, -50}, {100, 50, 50}]}] ;

[Graphics:HTMLFiles/index_47.gif]

Rayica's ApertureStop creates apertures with user-defined shapes.  Here a GridOfRays impinges on four ApertureStop objects.

Optical designs often exploit aperture stops to moderate the total amount of light entering a system.  Even in the absence of an aperture, every simple lens has an equivalent aperture defined by its circumference.  This equivalent aperture is the lens aperture.

Go to list of topics

Connections Between Sources and Rays

Light sources have an attribute called SourceID.  This attribute uniquely identifies a light source.  It distinguishes  among multiple sources in the same system, and ties Ray objects to their originating Source.  Each Ray remembers the originating SourceID number.  Note also that any valid option for Ray is a valid option for Source.

Go to list of topics

1.3.5 Rays

Ray objects record information about the trace of an optical system.  They  contain information about their source of origin, surface intersections,  light intensity, wavelength, and optical path lengths.  You never create Ray objects directly.  If you ever need a single ray, use the SingleRay light source to get it.  You need to know about Ray objects only because they are fundamental to the ray tracing procedures  in Rayica.  In general, you will not manipulate them directly.

Rayica creates rays during a trace.  Until you call an Rayica function that performs ray tracing, such as AnalyzeSystem, there are no rays in your system.  During the trace, each Source and each fresh Component interaction creates new Ray objects.  Rayica stores all the Ray objects that are so generated except certain speed and memory  optimizations, detailed later.  Any given Ray intersects only one surface.  Light propagation beyond that surface is  handled by other Ray objects farther down the light path.  Fresh Rays are created as required.  Later you will learn more about how rays  interact with systems.

Go to list of topics

Ray Properties and Queries

The one action you might perform frequently with Ray objects is to query them for information.  The Rayica function ReadRays performs such queries.  You don't need to isolate rays out of your  system.  ReadRays automatically finds them in your system according to given criteria.  Any  of the following ray parameters can be obtained with this function.

BeamGeometry BirthPoint
ComponentIncrement ComponentNumber
ConfinedNumber ConfinedPosition
DiffractionMismatch DiffractionOrderNumber
GenerationNumber Intensity
InternalDirectionChange IntersectionNumber
IntrinsicMedium NewAuthorizedOptions
OffAxis OpticalLength
OpticalMedium Polarization
RayEnd RayLabelPositions
RayLabels RayLength
RayLineRGB RayLineStyle
RayLineThickness RayPointRGB
RayPointSize RayPointStyle
RaySourceNumber RayStart
RayTilt RefractiveIndex
RotationMatrix SourceID
SourceTransformation SurfaceBoundary
SurfaceCoordinates SurfaceID
SurfaceIncrement SurfaceNormalMatrix
SurfaceNumber Temperature
Tension UnconfinedIncrement
UnconfinedPath UnconfinedPosition
WaveFrontID WaveLength

Information you can obtain from ReadRays.

The most important ray attributes are WaveLength, Intensity, Polarization, OpticalLength, RayStart, RayEnd, SurfaceCoordinates, ComponentNumber, and SurfaceNumber.

Each ray is a vector.  RayStart and RayEnd define the two ends of the ray.  RayEnd is an intersection point in global coordinates.  ComponentNumber identifies the component involved in the intersection.  There  are two ways to express this intersection point.  One way is in global system  coordinates; that is RayEnd.  Another way is in parametric form, along the surface of  intersection; SurfaceCoordinates gives this form.  The type of parameters depends on the particular  component because different surfaces parametrize differently.  SurfaceCoordinates and RayEnd, then, represent the same point in space; SurfaceCoordinates does so locally and RayEnd globally.

The attribute SurfaceNumber identifies the particular surface within the component where the  intersection occurs.  Components typically have two surfaces, but more are  possible.

OpticalLength and Intensity give information about how your system affects light.  Intensity is a normalized value, which by default varies from zero to one hundred.   A Ray essentially disappears when its Intensity drops below a threshold value.  When this happens, the ray no longer  propagates.  This mechanism is exactly how Boundary and ApertureStop work;  they set the Intensity of a ray to zero.  Rayica's ray-tracing engine then discontinues propagation of the ray.

Other components modify intensity in other ways.  Rayica incorporates standard mathematical models for  energy loss through  various components.  Beam splitters, diffraction gratings, and polarizers all  modify Intensity.  Standard lenses also modify Intensity, provided that their FresnelReflections attribute is set to True.  For instance, typical refractive elements suffer energy loss from  first-surface reflections.  Anti-reflective (AR) coatings are used to  mitigate such losses.

In the same way, Rayica keeps track of Polarization changes to the ray as it propagates.  The Polarization data includes the horizontal and vertical polarization values together  with the phase angle difference (given in degrees).  Elliptical polarization  is the most general kind, encompassing both linear and circular  polarization.

The WaveLength property stipulates the wave length of the light in microns.  Rayica has a built-in default wavelength, but in most cases you will want to  override this default.  Usually you will apply WaveLength as an option to your light sources.  Rayica can propagate multiple wavelengths through the same optical system.  Such  capability could be used in chromatic studies.

Go to list of topics

Using Rays to Understand Your System

Often you will want to distinguish between sets of rays.  You will use one  set of rays to track one aspect of your system, and another set of rays to  track something else.  Both sets will propagate through the same system, but  with different purposes in mind.  Typically in these cases you will emit the  rays from separate Source objects.

The SourceID and RayLineRGB properties are useful in this regard.  After the rays have propagated, these properties can discriminate  among them.  SourceID provides an identification number of the ray's originating Source.  Meanwhile, RayLineRGB determines the rendering color for the ray.  RayLineRGB can be used as an option to any standard light source, as can any other  Ray option.  Rayica's graphics utilize RayLineRGB to determine the rendering colors for the rays in your system.  This  color may or may not correlate with the actual WaveLength of the rays.

You can, for example, distinguish between principal rays and all other  rays in your Rayica system.  One source emits the principal rays, while a coincident source  emits the rest.  The following example shows two sources impinging on two  screens through a lens pair.  We assign a handful of principal rays a  different color than the rest.  One of the sources is on-axis, the other is  off-axis.  Technically there are six Rayica Source objects, but they are arranged in coincident triplets, so we can speak of  two sources.  Each triplet source emits both principal and ordinary rays.

[Graphics:HTMLFiles/index_48.gif]

A system demonstrating spot diagrams and principal rays (for source code see Appendix 1).  This system includes four components and six light sources.  The two lenses are optically active while the two screens are optically inert.

The two Screen components in this system generate spot diagrams (below) without  disturbing the system optics.  One of the screens is closer to system focus  than the other.  This fact is evident from the tighter distribution of ray  intercepts.  Furthermore, observe that the off-axis source, imaged on the  left of each screen, breaks the symmetry of the principal ray pattern.  This  pattern is a simple cruciform.  The pattern is unbroken by the on-axis source  (right).

[Graphics:HTMLFiles/index_49.gif]

[Graphics:HTMLFiles/index_50.gif]

Spot diagrams from the two screens.  The top screen is closer to the focal plane of the system because the overall distribution of ray intercepts is tighter.  The off-axis position of the source imaged at left skews its cruciform principal ray pattern.

Visual feedback is well worthwhile, but sometimes you need exact  numerical information.  That is the purpose of ReadRays.  For the system above, we can extract the intercepts of the  four outer principal rays associated with one source.

ReadRays[twopointsystem, SurfaceCoordinates, ComponentNumber4, SourceID5]

RowBox[{{, RowBox[{RowBox[{{, RowBox[{4.47786, ,, 0.}], }}], ,, RowBox[{{, RowBox[{6.5, ,, Row ... , ,, RowBox[{{, RowBox[{8.52214, ,, 0.}], }}], ,, RowBox[{{, RowBox[{6.5, ,, 2.02214}], }}]}], }}]

The return value from this query to ReadRays is a list of two-dimensional coordinates.  (Each of these coordinate  pairs is also a Mathematica list;  lists can be nested.  This return value includes only rays that  match the given query criteria.  The query specifies ComponentNumber to identify the Screen component that you want, and SourceID to further isolate the rays of interest on that screen.  Only rays  emanating from SourceID 5 that intercepted ComponentNumber 4 were returned.  This example demonstrates how to confine your query  using ray properties.  You may employ any property of Ray as a query criterion for ReadRays.

Go to list of topics

Finding the Focus

Often you need to find the focal plane of a system.  Rayica features two functions for this purpose, FindFocus and FindFocusFast.  These functions work with ray-intercept data to estimate the focus  automatically.  The faster version uses the same internal algorithm but omits  the plotting of the focal plane spot diagram.  The rough idea is to find the  plane of intersection exhibiting the smallest spot diagram in a geometric  sense, although different measures for spot size can be specified.

FindFocus[objectset, options] and FindFocusFast[objectset, options]  determines the minimum spot size for a locus of rays at the last reported surface in the system. The focus search is started at the last reported surface.

Here we use FindFocus for a simple lens system.

In[5]:=

simpleLensSystem =
    {LineOfRays[30, NumberOfRays -> 8],
    Move[PlanoConvexLens[100,50,10],50],
    Move[Screen[50],100]};

In[6]:=

FindFocus[simpleLensSystem]

[Graphics:HTMLFiles/index_53.gif]

Out[6]=

RowBox[{{, RowBox[{RowBox[{Screen, , TagBox[RowBox[{Move, [, RowBox[{RowBox[{Screen, [ ... Box[{{, RowBox[{1., ,, 0, ,, 0}], }}]}], ,, TurboRays-ray intercepts of 1 surfaces-}], }}]

In fact, there can be several different measures for the spot size of a lens focus. The type of measure is dictated by the FocusType option.

FocusType is an option of  FindFocus and FindFocusFast that specifies what is considered to be the focus.

The default FocusType setting for FindFocus is FocusType -> FocusDiameter. Here is a list of the different settings for FocusType.

FocusDiameter is a setting of FocusType that specifies that the focus diameter is to be minimized. It is slower and more accurate than FocusRadius.
FocusRadius is setting of FocusType that specifies that the focus radius is to be minimized. It is faster and less accurate than FocusDiameter.
RMSFocus is a setting of FocusType that specifies that the second momentum is to be minimized.

The default FocusType setting for FindFocusFast is RMSFocus. Here is the same optical system measured with FindFocusFast.

In[13]:=

FindFocusFast[simpleLensSystem]

Out[13]=

RowBox[{{, RowBox[{RowBox[{FocalPoint, , RowBox[{{, RowBox[{151.474, ,, 0, ,, 0}], }}] ... neTilt, , RowBox[{{, RowBox[{1., ,, 0, ,, 0}], }}]}], ,, TurboRaysTurboRays}], }}]

Note that in this case, the calculated FocalPoint and SpotSize parameters are slightly different from FindFocus. This was because of the FocusType -> RMSFocus setting. If you use FocusType -> RMSFocus instead then you will get the same result with both functions.

Go to list of topics

1.3.6 The Ray Tracing Process

Ray tracing proceeds through three steps.  First, Rayica generates Ray objects from the Source objects in your system.  Next, Rayica propagates them through the Component objects.  Finally, Rayica generates the graphical output.  Once the system is traced, you  can perform further operations to investigate the results.  This is the basic  outline of ray tracing in Rayica.

Go to list of topics

AnalyzeSystem Function

Ray tracing takes the form of a Mathematica function call.  You commence the tracing of your system by  calling AnalyzeSystem.  This function invokes the ray tracing engine and yields  graphical output.  Once your system is traced, you can obtain detailed  numerical information via ReadRays.

Like any other Mathematica function call, AnalyzeSystem returns a value.  This return value is an OpticalSystem object.  The OpticalSystem object contains all information about your ray trace.  It  represents Rayica's internal format for the system, including the rays.  The OpticalSystem is not shown on the screen.  Instead, AnalyzeSystem produces graphics and echoes your system input to the screen.   This information is more intelligible than a view of the raw OpticalSystem object.  However, you should always assign the OpticalSystem to a Mathematica variable.  Then you can investigate the results of the trace by  means of further Rayica function calls taking the system variable as an input  parameter.

In[27]:=

myComponent = PlanoConvexLens[50, 25, 5] ; RowBox[{RowBox[{mySource,  , =,  , RowBox[{Move, [, ...  myComponent, myWall} ; myOpticalSystem = AnalyzeSystem[mySystemList, PlotType  SideView]

[Graphics:HTMLFiles/index_57.gif]

TagBox[RowBox[{AnalyzeSystem, [, RowBox[{RowBox[{{, RowBox[{RowBox[{Move, [, RowBox[{ConeOfRay ... , ,, Boundary[{-50, -50, -50}, {50, 50, 50}]}], }}], ,, PlotTypeSideView}], ]}], HoldForm]

Out[31]=

-120 ray/surface intersections-

If you want to see graphics but not the textual output from AnalyzeSystem use a semicolon to terminate its invocation.  The assignment to myOpticalSystem will still work.

Go to list of topics

Sequential and Nonsequential Ray Tracing

Rayica handles both sequential and nonsequential ray tracing.  Roughly speaking,  nonsequential ray traces involve rays that hit the same surface multiple  times, or rays that could hit multiple surfaces from a given point of  departure.  The nature and geometric arrangement of the components in your  system will dictate the nature of the trace.  Later you will learn about  functions that invoke nonsequential ray tracing whenever they appear in an Rayica system.

Go to list of topics


Created by Mathematica  (November 19, 2004)