CODEV Ch4

Download as pdf or txt
Download as pdf or txt
You are on page 1of 34

Menu

Search

Chapter 3
Make It Better: Optimization

In this chapter, you will learn how to optimize the digital camera lens that you set up
in the last chapter. This will include setting up variables, determining and defining
constraints, and analyzing the results of the optimization. Some advanced
optimization features will also be discussed, including Global Synthesis.

Contents

About Optimization ....................................................................................................44


The Game Plan ...........................................................................................................46
Variables .....................................................................................................................48
Automatic Design Settings .........................................................................................52
Understanding AUTO Output.....................................................................................60
Analyzing Results and Modifying Weights ................................................................66
Final Optimization and Notes.....................................................................................69
Plastics, Private Catalog, and Aspheres......................................................................72
Global Synthesis and Other AUTO Features..............................................................73
Constraints: Problems and Solutions ..........................................................................74

CODE V Introductory User’s Guide 43


Chapter 3 Make It Better: Optimization
Menu

About Optimization
Search
Purpose
The purpose of optimization is to generate the best possible optical system that can
be achieved within a given set of physical and other constraints. The term “best” is
measured by an error function which combines image error data into a single
number that we then attempt to make as small as possible. CODE V’s error function
is pre-defined in its basic structure, although a variety of controls and weights are
available that allow you to modify it easily and extensively. It is even possible to
replace this error function with a completely user-defined error function, although
this is somewhat more difficult and is seldom actually necessary.

Methods
CODE V’s optimization feature is called Automatic Design, AUTO for short.
AUTO uses an accelerated damped least squares (DLS) algorithm to generate
changes in variables that improve the system. Constraints place boundaries on the
search for optimum solutions. AUTO uses Lagrangian multipliers to impose
constraints only when needed. This allows exact constraint control while not
requiring constraints to be included in the error function itself, usually resulting in
faster, smoother convergence to an optimum solution within the constrained
solution region.

Defaults
The default values built into AUTO allow you to use AUTO with little or no
attention to the details of error function construction and with minimal input
requests. At the same time, the many optional controls, weights, constraints, etc.,
allow you great flexibility when needed for unusual designs or fine tuning in later
design stages.

The AUTO process


Though you can achieve results from AUTO by treating it as a black box, you may
be interested in the outlines of the internal procedures. The diagram below shows
the general flow of the design process, including the parts that AUTO handles. The
meaning of the various steps will become clearer as we set up and run an example
problem.

44 CODE V Introductory User’s Guide


Chapter 3 Make It Better: Optimization
Menu

Chapter 18 of the CODE V Reference Manual describes the Automatic Design


option in detail; the section titled “The Automatic Design Process” on page 18-4 is
Search especially valuable for understanding how AUTO works.

Automatic Design Process

Define Lens
Designer Tasks

Define Variables

Define Constraints

Define Error Function


Modify Definitions

Develop and Apply CODE V


Construct Error Function Solution Vector AUTO
(Changes in Variables to Tasks
Reduce Error Function)

Develop Finite Differences


Evaluate Error Function for Each Constraint and
Aberration

Evaluate Design
• Print each cycle for user feedback
• Exit if time/cycle limit exceeded ,
if improvement has stalled,
or if user requests exit
No
Good Enough?

Yes

Stop

CODE V Introductory User’s Guide 45


Chapter 3 Make It Better: Optimization
Menu

Local vs. Global


If you think of the error function as a space of multi-dimensional hills and valleys,
Search
the goal is to find the lowest possible valley. In local optimization, you will find the
valley nearest your starting point. Global optimization will locate valleys farther
from the starting point in its search for the deepest valley, or global optimum.
CODE V’s Global Synthesis® (GS) is an extremely good global optimizer that can
find multiple solutions from virtually any starting point.

Parallel Processing Support


CODE V provides parallel processing support for both local and global (GS)
optimization. Parallel processing uses two or more processors on a multicore PC to
perform lens design optimization in a fraction of the time needed using a single
processor, particularly for complex lens systems or systems tracing many rays.
Parallel processing is supported for the following types of optimization
computations:
• Transverse aberration error function
• Wavefront error variance error function
You do not need to modify your lens system before using the parallel processing
capability. CODE V automatically detects the number of available processors in
your PC and uses them to perform parallel-processing-enabled optimization
computations.
For complete details about CODE V’s parallel processing support, see “Parallel
Processing Support for Local and Global Optimization” on page 1-111 of the
CODE V Reference Manual.

The Game Plan


It may seem that there are a lot of steps in this chapter, but there are really just a
few, plus a lot of explanatory text. To help you see the forest as well as the trees,
here is an outline of the game plan for optimizing this lens. These steps will all be
done in the Automatic Design option dialog box (Optimization menu), except for
defining variables, which is done in the LDM, and the analysis checks, which will
be done in the MTF and FIELD options:
• Define as variables all radii of curvatures, thickness values, and fictitious
glasses, then save this revised starting point.
• Make sure all glass elements are thick enough (General Constraints tab).
• Make sure the glass index doesn’t get too high (General Constraints tab).

46 CODE V Introductory User’s Guide


Chapter 3 Make It Better: Optimization
Menu

• Constrain the effective focal length (EFL) to the current 6 mm value (Specific
Constraints tab).
Search
• Draw the lens on each optimization cycle (Output Controls tab).
• Use the default spot size (transverse ray aberration) error function, but trace
more rays in the grid (Error Function Definitions and Controls tab).
• Analyze the lens by re-running earlier evaluations (one click updates on
windows from the last chapter, mainly the VIEW, MTF, and FIELD options).
• Modify AUTO settings to refine the solution (Error Function Weights tab).
Now on to the details!

CODE V Introductory User’s Guide 47


Chapter 3 Make It Better: Optimization
Menu

Variables
Search
Defining Variables
You need to tell CODE V which lens parameters are free to vary when it tries to
optimize your lens. These variables are defined in the LDM and are stored with the
lens data when you save the lens in a file. Deciding what to vary is not always a
simple task, but in centered systems, it is typical to vary all glass surface curvatures
(but not the image surface curvature, since you usually want a flat film or detector
surface), all air spaces, and the thickness values of positive glass elements (to allow
the program to keep good lens edges without restricting curvatures too much).
Glass is often varied also (index and dispersion). This requires using a special
variable “fictitious glass” form in CODE V, since catalog glasses have fixed
properties and thus cannot be directly varied.

Use the LDM


Variables are defined in the LDM. By default, everything is frozen initially. To vary
a radius or thickness, place the cursor on it in the Lens Data Manager window,
right-click, and choose Vary from the shortcut menu. A small v appears next to the
parameter, indicating that it is a variable. If you vary something by mistake, right-
click on the parameter and choose Freeze from the shortcut menu to remove the v.
You can also select multiple values of one or more types and change all the selected
values to variables with a single right-click Vary.
If it is not already open, you will need to open or create the 6 mm f/3.5 digital
camera lens starting point from last chapter.
1. Choose the File > Open menu, locate the digital camera lens file you created in
the last chapter (DigCamStart.len or whatever you called it), and click OK.
If you save and later open a lens from the File menu, any analysis windows that
were open at the time of the save will be restored when the lens file is opened.
Note that this does not happen if you open the lens from the Command Window
with the RES (restore) command. In this case, the lens is restored without
changing other windows.
2. In the LDM spreadsheet window, drag to select the Y Radius of curvature
values for surfaces 1 through 6.
3. Right-click on one of the selected cells and choose Vary as shown below.

48 CODE V Introductory User’s Guide


Chapter 3 Make It Better: Optimization
Menu

Search

4. Repeat this procedure for the thickness values (select and vary thickness for
surface 1 to surface 5 as a range, then select the image surface thickness and
vary it separately; do not include surface 6, as this will remove the PIM solve
from this surface).
The LDM spreadsheet window with all variables is shown on page 51, following
the discussion of fictitious glass.

Fictitious Glass
Varying glass involves additional considerations and possible extra steps, since
both the index and dispersion properties of a glass can vary. To be used as a
variable in AUTO, a material must be defined as a fictitious glass. If a catalog glass
is selected as a variable, it is automatically converted to its equivalent fictitious
glass (in a final design, the optimized fictitious glasses need to be replaced with
their nearest real equivalents by the user, often with the help of the supplied
glassfit.seq macro). Fictitious glasses have a special form. For a glass of refractive
index (at 587.6 nm, or “d” light) of 1.620 and an Abbe value (i.e., reciprocal
dispersion), or V-value of 60.3, the fictitious glass name is 620.603 (the period tells
the program this is a fictitious glass). An alternate form, 1.620:60.3, is also
accepted by CODE V, and allows the entry of glasses with n > 2.0 and v > 100.
In the case of the digital camera lens, the patent that it is based on already includes
fictitious glasses, although they are frozen. You should also note that all three
glasses have very high index of refraction values (1.7 to 1.8), which generally
indicates an expensive glass. You will need to vary glass but constrain its index in
AUTO (this will be done in the next section).

CODE V Introductory User’s Guide 49


Chapter 3 Make It Better: Optimization
Menu

1. To vary the glass for surface 1, right click on the glass name in the LDM
window and choose Vary from the shortcut menu.
Search
The v will display next to the glass name, indicating that it is a variable. For a
polychromatic (multi-wavelength) system, we normally vary both index and
dispersion, and this is the default. But there are other possibilities for glass.
2. Left-click on the v for the glass on surface 1 (or right-click and choose Couple).
This displays the Coupling Editor dialog box. Coupling is one way to link
together variables, but in the case of variable glass, it also gives access to the
index and dispersion variables.
3. Double-click the Index and Dispersion cell for surface 1.

You can vary the index and dispersion separately or together. Since this is a
polychromatic lens, varying both Index and Dispersion is OK. Dispersion
Boundaries are the boundaries of the glass map polygon which limits the range
of allowed glass types. This will be discussed in the next section under General
Constraints.
4. Click Cancel.

50 CODE V Introductory User’s Guide


Chapter 3 Make It Better: Optimization
Menu

5. Right-click and choose Vary from the shortcut menu for the glass for surfaces 3
and 5.
Search
When you are through, the LDM window should look like this:

6. Choose the File > Save Lens menu to save a new version of the lens file with
the variable definitions.

CODE V Introductory User’s Guide 51


Chapter 3 Make It Better: Optimization
Menu

Automatic Design Settings


Search Now you are ready to launch Automatic Design and define some settings that will
guide the optimization of this lens.
• Choose the Optimization > Automatic Design menu to open the Automatic
Design (AUTO) dialog box.

Note: Do not click the OK button in the Automatic Design dialog box until you
reach the end of this section.

You will be changing settings on several tabs before you click OK to run AUTO. If
you click OK by mistake, don’t panic: choose the Edit > Undo menu to get the
starting lens back and click the Settings button in the AUTO output window to
resume.
AUTO is a very powerful feature with many categories of settings divided among
ten tabs in the input dialog box.

Most of the settings determine parameters such as weights, or flags for special
behaviors, such as drawing the lens on each optimization cycle. Two categories of
settings define boundary conditions or constraints.
The first of these boundary condition categories is called General Constraints.
These are general boundary conditions that control thickness values and glass map
boundaries to help protect you from unrealistic designs. Thickness constraints
prevent such problems as negative edge thickness, or lens elements that overlap.
Glass boundaries keep the program from choosing physically unrealistic index and
dispersion values. General constraints are always in place, applying limits for all
surfaces in all zoom positions. You can set the values for these limits, and override
selected general constraints with specific constraints on a per-surface basis.
The second boundary condition category is called Specific Constraints. Specific
constraints are applied only when entered by the user. Many constraints are surface
based, referring to a physical or optical property. Other constraints apply to the
whole system or to a range of surfaces. Specific constraints allow you to define
your requirements in great detail, though you must be careful not to over-constrain
the system, since this can limit the improvement potential.

52 CODE V Introductory User’s Guide


Chapter 3 Make It Better: Optimization
Menu

General Constraints

Search
General Thickness Constraints
For this small lens, you must be sure that the elements are thick enough to be
handled and worked easily. According to fabrication specialists, the values
suggested here are reasonable, though it's possible to go as thin as 0.5 mm for
elements of this size. This is best handled by the general thickness constraints. In
addition, we noted in the last section that the glasses in this patent are all high-index
glasses. Glass map boundary constraints can be used to limit the optimized glasses
to a lower index, lower cost region of the glass map. Assuming you have already
opened the AUTO dialog box (as described on page 52):
1. Click the General Constraints tab.
2. Enter 1.4 in the Maximum Center Thickness field.
3. Enter 0.9 in the Minimum Center Thickness field.
4. Enter 0.8 in the Minimum Edge Thickness field.

Glass Map Constraints


The glass map used in AUTO is a plot of Nd vs. (NF - NC). The picture below is an
excerpt from the map in Chapter 18, Automatic Design in CODE V of the CODE V
Reference Manual. It shows the default, four-sided glass map boundary, a region
that allows fairly high index values. Note that the Schott designations for some of
the specific glasses are indicated as labeled points, and the default glass boundaries
are constructed to enclose the region that contains the most commonly available
glass. It's important to note, however, that AUTO can only vary glass on a
continuous basis—it does not locate discrete real glasses. You must convert a
fictitious glass to a real glass after optimization in order to analyze final
performance and make fabrication possible (e.g., with the glassfit.seq macro).

CODE V Introductory User’s Guide 53


Chapter 3 Make It Better: Optimization
Menu

Search

The glass map constraint polygon can actually have 3 to 5 sides, labeled A through
E (it must be a convex polygon; see the CODE V Reference Manual for more
details). It appears that SF2 defines a convenient point for a three-sided glass region
that keeps the maximum index below 1.65 (the hope is that this will result in
cheaper glasses after optimization). Note that the glass map boundary changes will
apply to all surfaces by default, though you can define a separate glass map for each
surface if necessary.
1. On the General Constraints tab in the AUTO dialog box, click on the glass
SF4 in the cell Map4 of the Glass Map Boundary spreadsheet at the bottom of
the dialog box and press the Delete key (or CTRL-X) to remove the fourth
boundary.
2. Click in the cell Map3 and type SF2 to define the new corner point for the
triangle region.

54 CODE V Introductory User’s Guide


Chapter 3 Make It Better: Optimization
Menu

Your General Constraints tab should look like this:

Search

Specific Constraints
There are many things you can constrain when needed to define the boundary
conditions of the optimization. These include many physical and optical properties
(overall length, focal length, distortion, real ray properties, paraxial ray properties,
etc.). Constraints can be entered in several ways, including equality (hold to a
value), upper and/or lower bounds, and minimize (don't directly constrain, but
minimize difference from target value). You can also designate constraints as
display only (these are calculated and displayed on each cycle but not controlled in
any way). Constraints and constraint modes are discussed in detail in Chapter 18,
Automatic Design in CODE V of the CODE V Reference Manual.
In most lenses, at least one specific constraint is required to hold the scale of the
system. This could be a paraxial or real ray height at the image surface, a paraxial
slope, or a real-ray direction cosine value. But most often, it is the paraxial effective
focal length of the system (EFL), which you will use here.
1. In the Automatic Design dialog box, click the Specific Constraints tab.
The table starts out empty (no specific constraints are defined by default).

CODE V Introductory User’s Guide 55


Chapter 3 Make It Better: Optimization
Menu

2. Click the Insert Specific Constraint button, which is near the bottom of the
dialog box.
Search
The Edit Constraint dialog box is displayed, with Effective Focal Length as
the default constraint (since this is the most common case). You could actually
just click OK in this case, but first note that you can choose from several catego-
ries from the list at the top left, and that for each category, there is a separate list
of constraints at the top right. Effective Focal Length is the first of the Optical
Definitions.
3. Click in the Constraint Target field and enter 10.0 (note that this is the
WRONG value; however, this is just a demonstration, since 6 is the value you
want).
4. Click the Calculate Default Target button.
Note that the value of 6 is back. This button evaluates the current value of the
constraint as a convenience. You don't have to keep it, but it's correct for this
case.

5. Click Apply & Close to enter this constraint.

56 CODE V Introductory User’s Guide


Chapter 3 Make It Better: Optimization
Menu

Search Tip: When entering a constraint, be sure to click in a data field after choosing
the constraint, to allow the program to display the data required by the constraint
type. If it is a surface-based or field-based constraint, be sure to select the
desired surface or field (and zoom position if it is a zoomed system). The
Calculate Default Target button will show the current value to help you
determine a good target.

Other Specific Constraints


In many cases, other specific constraints will be necessary, but you won't usually
know this until you make a trial optimization run. It is usually best to limit the
number of specific constraints to those that are really important to the design. For
this lens, you have a distortion specification of less than 4%. You could easily add
this (it's in the Optical Definitions category in the Edit Constraint dialog box, and
is labeled Distortion Fraction Y; the command is DIY). If you did add it, you
would select the field at which you will control it (typically the last or largest field),
and you would seldom control it at more than one field. The starting point of this
lens has very low distortion, so you would probably start out without constraining it
(in the Edit Constraint dialog box, you could add it in Display Only constraint
mode to monitor it). If distortion becomes a problem, you can add it (possibly
twice, to limit plus and minus distortion).
Image clearance (“back focus”) is another common constraint, although a digital
camera requires no space for a reflex mirror or prism, as do some film cameras. In
digital cameras, the scene is viewed either through a separate viewfinder or on the
LCD preview panel. Other common constraints come from the Manufacturing and
Packaging category, such as Overall Length.
“Constraints: Problems and Solutions” on page 74 describes common problems and
their corresponding constraint approaches.

Output Controls
For lenses with many surfaces, you might wish to restrict the amount of surface-
based output that appears. You might also wish to see a table of variables. In this
case, you can accept the defaults for these things, but it will be helpful to see a
picture of the lens on each optimization cycle. You are still modifying the AUTO
settings (almost done!).
1. In the Automatic Design dialog box, click the Output Controls tab.
2. Check the box labeled Draw system at each cycle.

CODE V Introductory User’s Guide 57


Chapter 3 Make It Better: Optimization
Menu

Search

This will result in a separate tab in the AUTO output window for each cycle,
labeled with the error function.

Error Function Definitions and Controls


The Error Function Definitions and Controls tab is the one that by default
appears first in the Automatic Design dialog box. This is where you set the general
approach and some control values (e.g., error function type, Global Synthesis). You
can accept the default error function type (transverse ray aberration, essentially
RMS spot size), but for this particular lens, you should change to a different ray
grid interval value.
1. In the Automatic Design dialog box, click the Error Function Definitions and
Controls tab.
2. Enter 0.22 as the Ray interval in the Ray Grid Controls section.

58 CODE V Introductory User’s Guide


Chapter 3 Make It Better: Optimization
Menu

Save Your Settings (Option Set) and Run AUTO


The settings in the Automatic Design dialog box will persist in your CODE V
Search
session for as long as you keep the associated AUTO window open, allowing you
to modify the settings and re-run AUTO multiple times. But to use the settings in a
future CODE V session, you need to save them. This is easy enough to do and often
saves a lot of later work.
1. Click the Option Set button in the lower left corner of the Automatic Design
dialog box.
2. Click the Save As button
3. Type a name for the saved set of AUTO settings and click OK.
4. Click the Close button in the Option Sets dialog box.

5. Click OK in the Automatic Design dialog box.


This will create the AUTO tabbed output window and run AUTO with the set-
tings you entered. It will typically run for several cycles, stopping when it can
no longer make much improvement in the lens (there are settings on the Exit
Controls tab in the AUTO dialog box for determining when to stop).

CODE V Introductory User’s Guide 59


Chapter 3 Make It Better: Optimization
Menu

Understanding AUTO Output


Search When you click the OK button, AUTO starts to run, displaying a tabbed output
window (TOW) and a control dialog with a stop button. The TOW always includes
a Text tab which contains most of the output. If a per-cycle lens drawing is
requested, you will also see multiple plot tabs, one for each cycle. You may also see
an Error tab if there are any warnings or errors generated.
The control dialog shows the current cycle number and error function value. Note
that if you click the Stop toolbar button, AUTO may not stop immediately. It tries
to complete the current cycle and make sure that the lens is valid before stopping.

The Error Function


The Error Function is the single most useful piece of information produced by
AUTO as it runs. This single number represents the image quality of the lens, with
zero representing an aberration-free lens. The default error function is made up of
sums of squares of transverse ray aberrations in X and Y, scaled so that the value
approximates the square of the RMS spot radius averaged across all fields and
zoom positions. Default error functions also exist for wave front error variance,
fiber coupling efficiency, and MTF. The interpretation of the error function value is
changed in these cases, but it is always defined such that smaller is better, and zero
is ideal (but seldom achieved). A user-defined error function can also be used.
To calculate the error function, CODE V traces a grid of rays in every defined
wavelength from every defined field and zoom position. The grid is defined
assuming that the entrance pupil has a unit (normalized) radius, and the spacing
between rays is called the pupil fraction ray interval (command: DEL). There is a
macro (AUTOGRID.SEQ, found by choosing the Tools > Macro Manager menu,

60 CODE V Introductory User’s Guide


Chapter 3 Make It Better: Optimization
Menu

and is listed under Sample Macros/ Optimization) for looking at the ray pattern
for specified DEL values. For the value of DEL chosen for this optimization, 0.22,
Search the pattern is as shown in the figure below. (Note that you cannot run this or any
macro while the AUTO dialog box or any other option dialog box is open.)

The transverse ray aberrations in X and Y are calculated on the image surface for
each of these many rays, and the weighted sum of the squares of these aberrations
determines the error function at each optimization cycle. The weights in this
summation are important controls in optimization. Weights are defined for aperture
position, wavelength, and field (X and Y components). For a more detailed
treatment of the error function and other mathematical aspects of optimization, see
“Technical Notes” on page 18-41 in the CODE V Reference Manual.

CODE V Introductory User’s Guide 61


Chapter 3 Make It Better: Optimization
Menu

The AUTO Output Header


Take a look now at the text output from AUTO. The output starts with a section
Search
called the output header, which displays the inputs and defaults used in the
calculation. These are labeled primarily in terms of commands.

The header starts by displaying the commands generated by your settings (EFL,
DEL, etc.). It then lists potentially active specific constraints, in this case only EFL.
“Potentially active” means that AUTO will dynamically determine if a constraint is
needed at any given cycle, freeing as many variables as possible to control image
errors. General constraints are listed next; the commands are not too hard to
interpret (MNE is minimum edge thickness, MNT is minimum center thickness,
etc.).

62 CODE V Introductory User’s Guide


Chapter 3 Make It Better: Optimization
Menu

Search Tip: To see the commands for a category of inputs, click the tab of interest in the
Automatic Design dialog box (e.g., General Constraints) and press the F1 key.
This displays the help page that describes the inputs, including their CODE V
command names.

Error Function Construction shows you the weights on the various components,
as well as the DEL value used in the ray trace grid. Convergence Controls
displays the exit conditions (MXC is maximum cycles, MNC is minimum cycles,
TAR is error function target, and IMP is the target per-cycle fractional
improvement). Output Controls includes only the lens drawing command in this
case (DRA). This is followed by the number of variables, 18 in this case (6 radii, 6
thickness values, and 6 glass variables, the index and dispersion for each of 3
glasses).

Tip: You can get a list of the variables by clicking the Print Cycle Value button
in the Variable Table area on the Output Controls tab of the AUTO dialog box.

Finally, the header text tells you that 18 constraints can be active, thanks to the 18
variables. This is an upper limit! In fact, you hope for a small number of active
constraints so most “degrees of freedom” (i.e., variables) can be applied to
improving the image quality.

AUTO Per-Cycle Output


A cycle in AUTO is roughly one iteration for which the error function and
constraints are displayed. In fact, each cycle contains several mini-iterations, in
which different parameters are tried and constraints added or dropped as needed,
allowing maximum progress for the current configuration.

CODE V Introductory User’s Guide 63


Chapter 3 Make It Better: Optimization
Menu

Search

Note: The above output is for illustrative purposes only; your output may be
slightly different.

Starting and ending each cycle is the error function value, labeled ERR. F. This is
followed by its X and Y components from each field, allowing you to see which
fields and components are contributing most to the error function, though the total
error function value also includes weighting factors (e.g., a large X component at
field 4 may not contribute much if the WTX F4 field weight value is small). The
surface data is listed next, followed by the basic first system properties (EFL,
REDU or reduction ratio, PIM or paraxial image distance, OAL or overall length,
EN/EX PUP or entrance/exit pupil distances).
Finally there is a table of Active Constraints (10 on this particular cycle). EFL is
listed first, with its target value, current value, and difference between these. Given
that this is the only specific constraint, what are all the other constraints? They are
general constraints that AUTO has determined will require control at this particular
cycle. GL A S1 is a glass map boundary constraint (recall the glass polygon
boundaries labeled A, B, C, in this case). Mn ET S1 is a minimum edge thickness
constraint at surface 1.

64 CODE V Introductory User’s Guide


Chapter 3 Make It Better: Optimization
Menu

Constraint Costs
The program dynamically determines the constraints it needs to control at every
Search
cycle, based on their Lagrange multiplier values, which are listed in the cost
column. Why is this called a “cost?” When a boundary condition is controlled, the
program is restricted from going to a solution-space point (set of variable values)
where the error function could get lower. This restriction from the optimum point
“costs” you something in terms of the error function that can be achieved (if it
could be released, the error function could be smaller).
Some constraints are harder to control than others, and these have larger magnitude
costs. Although you can't directly compare costs for different types of constraints,
larger values hurt more than smaller values, and if you see very large values (any
positive exponent, e.g., 1E+02), this constraint is causing a big problem. You may
need to remove it, or provide another variable that can allow it to be met more
easily.
The values and signs of the Lagrange multipliers are used along with other program
data to determine which constraints to control on each cycle. The remaining
variables (18 - 10, or 8 on this cycle) are available to try to improve the image
quality.

CODE V Introductory User’s Guide 65


Chapter 3 Make It Better: Optimization
Menu

Analyzing Results and Modifying Weights


Search If you have left open the analysis windows used when you defined the digital
camera lens, it is a simple matter to update them to see the effects of optimization.
1. Locate the MTF output window from your prior analysis.
2. Drag the tab of the plot with the mouse to tear off a copy of the original MTF
plot (this is optional but this method allows easy before/after comparison).
3. Click the Execute (Recalculate) button in the MTF window to re-run the
calculation and see the new MTF results.

This plot shows that the MTF is good for most fields and azimuths (T,R for
tangential and radial, which correspond to Y and X), but a couple of the radial
(X, dashed) component curves are low. You can relate this to the AUTO output as
well. Click the Text tab of the AUTO output window and scroll to the bottom.

66 CODE V Introductory User’s Guide


Chapter 3 Make It Better: Optimization
Menu

Note that the largest error function components are the X values for F3 and F4, plus
the Y component for F3. These correspond to the lowest MTF curves. Since the
Search problem is related to particular fields and X components, you can modify the
AUTO settings to increase the weight on some of these during optimization.
1. Click the Modify Settings button of the AUTO output window.
2. Click the Error Function Weights tab in the AUTO dialog box.
The default field weights come from the LDM data, which are all 1.0 as you can
see in the Fields/Vignetting page of the System Data window (Lens > System
Data menu). You can try to increase the X component weights for field F3 and
F4, using 1.2, for example.
3. Click in the first row of the spreadsheet labeled X-Aberration weights only,
then double-click the first cell and choose field 3 (F3).
4. Enter 1.2 in the Value field for this row.
5. Click the blank row and repeat the above procedure for field 4 (F4).

6. Click OK to re-run AUTO with the new weights.

CODE V Introductory User’s Guide 67


Chapter 3 Make It Better: Optimization
Menu

7. Click the Execute button in the MTF window to re-run the analysis.

Search

Now the radial (dotted) curves are higher, but the T curve for F3 is even lower and
will require more weight. You can quickly experiment with different field weights
in X and Y, even lowering the weights for the axis (F1) and 0.4 (F2) fields, which
have higher MTF than you need. Although you could switch to MTF optimization
at this point, defining the targets for the MTF error function will probably take
longer than interactively changing weights, re-running AUTO, and re-running
MTF.
As an aside, MTF is also convenient in another way, in that it reports both relative
illumination and distortion for each field (in the Text output). This allows you to
keep an eye on these specs as you tweak the MTF.

68 CODE V Introductory User’s Guide


Chapter 3 Make It Better: Optimization
Menu

Final Optimization and Notes


Search After a few trials, you can find a set of weights (WTX and WTY) that will allow the
lens to meet the MTF and other specs. One such set of weights is shown below (this
was from the initial default-weight optimization shown in the previous section,
using Undo each time to go back to the same starting point).

You may not get exactly the same solution, depending on the weights applied and
the starting point, but your solution should have a similar performance. You should
set a new title and save the lens file (by choosing the File > Save Lens As menu)
when you get a good solution.
The following figure shows the basic Quick 2D lens drawing, MTF, and LDM
surface data of the final glass lens.

CODE V Introductory User’s Guide 69


Chapter 3 Make It Better: Optimization
Menu

Search

To get other final analysis results, click the Execute/Recalculate button on each
analysis window used in earlier analysis (or run them again if you have closed
them). For this solution, we get:
• MTF meeting the spec at 17 and close to meeting the 51 lp/mm spec at 68 lp/
mm as well, giving some performance margin.
• Distortion -1.7% at worst from Field Curves (Analysis > Diagnostics menu).
• Relative illumination 67.3% at full field (from MTF option). Transmission
Analysis (Analysis > System menu, or TRA option) is more accurate and gives
63.2% for field F4, still above the 60% spec.
• The same TRA option reports average transmission of 88.2% at full field,
although this is with the CODE V default of a single layer anti-reflection
coating (1/4 wave MgF2) on each surface, which was not specified. If all
coatings are removed (Lens > Surface Properties menu, Cement/Coating
page, click None for coating on each surface), the transmission drops to 66%.
Some coating will probably be applied, but you should always check on details
such as this in any lens specification.
Actually, there is more to be done on this lens before it could be built.

70 CODE V Introductory User’s Guide


Chapter 3 Make It Better: Optimization
Menu

What About Real Glass?


One key point is to change the fictitious glass to real glass as discussed at the end of
Search
Chapter 2. This would typically be followed by some minor re-optimization, since
the real glass will not precisely match the fictitious glass. The supplied macro
glassfit.seq is very useful, but you should not always use the “fit all glasses
automatically” option. In this lens, the automatic-fit Schott glass for the front and
rear elements (620.603) was NSK16, which was listed as an inquiry (category 2)
glass. SK16 gave just as good a solution but was listed as a preferred (readily
available and cheaper) glass. This may reflect some interim conditions with Schott,
and of course you also have other manufacturers available as well.
The point is that you can run the glassfit macro in several modes, including one
where the five closest glasses are listed for each surface. This allows you to choose
a glass based on other properties in addition to a good match in index and
dispersion.

What About Depth of Focus?


One spec we did not cover is depth of field for this fixed-focus lens. It should have
the specified MTF for object distances from 750 mm (2.5 feet) to infinity, but we
have only designed and analyzed at infinity. To evaluate this:
1. In the LDM spreadsheet window, right-click on the thickness of surface 6 (the
cell containing this data is shaded gray) and choose Delete Solve from the
shortcut menu.
This removes the PIM solve so the lens will not be re-focused when the object
distance is changed.
2. Change the object thickness from infinity to 750 mm.
3. Re-run MTF and any other desired analysis.
You can see that the spec is not met at the close focus distance with this solution.
There are several ways to deal with this, using through-focus parameters in AUTO,
or by using Zoom to optimize the close and far distances simultaneously. We
won’t do this here, but note that with the extra margin of MTF at the high
frequencies (51-68 lp/mm), a compromise focus solution is feasible.

CODE V Introductory User’s Guide 71


Chapter 3 Make It Better: Optimization
Menu

Plastics, Private Catalog, and Aspheres


Search Would a low-cost digital camera lens really be built from an all-glass triplet? This
depends on a lot of factors, but plastic or a glass/plastic hybrid solution is certainly
worth considering. Plastic lenses are molded, and a mold can include aspheres just
as easily as spheres. Plastic is cheap, and molding offers cheap large volume
fabrication with many options. But plastics do have several problems:
• There are fewer optical plastics than there are optical glasses, with a smaller
range of index and dispersion values, and their properties are not as
standardized.
• Plastic molding may require looser fabrication tolerances than glass.
• Most optical plastics are more sensitive to temperature changes than are optical
glasses.
Plastics are not supplied in standard catalogs like Schott, Ohara, Hoya, and other
glasses. They must be defined with the lens using the Private Catalog feature (PRV
command) before they can be used in a lens definition. ORA supplies a macro that
defines many common optical plastics, based on various sources.
1. Choose the Tools > Macro Manager menu and locate the macro plasticprv.seq
under Sample Macros / Materials Information. Click the Run button. When
the macro dialog box displays, click OK to run the macro.
This will define the various materials with names such as 'P-CARBO' (polycar-
bonate) and 'P-STYRO' (polystyrene).
2. To use a PRV material, type its name in quotes in the Glass field in the LDM
spreadsheet.
The quotes can be single or double but are required and case is considered (i.e.,
the material 'P-CARBO' is not the same as 'p-carbo').
3. To review the names and types of PRV materials, choose the Review > Private
Catalog menu.
You cannot view or modify the properties here, you can only see what is defined
and delete unneeded materials.
4. To view the properties of defined PRV materials, choose the Display > List
Lens Data > Private Catalog menu.
For more information on the Private Catalog feature, see Chapter 7 in the CODE V
Reference Manual.

72 CODE V Introductory User’s Guide


Chapter 3 Make It Better: Optimization
Menu

Global Synthesis and Other AUTO Features


Search At the start of this chapter we mentioned the difference between local and global
optimization. Up to now, we have used local optimization, which efficiently locates
the nearest local minimum from the starting point, subject to constraints. CODE V
also has a very powerful global optimizer which is called Global Synthesis® (GS)
and is easily available whenever you are using AUTO.
1. Save your lens in an easily located file name (e.g., GS1DCAM.LEN).
GS will save each solution in a lens file (GS1DCAM1, GS1DCAM2, etc.), and
a distinct name will make it easier to keep track of the many files.
2. Click the Modify Settings button in the AUTO window you are working with
to access the AUTO dialog box.
3. On the Error Function Definitions and Controls tab, click the button labeled
Run Global Synthesis.
4. Click OK.
That’s it! Your regular AUTO run is now a global run, and the program will
generate multiple solutions. You may choose to limit the solutions with a Maximum
Error function target value (on the Exit Controls tab) to filter out poor solutions.
You may also find it necessary to add some constraints such as overall length
(OAL), since the design forms can very a great deal. Use of the DRAW feature
(Output Controls tab) is also advised. You will usually get a wide variety of
solutions (as in this case), some better than the starting point, but these should be
reviewed for quality and to see if they are suitable for manufacture.
AUTO has many other features including optimization of MTF, fiber coupling
efficiency, and even user defined error functions. The CODE V Reference Manual
is the best place to start to learn about these features.

CODE V Introductory User’s Guide 73


Chapter 3 Make It Better: Optimization
Menu

Constraints: Problems and Solutions


Search This is a table that lists various problems and the solutions in terms of what you
would constrain, with menu instructions and a command example for each. This
does not include the complete instructions for handling the problem, but is meant to
guide you on where to look. Keep in mind these points:
• Too many constraints can limit finding a good solution.
• Be sure you have variables that can affect the things you are constraining.
• If equality or bounding (< or >) constraints cause problems, you can use the
Minimize mode to push the constraint toward a goal value rather than holding it
exactly.
The CODE V Reference Manual has more details on constraints and their use.

Specific Constraint Tab Command


Problem
(AUTO dialog box) Example

Lens or section of lens is Manufacturing & Packaging, OAL S3..9 < 21.5
too long Overall Length (surface range)

Need a paraxial pupil at a Paraxial Ray Trace Data, YZ HCY S13 = 0


specific location (dummy Paraxial Chief Height (surface,
or real surface) set target to zero)

Need intermediate image Paraxial Ray Trace Data, YZ HMY S15 = 0


at a specific location Paraxial Marginal Height (sur-
(dummy or real surface) face, set target to zero)

Distortion is too big Optical Definitions, Distortion DIY F3 < 0.025


Fraction Y (field number, usu- DIY F3 > -0.025
ally bounded, enter twice if two (note: 2.5%)
bounds are needed)

A particular element (sur- Manufacturing & Packaging, SD s9 < 25.5


face) is too big in diameter Max Semi Diameter (surface
number)

I want f-theta linearity Real Ray Trace Data, Local Y Y Si R1 F3 = -127.8


Surface Coordinate (image sur-
face, ray 1, field number, calcu-
lated f-theta target value)

74 CODE V Introductory User’s Guide


Chapter 3 Make It Better: Optimization
Menu

Specific Constraint Tab Command


Problem
(AUTO dialog box) Example
Search
General thickness con- Manufacturing & Packaging, ET s10 < 2.1
straints are OK except for Edge thickness (surface, value) (overrides MNE, etc.)
one very small element

I can’t find a constraint User Defined Constraints allow See online Help and/
that does what I want to do you to define many conditions or CODE V Reference
using macros and program data. Manual.
See User Constraints tab and
Help for more details.

CODE V Introductory User’s Guide 75


Chapter 3 Make It Better: Optimization
Menu

Search

76 CODE V Introductory User’s Guide

You might also like