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

Introduction to 3D Ray Tracing

Ray tracing models light as rays propagating through 3D space. It is ideal for devices with non-planar or microstructured geometries (e.g., microlens arrays, textured substrates, light-extraction features) where wave-optics thin-film assumptions no longer hold.

A ray is parameterized by a point \(\mathbf{r}_0\) and a unit direction \(\hat{\mathbf{d}}\):

\[ \mathbf{r}(t) = \mathbf{r}_0 + t\,\hat{\mathbf{d}}, \qquad t \ge 0 . \]

On hitting a surface with unit normal \(\hat{\mathbf{n}}\), the perfectly specular reflection direction is

\[ \hat{\mathbf{d}}_{\mathrm{ref}} = \hat{\mathbf{d}} - 2\,(\hat{\mathbf{d}}\!\cdot\!\hat{\mathbf{n}})\,\hat{\mathbf{n}} . \]

3D Snell’s Law (Vector Form)

Let \(n_1\) and \(n_2\) be the refractive indices of the incident and transmission media, respectively. Define \(\eta = \dfrac{n_1}{n_2}\) and \(c = -\,\hat{\mathbf{n}}\!\cdot\!\hat{\mathbf{d}}\) (the cosine of the incidence angle, using the convention that \(\hat{\mathbf{n}}\) points into medium 1). Then the refracted (transmitted) unit direction \(\hat{\mathbf{d}}_{\mathrm{refr}}\) is

\[ \hat{\mathbf{d}}_{\mathrm{refr}} \;=\; \eta\,\hat{\mathbf{d}} \;+\; \bigl(\eta\,c \;-\; \sqrt{\,1 - \eta^{2}\,\bigl(1-c^{2}\bigr)}\,\bigr)\,\hat{\mathbf{n}} . \]

The square-root argument enforces the physical constraint from Snell’s law, \(n_1 \sin\theta_1 = n_2 \sin\theta_2\). If

\[ 1 - \eta^{2}\,\bigl(1-c^{2}\bigr) \;<\; 0, \]

then no real solution exists and the ray undergoes total internal reflection (TIR); in that case, use \(\hat{\mathbf{d}}_{\mathrm{ref}}\) above.

Energy Partition (Optional)

To split energy between reflection and transmission, use Fresnel coefficients (unpolarized average):

\[ R \;=\; \tfrac{1}{2}\!\left( \left|\frac{n_2 c - n_1 c'}{n_2 c + n_1 c'}\right|^{2} \;+\; \left|\frac{n_1 c - n_2 c'}{n_1 c + n_2 c'}\right|^{2} \right),\qquad T = 1 - R, \]

where \(c' = \sqrt{\,1 - \eta^{2}\,(1-c^{2})\,}\) is \(\cos\theta_2\). In absorbing media, use complex refractive indices \(n = n' + i\kappa\).

Typical Uses