Getting Started

Trefoila

From installation to your first optimized lens in minutes

Version 0.2.0 Platform macOS / Windows / Linux

Getting Started

This guide walks you through installing Trefoila, opening your first design, and running a complete analysis workflow — from a blank system to an optimized lens with spot diagrams and MTF curves. No prior experience with optical design software is assumed.

If you are already up and running and want detailed reference documentation, see the User Manual.

Tip The fastest way to learn Trefoila is to open one of the built-in sample designs and explore it interactively. The Cooke Triplet sample (covered in Step 4) is a great starting point.

1. System Requirements

PlatformMinimumNotes
macOS macOS 12 Monterey or later Apple Silicon (M1/M2/M3) and Intel both supported
Windows Windows 10 (64-bit) or later Windows 11 recommended
Linux Ubuntu 20.04 LTS or equivalent Any glibc 2.31+ distribution should work

Additional Requirements

2. Download & Install

Download Trefoila from trefoila.app. The correct installer for your platform is detected automatically, or you can choose manually from the downloads page.

macOS

  1. Download the .dmg disk image from the Trefoila website.
  2. Double-click the .dmg file to mount it. A Finder window opens.
  3. Drag the Trefoila icon into the Applications folder shortcut shown in the window.
  4. Eject the disk image. Open Applications and double-click Trefoila to launch.
  5. On first launch macOS may show a security dialog. Click Open Anyway in System Settings → Privacy & Security if prompted.

Windows

  1. Download the Trefoila-Setup.exe installer.
  2. Double-click the installer. If Windows Defender SmartScreen appears, click More infoRun anyway.
  3. Follow the installation wizard: accept the license, choose an install location (default is fine), and click Install.
  4. Launch Trefoila from the Start menu or the desktop shortcut created by the installer.
Tip The installer does not require administrator rights if you choose a per-user install location (the default on Windows 10/11).

Linux

  1. Download the Trefoila-x86_64.AppImage file.
  2. Open a terminal and make it executable: chmod +x Trefoila-x86_64.AppImage
  3. Run it: ./Trefoila-x86_64.AppImage
  4. Optionally move the AppImage to ~/Applications/ and create a desktop launcher for convenience.
Note On some distributions you may need libfuse2 installed (sudo apt install libfuse2 on Ubuntu). If AppImage fails to mount, run with --no-sandbox or extract with ./Trefoila-x86_64.AppImage --appimage-extract and run the extracted binary directly.

3. First Launch

When you open Trefoila for the first time, a splash screen appears. It shows your license status and lists the built-in sample designs. Click any design row to load it directly, or dismiss the splash to start with an empty system.

Screenshot — Splash screen on first launch
Trefoila splash screen on first launch

After dismissing the splash, the main window appears with the ribbon toolbar at the top and the panel workspace in the center. You can also reach sample designs any time from the Setup tab.

4. Open a Sample Design

Trefoila ships with fully configured example systems. The Cooke Triplet is a classic photographic lens (f/5, 10 mm entrance pupil) and is a good starting point for exploring the application.

  1. Click the Setup tab in the ribbon.
  2. In the Samples group, click Cooke Triplet.

After opening, the 2D Layout panel appears automatically, showing the lens cross-section with ray fans traced through the system.

Screenshot — 2D Layout panel
2D Layout panel

The status bar at the bottom now shows the system's first-order properties: EFL, f/#, and Strehl ratio. These update automatically whenever you change any surface parameter.

Tip To experiment freely with a sample design, save a copy first using Ctrl/Cmd+Shift+S (Save As). This keeps the sample intact.

5. Understanding the Interface

Screenshot — Full application window with panels open
Trefoila full application window

The main window has four regions:

RegionLocationDescription
Ribbon ToolbarTopSix tabs — Setup, Construction, Analysis, Optimization, Tolerancing, View — each grouping related commands
System TreeFar left (narrow strip)Hierarchical view of surfaces, wavelengths, fields, and aperture
Panel WorkspaceCenter / rightFlexible tiled area where analysis panels, the layout, and the surface table live
Status BarBottomLive EFL, f/#, Strehl ratio, and background task progress

Ribbon Tabs

Screenshot — Ribbon toolbar showing Analysis tab
Ribbon toolbar — Analysis tab
TabWhat you do here
SetupDefine wavelengths, field points, aperture type and size, and object distance
ConstructionEdit the surface table — add/remove surfaces, set radii, thicknesses, glass, and aperture shapes
AnalysisOpen analysis panels: spot diagram, ray fan, wavefront, PSF, MTF, distortion, and more
OptimizationDefine design variables and merit function operands, then run the optimizer
TolerancingRun sensitivity analysis and Monte Carlo simulations to predict yield
ViewControl panel layout, zoom the 2D view, and export images or data

Panel Workspace

Panels can be opened from the Analysis ribbon tab, resized by dragging their borders, and tiled side by side. Every panel recomputes automatically when the system changes — there is no manual "update" button.

6. Setting Up a Simple Lens

This section walks through entering a lens from scratch. If you are working with the Cooke Triplet sample, follow along to understand each step — you can inspect the values already entered without changing them.

6.1 Surface Table

Click the Construction tab in the ribbon. The Surface Table panel opens in the workspace.

Screenshot — Surface Table panel
Surface Table panel

The table always starts with an Object surface (row 0) and ends with an Image surface. Every row in between is a physical optical surface or a gap.

ColumnDescription
RadiusRadius of curvature in mm. Positive = center of curvature to the right. Inf = flat.
ThicknessAxial distance to the next surface in mm.
GlassMaterial name (e.g. N-BK7) or blank for air.
Semi-Diam.Clear aperture radius in mm. Auto-calculated if left blank.
TypeStandard, Conic, Mirror, etc. Most surfaces are Standard.

To add a surface, right-click any row and choose Insert Surface After. To delete a surface, right-click and choose Delete Surface.

Double-click any surface row to open the Surface Properties dialog for full control over that surface.

Screenshot — Surface Properties dialog
Surface Properties dialog — Standard surface

6.2 Glass

Click directly on any Glass cell in the surface table to open the Glass Picker. You can search by name, filter by catalog (Schott, Ohara, Hoya, and others), or enter a custom index and Abbe number.

Screenshot — Glass Picker dialog
Glass Picker dialog

Leave the Glass cell blank to use air (n = 1.000). For mirrors, set Glass to MIRROR — Trefoila handles the sign reversal automatically.

Tip Type part of a glass name in the search box — for example SK16 — to narrow the list instantly. The picker shows the refractive index, Abbe number, and partial dispersion for the selected material.

6.3 Fields & Aperture

Click the Setup tab, then click Fields to open the fields dialog. Each field point defines an angle (for infinite-conjugate systems) or an object height (for finite conjugate systems) at which the system is evaluated.

Screenshot — Fields dialog
Fields dialog

Add field points by clicking Add Field. A typical starting set is three fields: on-axis (0°), 70 % of full field, and full field. Analysis panels color-code results by field point so you can compare them at a glance.

Back in the Setup tab, click Aperture to set the entrance pupil diameter (EPD). You can also specify the aperture as an image-space f-number or numerical aperture depending on your design intent.

Screenshot — Setup tab showing aperture and field controls
Setup tab
Note All analysis panels — spot diagrams, ray fans, MTF, wavefront — trace rays for every defined field point simultaneously. Adding more field points increases computation time but gives a more complete picture of off-axis performance.

7. Running Your First Analysis

Once a system is defined, open analysis panels from the Analysis tab. Each panel is independent and can be open simultaneously.

Spot Diagram

Click AnalysisSpot Diagram. A grid of spot plots appears, one cell per field point. The geometric RMS spot radius is shown below each cell.

Screenshot — Spot Diagram panel
Spot Diagram panel

Each wavelength is plotted in a different color. The Airy disk radius is shown as a reference circle when the system is diffraction-limited or near it. Pan and zoom individual cells with the mouse.

Ray Fan

Click AnalysisRay Fan. The tangential (T) and sagittal (S) fans are shown for each field point. The horizontal axis is normalized pupil coordinate; the vertical axis is transverse aberration in mm.

Screenshot — Ray Fan panel
Ray Fan panel

S-shaped curves indicate third-order spherical aberration. Straight sloped lines indicate defocus. Asymmetry between T and S fans indicates astigmatism or coma.

MTF

Click AnalysisMTF. The modulation transfer function is plotted against spatial frequency (cycles/mm at the image plane) for each field point, tangential and sagittal separately.

Screenshot — MTF panel
MTF panel
Tip Switch between MTF methods (FFT, Huygens, Polychromatic, Geometric) using the dropdown in the panel toolbar. Huygens MTF is the most accurate near the diffraction limit; FFT is faster for quick design iterations.

8. Optimization

Trefoila's optimizer adjusts surface radii, thicknesses, glass indices, and conic constants to minimize a merit function you define. This section walks through the essentials.

  1. Click the Optimization tab, then click Optimization Studio to open the combined setup panel.
  2. Set variables. In the Variables section, check the radius or thickness of each surface you want the optimizer to change. A blue V badge appears on those cells in the surface table.
  3. Define the merit function. The default merit function minimizes RMS wavefront error across all fields and wavelengths, which is a practical starting point for most designs. Add custom operands (focal length, distortion, back focal distance, etc.) from the operand list.
Screenshot — Optimization Studio
Optimization Studio panel
  1. Click Run. The merit function value is shown in real time as the optimizer iterates. Analysis panels that are open update live so you can watch the design improve.
Screenshot — Optimization running
Optimization panel running

Trefoila offers four algorithms selectable from the optimizer toolbar:

AlgorithmBest for
DLS (Damped Least Squares)Polishing a near-final design; fast convergence when close to optimum
Nelder-MeadNon-differentiable merit functions; robust but slow
Differential EvolutionGlobal search with many variables; good for finding fundamentally better forms
Hybrid DE+DLSGlobal search followed by local polish; a solid default for new designs
Warning Check that glass constraints (minimum/maximum index, Abbe number limits) are included as operands before running a long optimization. Without them, the optimizer can push glass values into physically unrealizable or very expensive territory.

9. Saving Your Work

Save

Press Ctrl/Cmd+S or click File → Save. Projects are saved in the .trf format — plain JSON text that is fully human-readable and diff-friendly for version control.

Tip Because .trf files are plain JSON, you can track your optical designs in git just like source code. Every surface parameter change produces a clean, reviewable diff.

Save As

Use Ctrl/Cmd+Shift+S to save to a new filename. This is useful when creating design variants or when working from a sample file you want to keep unmodified.

Export

Use File → Export to share designs. Export options include:

Note .trf files do not contain glass catalog data — they reference glasses by name. This keeps file sizes small and ensures designs pick up any catalog updates automatically on reload.

You now have everything you need to explore Trefoila. For detailed documentation on any feature — surface types, advanced apertures, tolerancing, coatings, the file format — see the User Manual.

Trefoila v0.2.0  ·  © 2026 Blake Griffiths  ·  All rights reserved