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

Ray-tracing Tutorial (Part B): Editing light sources

In Part A you loaded the Reflection from film ray-tracing demo and inspected how rays reflect from a rough surface derived from an AFM image. In this part you will learn how to edit the light sources: changing their position, orientation and emission pattern, and then re-running the simulation to see how the reflected rays respond.

Step 1: Open the light editor

Start from the simulation you created in Part A. Rotate and zoom the view so that you can clearly see one of the green light source markers. Then right-click on the light source and choose Edit object from the context menu, as shown in ??. This opens the light source editor window.

Zoomed view of the simulation with a right-click menu open on the light source and the Edit object option highlighted.
Right-click a light source and choose Edit object to open the light source editor. This allows you to change the position, size and emission characteristics of the source.
Object tab of the light source editor showing the offset, xyz size, number of objects and rotation fields.
The Object tab of the light source editor.
Here you control the position (Offset), physical size (xyz size) and rotation of the emitting patch. With zero rotation, dx and dy define a flat rectangular source aligned with the x and y axes.

Step 2: Set the position and size (Object tab)

The light source editor opens on the Object tab (??). This tab is common to many object types in the Optical Workbench. It controls:

For our light source, the important values are dx and dy, which specify the width and height of the emitting region in the x–y plane. When the rotations are set to zero, this corresponds to a flat, rectangular patch that is aligned with the grid. This patch is then used as the starting area from which individual beams are launched.

For now, leave the position and size unchanged. In later parts of the tutorial you can experiment with making the source larger or smaller, or creating multiple sources using the Number of objects fields.

Step 3: Control emission angles (Configure tab)

Next, click the Configure tab of the editor. This displays settings that determine how the source emits light, as shown in ??.

Configure tab of the light source editor showing emission angles and beam settings.
The Configure tab controls the emission pattern of the light source. Here you set the centre angles (Rotate Theta, Rotate Phi), the angular scan range (−Δθ, +Δθ, −Δφ, +Δφ), and the number of beams launched in x and y.
Orientation markers showing the x, y, z axes and the theta/phi angle conventions.
Orientation markers for the x, y, z axes and the angles θ and φ. These markers appear in one corner of the simulation window and define the direction conventions: θ is the polar angle from the +z axis, and φ is the azimuth in the x–y plane.

The key fields are:

In the configuration shown, θ is set to 0°, so the main direction of emission is horizontal, while φ = 30° means the fan of beams is rotated in the x–y plane. The scanning steps in φ cause the light to sweep sideways across the detector.

Step 4: Understanding θ and φ in the 3D view

You might reasonably ask: how do I know which way θ and φ point? To help with this, the Optical Workbench displays small orientation markers in one corner of the simulation window, as illustrated in ??. These show the x, y, z axes and the definitions of θ and φ.

If the markers are not immediately visible, rotate or zoom the view slightly; they are always located near one of the corners of the 3D scene.

Step 5: Point the beams downwards

As an exercise, you will now re-orient the light source so that it points downwards onto the rough film instead of sideways.

  1. In the Configure tab, adjust Rotate Theta and Rotate Phi so that the main beam direction is towards the film.
  2. Keep the ranges (−Δθ, +Δθ, −Δφ, +Δφ) and the number of beams unchanged for now.
  3. Click Rebuild in the light editor toolbar to apply the changes.
  4. Close the editor and click Run simulation (or press F9) to re-run the ray tracing.

You should see the rays now strike the surface from above rather than sweeping in from the side. Comparing the new ray pattern with the original configuration is a good way to build intuition for the θ and φ angles.

Step 6: Move the light source in 3D

Once you have a downward-pointing source, you can also move it laterally to illuminate different regions of the rough film. In the main 3D view, select the light source and drag it with the left mouse button to a new position near the centre of the surface. An example is shown in ??.

Simulation view showing the light source moved to the centre above the rough film.
The light source moved to the centre of the scene using the mouse. Once the beams have been redirected to point downward, this configuration illuminates the central region of the rough film.
Optical mesh editor showing the wavelength range and sampling points used for ray tracing.
The Optical Mesh Editor. This window controls which wavelengths are simulated. Here a range from 300–800 nm is sampled using 50 points, producing the spectral mesh shown along the bottom axis.

After moving the source, run the simulation again and observe how the distribution of rays on the detector changes. You can also inspect the updated detector efficiency curves in the Output tab, as described in Part A.

A final note on optical sources

The number of wavelengths emitted by a light source is controlled from the Optical ribbon using the Optical Mesh Editor (??). The mesh defines the spectral sampling used during the ray-tracing calculation, and it has a direct impact on both the accuracy of wavelength-dependent plots (for example reflection or transmission spectra) and the overall simulation speed.

As a general rule, it is best to begin with a small number of wavelengths while setting up a simulation. A coarse mesh of around 8 wavelengths is usually sufficient for positioning light sources, checking geometry, and verifying that rays behave as expected. Once you are confident that the configuration is correct, you can increase the mesh density to 40–50 wavelengths to obtain smooth, high-quality optical spectra.

Each wavelength is simulated independently on a separate CPU thread. This means that if your computer has many cores, OghmaNano will scale almost linearly with the number of wavelengths: more available threads lead to faster multi-wavelength simulations. Conversely, choosing an excessively fine mesh on a machine with only a few cores may slow the simulation down noticeably. Selecting an appropriate number of wavelengths is therefore a balance between accuracy and speed.

👉 Next step: Continue to Part C to explore more advanced analysis, including angle-resolved statistics and exporting data for external plotting.