Getting Started With Zemax Actually Means Dealing With The Merit Function First

Most people come into lens design thinking the software does the work for you. It doesn't. The software evaluates what you tell it to evaluate, and if your instructions are vague, you get a lens that looks good on paper and fails the second someone tries to fabricate it. The merit function is where the actual design happens. Everything else is just setup. I want to talk about how this actually goes when you're sitting at the keyboard, because the standard tutorials skip over the bits that take up 80 percent of your time. Let me give you a concrete workflow and then go into the stuff nobody warns you about. Start with a prescription. Don't build from zero unless you have a reason to. Take an existing lens — a Coddington singlet, a doublet, a triplet, whatever matches your general layout — and load it into OpticStudio. I usually pull designs from the Zemax library or older papers. The starting point matters more than people admit. If your initial ray trace looks reasonable, optimization converges faster. If it looks like garbage, you're going to spend two days fighting the solver before anything behaves.

Set your wavelengths. Not four. Set the ones that actually matter for your application. If you're doing visible imaging, 486, 587, and 656 nanometers — the F, d, and C lines — is standard. Add extra wavelengths only if your system has chromatic requirements that those three won't cover. Each additional wavelength multiplies the number of rays the optimizer has to track, and your optimization time goes up proportionally. This is one of those obvious things that beginners ignore constantly. Now the system configuration. Define your field points. For a simple imaging lens, three fields — on-axis, 0.7 field, and full field — is usually sufficient to start. You can always add more later. The number of fields directly affects how long each optimization cycle takes. I've watched people set up fifteen field points for a prototype lens that will eventually use three. Waste your own time, not the company's. Here's where most people stall. They don't understand how to build a merit function that actually guides the optimizer toward something realizable. The default merit function in Zemax uses RMS spot size as the operand. That's fine for a first pass, but spot size alone won't keep your lens manufacturable. You need to think about what's actually going to be built.

Add surface constraints early. Use the CTGT and CTTH operands to enforce minimum and maximum center thicknesses. Add AXCL and AXCC for edge thickness control. A lens with zero edge thickness on any surface is a lens that won't survive grinding. I learned this the hard way on a 50mm focal length doublet in 2019. The optimizer drove the edge thickness of the second element down to 0.3 millimeters because I hadn't constrained it. The designer who was going to manufacture it called me and asked if I was aware the part would snap during mounting. I wasn't. Adding thickness constraints after optimization finished added about forty-five minutes to the schedule. Doing it from the start would have prevented that conversation entirely. Control curvature with MNCA and MXCA operands. If you're working with a fabricator, ask them what radius ranges they can handle comfortably. Some shops struggle with radii under 25mm or over 500mm. Build those limits into your merit function instead of discovering them during a DFM review six weeks later. The optical power distribution between surfaces is another thing beginners consistently mess up. A single surface carrying too much power creates steep ray angles, which means larger apertures, more sensitivity to decenter, and worse tolerance performance. Spread the power across surfaces. A well-distributed doublet or triplet performs better and is easier to make than a singlet doing the same job. This isn't theory — I've seen people optimize a singlet to f/1.4 and then wonder why the tolerances were impossibly tight.

Get the Full Details

Amazon.com: Introduction to Lens Design: With Practical Zemax Examples ...
Amazon.com: Introduction to Lens Design: With Practical Zemax Examples ...

Let me explain how the optimizer actually works, because understanding this will save you days. The merit function is a sum of squared weighted errors. The optimizer adjusts your variables — surface curvatures, thicknesses, conic constants, glass selections — to minimize that sum. The weights you assign to each operand determine what the optimizer prioritizes. If you weight spot size at 1.0 and edge thickness at 0.01, the optimizer will happily violate your thickness constraints to shrink the spot. Weight management is the skill that separates people who produce usable designs from people who produce pretty numbers on a screen. Variable selection matters more than weight selection. Start with curvature as your primary variable. Fix thicknesses at reasonable values and let the optimizer adjust radii. Once the spot size converges, unlock thickness variables one at a time. Every variable you add increases the dimensionality of the optimization problem, and higher-dimensional problems have more local minima. A 20-variable optimization will find a different solution than a 10-variable optimization even when starting from the same point. Fewer variables generally means more reliable convergence. Glass selection is where the design becomes interesting. The built-in glass libraries in OpticStudio cover the major catalogs — Schott, Ohara, Hoya, CDGM. When you're swapping glasses during optimization, use the GLAS operand to let the software search for alternatives. But don't let it run wild. A glass swap can change the physical length of your lens, the number of surfaces needed, and whether you're using stock material or something that requires a custom melt. I've had situations where the optimizer swapped to a glass that existed in the database but had a lead time of sixteen weeks and a unit cost four times the original choice. Always verify that the glass your optimizer picks is actually available from your supply chain.

When I say practical examples, here's a specific workflow for a simple achromatic doublet: Open a new file. Set the object distance to infinity. Set the image distance to your target focal length — say 100mm. Define the aperture as f/4, which means an entrance pupil diameter of 25mm. Add two surfaces: the first element's front and back, then the second element's front and back, then the image plane. That's five surfaces total before the stop and image. Set the first surface radius to something reasonable — maybe 60mm. Set the air gap between elements to 1mm. Set the rear element thickness to 4mm. Assign BK7 to the first element and F2 to the second. This is a classic combination. Now set the merit function. Start with a default operand list targeting RMS spot radius. Make the rear surface radius and the air gap variables. Run a local optimization with the Damped Least Squares algorithm. Check the results. If the spot size improved but the edge thicknesses look unreasonable, add thickness constraints and reoptimize. If the spot size didn't improve, your starting point may be too far from a viable solution — try changing the initial radius or switching to a different glass pair.

There are operations in Zemax that are absolutely essential but completely undocumented in the beginner materials. The reverse ray trace function. The multi-configuration editor. The tolerance analysis module. Learning these early prevents rework later. Tolerance analysis in particular is where theoretical designs go to die. A lens that images at 2 microns RMS in the software might perform at 15 microns on the bench because the assemblage tolerances were never evaluated. Run a quick tolerance estimate before you hand off a design. It takes about ten minutes and can save a week of debugging. The non-sequential mode is worth mentioning briefly. Most lens design work happens in sequential mode, but if your system has stray light, diffractive elements, or complex scatter paths, non-sequential is necessary. The tradeoff is computational cost. Non-sequential ray tracing is orders of magnitude slower than sequential. Don't use it for routine optimization. Use it for analysis after the sequential design is finalized. One counter-intuitive thing about Zemax optimization: sometimes adding more constraints makes the solution worse, not better. If you constrain every parameter too tightly, the optimizer runs out of degrees of freedom and can't find a solution that satisfies the imaging performance you actually care about. The trick is to constrain what matters for manufacturability and leave the rest free. Center thickness matters. Edge thickness matters. Glass availability matters. The exact value of the third surface radius to the fifth decimal place does not matter at this stage.

Introduction to Lens Design With Practical Zemax Examples J. Geary ...
Introduction to Lens Design With Practical Zemax Examples J. Geary ...

Another thing people miss: the difference between minimizing spot size and minimizing wavefront error. These are related but not identical objectives. Spot size is a geometric measure. Wavefront error is a physical optics measure. For diffraction-limited systems, wavefront error is the right metric. For systems where geometric aberrations dominate, spot size is fine. Mixing the two without understanding the difference leads to suboptimal design choices. Use the Wavefront operand or switch the merit function type to Wavefront Error when you're working at the diffraction limit. If you're downloading OpticStudio for the first time, the trial version gives you full functionality for fourteen days. Academic licenses are available through the Zemax website with proper institutional verification. The student version is feature-restricted but sufficient for learning the basics. Don't waste the trial period watching YouTube tutorials. Open the software and build something. The manual is searchable and genuinely useful. The OpticStudio Help system contains operands, algorithms, and examples that are more accurate than any third-party summary. Spend thirty minutes reading the operand reference for the three operands you'll use most — REAY, TRAC, and SPHA. Understanding what these actually compute will make your merit functions more intentional.

There are limitations to Zemax that aren't discussed enough. The software assumes paraxial approximations in some analysis modes, which breaks down at wide angles or with strong aberrations. The tolerance analysis uses first-order sensitivity methods by default, which can underestimate real-world degradation for complex systems. For production-grade tolerance estimation, run Monte Carlo simulations with at least 500 trials. The default first-order analysis will give you numbers fast, but they're optimistic. I've seen published tolerance specs from first-order analysis that turned out to be thirty percent too loose when verified with Monte Carlo. Another failure mode: Zemax can't optimize what it can't model. If you're designing a freeform surface or a graded-index element, make sure your version of OpticStudio actually supports that operand type. The standard edition doesn't include freeform surfaces. You need the Premium or Ultimate tier for that. Don't design a freeform lens in Standard and then discover the operands aren't available when you try to run the optimization. For learning progression, I'd suggest this order: build a singlet, build a doublet, build a triplet, analyze a commercial lens by reverse-engineering its prescription, then move to something original. Each step introduces new constraint types and new optimization challenges. The triplet is where things get interesting because you have enough degrees of freedom to correct spherical aberration and coma simultaneously while still managing thickness and glass choices.

Save versions. Not just the final result. Save the state after each meaningful optimization run. Name them with dates and brief descriptions. I have projects where I went back to a version from three weeks earlier because the latest optimization had converged to a local minimum that looked good numerically but was physically unrealistic. Without version history, that recovered design is lost. The learning curve is real but manageable if you respect the tool. Zemax doesn't make bad designs for you, but it also won't stop you from making them. The responsibility for what comes out of the software is entirely yours. The merit function is your contract with the optimizer. Write it carefully, check the results critically, and verify manufacturability before anyone touches a lens blank.

Willman Bell Publishing : Introduction to Lens Design: With Practical ...
Willman Bell Publishing : Introduction to Lens Design: With Practical ...