The purpose of this tutorial is to examine several advanced uses of TurboTrace by way of example.

system = {GaussianBeam[20,.01,NumberOfRays->51],
    Move[PlanoConvexLens[100,50,10],25],
    Move[Window[50,10],130]}

RowBox[{{, RowBox[{TagBox[StyleBox[TagBox[RowBox[{GaussianBeam, [, RowBox[{20, ,, 0.01, ,, Num ... [50, 10], ,, 130.}], ]}], HoldForm], FontColor -> RGBColor[0., 0.392187, 0.]], DisplayForm]}], }}]

tracedsystem = TurboPlot[system, PlotType->TopView]

[Graphics:HTMLFiles/index_2.gif]

-traced system-

ColorView

ColorView can be used to give a pesudocolor ray map of a selected ray-parameter.

?ColorView

ColorView -> rayparameterlabel is an option of DrawSystem/AnalyzeSystem and ShowSystem that ... resenting the red, green, and blue colors used. See also: ModelRayColor, AllColors, and RayChoice.

TurboPlot[tracedsystem,PlotType->TopView,ColorView->Intensity];

[Graphics:HTMLFiles/index_5.gif]

PlotRange

You can use the PlotRange option to "zoom-in" on a particular ray-traced feature of an optical system.

?PlotRange

PlotRange is an option for graphics functions that specifies what points to include in a plot. More…

When PlotType->TopView is used, the resulting plot is two-dimensional and the PlotRange settings must also be given as two-dimensional quantities.

TurboPlot[tracedsystem,PlotType->TopView,PlotRange->{{127,134},{-3.5,3.5}}]

[Graphics:HTMLFiles/index_7.gif]

-traced system-

Note that you also can combine PlotRange with ColorView results.

TurboPlot[tracedsystem,PlotType->TopView,PlotRange->{{127,134},{-3.5,3.5}},ColorView->Intensity]

[Graphics:HTMLFiles/index_9.gif]

-traced system-

When no PlotType is specified, the resulting plot is three-dimensional and the PlotRange settings must also be given as three-dimensional quantities.

TurboPlot[tracedsystem,PlotRange->{{127,134},{-3.5,3.5},{-1,1}}]

[Graphics:HTMLFiles/index_11.gif]

-traced system-

ReportedParameters

ReportedParameters can be used as an alternative to ReadRays to directly extract numeric results by TurboTrace.

?ReportedParameters

ReportedParameters -> rayoptionnames is an option of TurboTrace for OutputType -> RayTra ... owSystem graphics. See also: ReportedFunction, OutputType, RayTraceFunction, and ReportedSurfaces.

TurboTrace[system,ReportedParameters->{ComponentNumber,SurfaceNumber}]

RowBox[{{, RowBox[{RowBox[{{, RowBox[{RowBox[{{, RowBox[{2., ,, 1.}], }}], ,, RowBox[{{, RowBo ...  }}], ,, RowBox[{{, RowBox[{2., ,, 2.}], }}], ,, RowBox[{{, RowBox[{2., ,, 2.}], }}]}], }}]}], }}]

As an alternative to specifying ReportedParameters as an option, TurboTrace also allows you to include parameters as a follow-on argument after the optical system argument.

TurboTrace[system,{ComponentNumber,SurfaceNumber}]

RowBox[{{, RowBox[{RowBox[{{, RowBox[{RowBox[{{, RowBox[{2., ,, 1.}], }}], ,, RowBox[{{, RowBo ...  }}], ,, RowBox[{{, RowBox[{2., ,, 2.}], }}], ,, RowBox[{{, RowBox[{2., ,, 2.}], }}]}], }}]}], }}]

ReportedSurfaces

In TurboTrace, the surface results for final component present in the system is automatically reported. In the previous example, the final component has two optical surfaces. Consequently, the trace information from both surfaces are reported. In some cases, however, you may wish to obtain information from a single surface or a selected set of surfaces in the system. In such instances, you can use ReportedSurfaces.

?ReportedSurfaces

ReportedSurfaces->numbers is an option of TurboTrace and PropagateSystem that indicates whi ... es are reported. See also: ReportedFunction, OutputType, RayTraceFunction, and ReportedParameters.

Here we use ReportedSurfaces->{{2,1}} to isolate specific information for the first surface (SurfaceNumber->1) of the second component (ComponentNumber->2)

TurboTrace[system,{ComponentNumber,SurfaceNumber},ReportedSurfaces->{{2,1}}]

RowBox[{{, RowBox[{RowBox[{{, RowBox[{2., ,, 1.}], }}], ,, RowBox[{{, RowBox[{2., ,, 1.}], }}] ... , 1.}], }}], ,, RowBox[{{, RowBox[{2., ,, 1.}], }}], ,, RowBox[{{, RowBox[{2., ,, 1.}], }}]}], }}]

OutputType

?OutputType

OutputType is an option of many Rayica functions that is used to indicate the final output for ... ce returns a TurboSurfaces object (without compiling a RayTraceFunction).\n\nSee also: TurboTrace.

system = {GaussianBeam[20,.01,NumberOfRays->51],
    Move[PlanoConvexLens[100,50,10],25],
    Move[Screen[50],{x,130}]}
AnalyzeSystem[system,PlotType->TopView];

RowBox[{{, RowBox[{TagBox[StyleBox[TagBox[RowBox[{GaussianBeam, [, RowBox[{20, ,, 0.01, ,, Num ... x, ,, 130.}], }}]}], ]}], HoldForm], FontColor -> RGBColor[0., 0.392187, 0.]], DisplayForm]}], }}]

[Graphics:HTMLFiles/index_20.gif]

The OutputType option is used by TurboTrace to determine the format of the final result. OutputType -> Numeric is used to directly get a numeric result from the trace. In the previous examples, when the ReportedParameters option is given, OutputType -> Numeric was automatically used by TurboTrace.

TurboTrace[system, OpticalLength, OutputType->Numeric]

RowBox[{{, RowBox[{135.417, ,, 135.389, ,, 135.364, ,, 135.343, ,, 135.325, ,, 135.309, ,, 135 ... 135.283, ,, 135.295, ,, 135.309, ,, 135.325, ,, 135.343, ,, 135.364, ,, 135.389, ,, 135.417}], }}]

When iterative trace calculations are required, it is more efficient to work use RayTraceFunction ray-trace code directly rather than generating a list of numbers from TurboTrace each time. For this OutputType -> RayTraceFunction is used instead.

turboresult = TurboTrace[system,OpticalLength, OutputType->RayTraceFunction]

RowBox[{{, RowBox[{RayTraceFunctionRayTraceFunction[{x}, -raytrace code: 716016 Bytes- ... rue, ,, EmbedGenerationLimitTrue, ,, RowBox[{RayTracePrecision, , 15.9546}]}], }}]

tracefunction = RayTraceFunction/.turboresult

RayTraceFunction[{x}, -raytrace code: 716016 Bytes- ]

Here we have stored the RayTraceFunction in the tracefunction variable. To obtain a trace-trace result, we can now evaulate this function with a value for the input x argument:

tracefunction[130.]

RowBox[{{, RowBox[{135.417, ,, 135.389, ,, 135.364, ,, 135.343, ,, 135.325, ,, 135.309, ,, 135 ... 135.283, ,, 135.295, ,, 135.309, ,, 135.325, ,, 135.343, ,, 135.364, ,, 135.389, ,, 135.417}], }}]

EmbedRays

You can use the EmbedRays option to control whether the ray source information is built into the compiled ray-trace function or left as an input argument to the function.

?EmbedRays

EmbedRays -> True is an option of TurboTrace that fixes the geometric ray source informatio ... nputrays, RayTraceFunction, EmbedThresholdIntensity, EmbedGenerationLimit, and ReportedParameters.

When different ray sources need to be separately traced through the same optical system, you can use the EmbedRays->False with TurboTrace together with OutputType->RayTrace Function.

turboresult = TurboTrace[system,OpticalLength, OutputType->RayTraceFunction, EmbedRays->False]

RowBox[{{, RowBox[{RayTraceFunctionRayTraceFunction[{$inputrays, x}, -raytrace code: 6 ... rue, ,, EmbedGenerationLimitTrue, ,, RowBox[{RayTracePrecision, , 15.9546}]}], }}]

tracefunction = RayTraceFunction/.turboresult

RayTraceFunction[{$inputrays, x}, -raytrace code: 681092 Bytes- ]

Now we can separately trace with LineOfRays and GaussianBeam light sources.

tracefunction[LineOfRays[40],130.]

RowBox[{{, RowBox[{135.417, ,, 135.227, ,, 135.417}], }}]

tracefunction[GaussianBeam[20,.01,NumberOfRays->51],130.]

RowBox[{{, RowBox[{135.368, ,, 135.344, ,, 135.323, ,, 135.305, ,, 135.29, ,, 135.277, ,, 135. ...  135.257, ,, 135.266, ,, 135.277, ,, 135.29, ,, 135.305, ,, 135.323, ,, 135.344, ,, 135.368}], }}]

ReportedFunction

ReportedFunction is used to make a user-defined calculation of the ray-trace results given from ReportedParameters.

?ReportedFunction

ReportedFunction -> Function[list of reported parameters] is an option of TurboTrace for Ou ... Parameters, RemoveSurfaceBreaks, OutputType, RayTraceFunction, ReportedRays, and ReportedSurfaces.

In the following example, we use ReportedFunction to selectively filter out ray internsities that are less than 50.

TurboTrace[system, ReportedParameters -> {OpticalLength,Intensity}, OutputType->Numeric, ReportedFunction->Function[Select[#,(#[[2]]>50)&]]]

RowBox[{{, RowBox[{RowBox[{{, RowBox[{135.235, ,, 53.4083}], }}], ,, RowBox[{{, RowBox[{135.23 ... Box[{{, RowBox[{135.233, ,, 58.228}], }}], ,, RowBox[{{, RowBox[{135.235, ,, 53.4083}], }}]}], }}]

As a different example, we use ReportedFunction to determine the average optical path length value.

TurboTrace[system, ReportedParameters -> OpticalLength, OutputType->Numeric, ReportedFunction->Function[Apply[Plus,#]/Length[#]]]

135.254

Otherwise, we can use OutputType->RayTraceFunction to be able to iteratively change the value of x.

tracefunction = RayTraceFunction/.TurboTrace[system, ReportedParameters -> OpticalLength, OutputType->RayTraceFunction, ReportedFunction->Function[Apply[Plus,#]/Length[#]]]

RayTraceFunction[{x}, -raytrace code: 718560 Bytes- ]

tracefunction[130.]

135.254

Now we can plot the average optical length as a function of x.

Plot[tracefunction[x],{x,125,135}];

[Graphics:HTMLFiles/index_35.gif]

Reporting vector quantities

Sometimes, you may wish to work with ray-trace parameters that contains vector quantities. If a single parameter is present, then its quantity will be reported in the usual way.

TurboTrace[system,RayTilt,OutputType->Numeric]

RowBox[{{, RowBox[{RowBox[{{, RowBox[{0.978182, ,, 0.207748, ,, 0.}], }}], ,, RowBox[{{, RowBo ... 512}], ,, 0.}], }}], ,, RowBox[{{, RowBox[{0.978182, ,, RowBox[{-, 0.207748}], ,, 0.}], }}]}], }}]

However, if more than one parameter is to be reported then the calculation returns a flattened list of parameter results.

TurboTrace[system,{RayTilt,Intensity,ComponentNumber,SurfaceNumber},OutputType->Numeric]

RowBox[{{, RowBox[{RowBox[{{, RowBox[{0.978182, ,, 0.207748, ,, 0., ,, 13.5337, ,, 2., ,, 1.}] ... wBox[{{, RowBox[{0.978182, ,, RowBox[{-, 0.207748}], ,, 0., ,, 13.5337, ,, 2., ,, 1.}], }}]}], }}]

When ReportedFunction is used in such instances, it is important to the flattened listing into account. In the following example, the Intensity parameter appears in the 4th position of the reported parameter result.

TurboTrace[system,OutputType->Numeric,ReportedParameters->{RayTilt,Intensity},ReportedFunction->Function[Select[#,#[[4]]>50&]], ReportedSurfaces->{{2,1}}]

RowBox[{{, RowBox[{RowBox[{{, RowBox[{0.993725, ,, 0.111854, ,, 0., ,, 53.4083}], }}], ,, RowB ... }], }}], ,, RowBox[{{, RowBox[{0.993725, ,, RowBox[{-, 0.111854}], ,, 0., ,, 53.4083}], }}]}], }}]

In this case, the ReportedFunction must address the Intensity parameter as #[[4]] rather than #[[2]].

ConstructMeritFunction

You can use ConstructMeritFunction to produce a RayTraceFunction that directly the caculates the ray-trace spot size.

?ConstructMeritFunction

ConstructMeritFunction[opticalsystem, options] constructs a RayTraceFunction that calculates t ...  is used by OptimizeSystem. See also: OptimizeSystem, MeritType, TurboTrace, and RayTraceFunction.

?MeritType

MeritType is an option of ConstructMeritFunction that indicates the performance criteria to be ... s. \n\nSee also: ConstructMeritFunction, OptimizeSystem, ReportedParameters, and ReportedFunction.

ConstructMeritFunction provides a short-hand way of specifies a suitable ReportedParameters and ReportedFunction for merit-related calculations. We will now consider two separate examples to use ConstructMeritFunction.

SphericalMirror example

sys = {Move[WedgeOfRays[4,NumberOfRays->11],{0,{y,0}}],Move[SphericalMirror[-500,50],500],Screen[50]};

AnalyzeSystem[sys,PlotType->TopView];

[Graphics:HTMLFiles/index_41.gif]

merit = ConstructMeritFunction[sys,MeritType->RMSFocus]

RowBox[{{, RowBox[{RayTraceFunctionRayTraceFunction[{y}, -raytrace code: 415412 Bytes- ... 2314;1〛 - TV1)^2 + (#1〚2〛 - TV2)^2) &)/@#1 ; TV4/TV3^(1/2)) &)}], }}]

tracefunction = RayTraceFunction/.merit

RayTraceFunction[{y}, -raytrace code: 415412 Bytes- ]

Plot[tracefunction[y],{y,0,6}];

[Graphics:HTMLFiles/index_44.gif]

ParabolicMirror example

sys = {Move[WedgeOfRays[4,NumberOfRays->11],{0,{y,0}}],Move[ParabolicMirror[250,50],250],Move[ParabolicMirror[250,50],100,180],Move[Screen[50],350]};

AnalyzeSystem[sys,PlotType->TopView];

[Graphics:HTMLFiles/index_45.gif]

Options[ConstructMeritFunction]

{MeritTypeRMSFocus, EmbedRaysTrue, ReportedSurfacesLast, SequentialTraceAutomatic, ReportedParametersAutomatic, ReportedFunctionAutomatic}

merit = ConstructMeritFunction[sys,MeritType->RMSFocus]

RowBox[{{, RowBox[{RayTraceFunctionRayTraceFunction[{y}, -raytrace code: 621052 Bytes- ... 2314;1〛 - TV1)^2 + (#1〚2〛 - TV2)^2) &)/@#1 ; TV4/TV3^(1/2)) &)}], }}]

tracefunction = RayTraceFunction/.merit

RayTraceFunction[{y}, -raytrace code: 621052 Bytes- ]

Plot[tracefunction[y],{y,0,6}];

[Graphics:HTMLFiles/index_49.gif]

Saving your results

Sometimes it is helpful to be able to save your intermediate results to a file on the hard disk. This allows you to recover your ray-trace data analysis in a future work session without having to re-calculate it. You can do this with the Put and Get commands.

?Put

expr >> filename writes expr to a file. Put[expr1, expr2, ... , \"filename\"] writes a sequence of expressions expri to a file. More…

?Get

<<name reads in a file, evaluating each expression in it, and returning the last one. More…

As an example, we will take the results from TurboPlot below and store it on a disk.

results = TurboPlot[{LineOfRays[45],Move[PlanoConvexLens[{f,100},50,10],50],Boundary[170]},PlotType->TopView]

[Graphics:HTMLFiles/index_52.gif]

-traced system-

Before storing the file, we will use SetDirectory to set the current working directory of the system.

?SetDirectory

SetDirectory[\"dir\"] sets the current working directory. More…

$HomeDirectory

/Users/donaldbarnhart

SetDirectory[$HomeDirectory]

/Users/donaldbarnhart

Next we use Put to write a file on the disk with our results.

Put[results,"lenssystem"]

Finally, we can use Get to recover the results calculation from the disk.

newresults = Get["lenssystem"]

-traced system-

We are now able to start working once again with our previous results.

TurboPlot[newresults,PlotType->TopView,SymbolicValues->{f->75}];

[Graphics:HTMLFiles/index_58.gif]


Created by Mathematica  (July 29, 2005)