Home Examples Screenshots User manual Bluesky logo
OghmaNano Simulate organic/Perovskite Solar Cells, OFETs, and OLEDs DOWNLOAD

Ray-tracing Tutorial (Part A): Reflection from a Rough Film

In this tutorial you will use OghmaNano’s ray tracer to study how light reflects from a rough film. The roughness can represent an AFM image or any other experimentally measured surface. You will load the Reflection from film demo, run a ray-tracing simulation, and examine how efficiently light is captured by a detector above the film.

Step 1: Open the ray-tracing examples

Launch OghmaNano from the Windows Start menu. From the start window, click New simulation. This opens the device-type library. Locate and double-click the Ray tracing category as shown in ??. This will open the folder of ray-tracing demos (??).

OghmaNano new simulation window with the Ray tracing category highlighted.
The New simulation window. Double-click the Ray tracing category to open the ray-tracing example projects.
List of ray-tracing demos including light box, microlens, prism demo, and Reflection from film.
The ray-tracing demo library. Select Reflection from film (highlighted) to load the example where light reflects from a rough film derived from an AFM image.

When prompted, choose a directory where the simulation should be saved. As with all OghmaNano simulations, it is best to use a local folder (for example on C:\) rather than a network or cloud drive. You can read more about simulation speedhere.

Step 2: Inspect the film and detector

After selecting Reflection from film, the main Optical Workbench window opens and shows the 3D scene (??). The red surface represents the rough film (for example, an AFM height map), the green arrows are the light sources, and the purple grid above the film is the optical detector – conceptually similar to a CCD camera.

You can navigate the 3D view using the mouse:

Overall view of the rough film, light sources, and detector grid in the Optical Workbench.
Initial view of the Reflection from film demo. The rough red surface is the film, the purple mesh is the detector plane, and the green arrows indicate the positions and directions of the light sources.
Zoomed-in view of the light sources just above the rough film.
Zoomed view of the light sources. By rotating and zooming the camera you can closely inspect how the sources are positioned relative to the rough film.

Step 3: Run the ray-tracing simulation

To start the simulation, click the Run simulation button (blue play icon) in the toolbar or press F9. OghmaNano will trace many rays from the sources, reflecting and refracting them according to the local surface normal of the film. As the simulation runs, the main view will update to show the paths of the rays (??).

Rays traced from the sources towards the rough film and detector plane.
Example of the ray-tracing result for the rough film. Rays originate from the green source region, interact with the rough red surface, and are partially captured by the purple detector grid above the film.

Step 4: Explore different wavelengths

The Wavelengths widget in the Optical ribbon lets you choose which wavelength is currently visualised in the 3D view. Select a wavelength from the drop-down box as shown in ??. This does not rerun the simulation – the full spectrum is precomputed – but it controls which subset of rays is displayed.

Optical ribbon with the wavelength selection widget highlighted.
Wavelength selection in the Optical ribbon. Use this drop-down menu to visualise how rays at different wavelengths propagate through and reflect from the rough film.

Try a few wavelengths and observe how the ray density at the detector changes. In later parts of the tutorial you will see how this relates to interference, scattering and absorption in the film.

Step 5: View the detector output

When the ray tracing is complete, switch to the Output tab to view the files written to disk (??). You will see a range of files describing the rays and detector responses. The most relevant for this tutorial is the detector0 directory, which contains the data recorded by the purple detector plane.

Output tab showing files such as detector0, rays.csv, and other ray-tracing outputs.
The Output tab for the Reflection from film demo. The detector0 folder contains the response of the detector plane; other files describe the individual rays and angular distributions.

Double-click the detector0 folder, then open the file detector_efficiency0.csv. This file stores the fraction of light energy arriving at the detector as a function of wavelength. When you open it, OghmaNano’s plotting tool will show a spectrum similar to ??.

Detector efficiency versus wavelength plotted from detector_efficiency0.csv.
Example detector efficiency spectrum derived from detector_efficiency0.csv. The vertical axis shows the fraction of light that reaches the detector. When a ray leaves the source it has intensity 1; attenuation and scattering by the rough film reduce this value before it reaches the detector. In this example almost no light is detected at long wavelengths, while shorter wavelengths are captured more efficiently. (The axis label currently shows metres, but the horizontal axis should be interpreted as wavelength in nanometres.)

By comparing the detector efficiency curve to the visualised rays at different wavelengths, you can build intuition for how surface roughness, scattering and angular distribution affect the detected signal.

The output files from your simulation

Each ray-tracing simulation generates a collection of files that describe the geometry, the individual rays, and the response of any detectors. Most of these are plain .csv files that can be opened in OghmaNano’s built-in viewers or analysed in external tools such as Python, Matlab or Excel. The key outputs for the Reflection from film demo are summarised in Table 1.

Table 1: Selected files produced by the ray-tracing simulation
File or folder Description
rays.csvList of traced rays (positions, directions, wavelengths, and intensities).
ray_trace/Additional ray-trace diagnostics and statistics.
detector0/detector_efficiency0.csvDetector efficiency vs wavelength (see ??).
detector0/detector_input0.csvTotal light incident on the detector plane vs wavelength.
RAY_image.csvImage-like representation of rays on the detector plane.
device.csvGeometric description of the rough film and detector surfaces.

👉 Next step: Continue to Part B to learn how to modify the rough surface, adjust the light sources, and run parameter sweeps.