Meshing
What is meshing?
Meshing is the process of dividing a continuous physical region into a set of discrete points that can be handled by a computer. For example, imagine heat flowing along a metal bar from a candle flame at one end to a block of ice at the other. In reality, temperature varies continuously along the bar, but a simulation cannot store infinitely many values. Instead, the bar is represented by a finite number of sample points (a mesh), and calculations are performed only at those locations (see ??). By working with a mesh, we convert an otherwise continuous problem into a discrete one that can be solved using numerical methods. This principle underlies finite-difference, finite-element, and other computational approaches widely used in physics and engineering.

Different meshes for different problems
In OghmaNano, three core physical models are solved: the optical model (light absorption and propagation), the thermal model (heat generation and flow), and the electrical model (charge transport and recombination). Each of these processes typically occurs on very different length scales, so each requires its own mesh. For example:
- Organic solar cell: Electrically relevant effects are concentrated in the active layer (≈100 nm thick), so drift–diffusion equations only need to be solved there. However, light interacts with all layers of the device stack (≈1 µm thick), so the optical problem must be solved across the full device. In this case, the optical mesh spans the entire stack, while the electrical mesh is focused on the active layer.
- Quantum Well laser diode: The device may generate significant heat in its quantum wells (≈30 nm thick) and waveguide layers (≈1 µm thick), but this heat ultimately dissipates through a large copper heat sink that is centimeters thick. Here, electrical effects must be modeled on the nanometer-to-micrometer scale inside the device, whereas thermal effects require a mesh extending out to the centimeter scale of the heat sink.



In practice, this means different physical effects must be simulated on different length scales. Additionally, device structures often include very thin contact or interface layers just a few nanometers thick. Optically, such layers are far below the wavelength of light and can often be ignored, but electrically they are critical because they determine the current–voltage behavior of the device. To capture these effects, you would use a very fine electrical mesh in those regions, while the optical mesh can remain coarser and span over them.
OghmaNano automatically interpolates between meshes when coupling models. For example, if you define a thermal profile on the thermal mesh but the electrical solver requires local temperature values, they are transferred through interpolation. The same applies for optical quantities such as the carrier generation rate, which are interpolated from the optical mesh onto the electrical mesh as needed. As a user, you do not need to manually manage these transfers.
The three meshes of OghmaNano
OghmaNano provides three independent meshes — thermal, optical, and electrical — which can be defined separately depending on the problem being solved. Each mesh is accessed from its corresponding ribbon tab, as shown in Figure ??.
Electrical mesh

Clicking the Electrical mesh button in the Electrical ribbon opens the mesh editor window (Figure ??). At the top of this window are the X, Y, and Z buttons. These toggle which spatial dimensions are active in the simulation. For example, activating only Y enables a 1D simulation, while enabling X and Y together sets up a 2D simulation. In the example shown, both X and Y are active, so the mesh is configured for a 2D OFET simulation. The central tables function like spreadsheets and define the mesh structure for each active dimension. Their main columns are:
- Thickness: the physical thickness of each mesh region.
- Mesh points: the number of discretization points in that region.
- Step multiply: how much the grid spacing grows within the region.
For example, a value of
1.1
increases each step by 10% relative to the previous one. - Left/Right: sets the side of the device from which the mesh is generated.
The resulting meshes are plotted in the graphs at the bottom of the window, giving immediate feedback on point spacing and distribution. The Import from layer editor button provides a shortcut for complex devices. It clears the Y-mesh and automatically imports all layers from the Layer Editor, assigning four mesh points per layer. This is especially useful for structures with many layers, such as laser diodes.
Optical mesh

The optical mesh editor (Figure ??) is similar in layout to the electrical mesh editor but includes an additional panel for defining the wavelength mesh. At the top of the window, the X, Y, and Z buttons toggle which spatial dimensions are active, while the λ (Wavelength) button enables the spectral grid.
The left-hand panel specifies the spatial discretization in nanometers, using the same columns as the electrical mesh (Thickness, Mesh points, Step multiply, and Left/Right). The right-hand panel defines the spectral range by setting the Start and Stop wavelengths, the number of points, and the step multiplier. These wavelength points are used consistently across all optical solvers, including ray tracing, FDTD, and transfer matrix simulations.
Thermal mesh
The thermal mesh editor (Figure ??) works in the same way as the electrical and optical mesh editors, with X, Y, and Z buttons to activate spatial dimensions. In addition, it includes a dedicated T (Temperature) mesh.

The temperature mesh is used whenever simulations need to account for temperature dependence, for example when enabling self-heating or when evaluating electrical properties across a temperature range. Before the simulation runs, OghmaNano pre-calculates and tabulates quantities such as carrier densities versus Fermi level and temperature, or Fermi–Dirac integrals. These tables allow the solver to quickly look up values during the run, rather than computing them repeatedly.
In most cases the thermal mesh is handled automatically, but advanced users may adjust the range and resolution to ensure sufficient accuracy for strongly temperature-dependent problems.
The electrical mesh in detail
Figure ?? illustrates how the electrical mesh is constructed. Notice that the mesh does not begin exactly at the device boundary, but rather starts half a mesh spacing inside. This ensures that the first computational node lies within the active simulation region, allowing boundary conditions (e.g. contacts) to be applied at well-defined positions just outside the mesh. The same convention is applied at the far edge of the device, so the mesh extends half a step beyond the final physical point. This offset arrangement provides two key advantages:
- It avoids numerical issues that arise when trying to evaluate derivatives directly on boundaries.
- It places the first and last mesh points in positions that best represent the physical device interior, while still enabling external conditions to be imposed consistently.
When do I need to worry about meshing in OghmaNano?

Electrical mesh
The Layer Editor splits a device into layers of different materials (see Section 3.1.3). Layers marked as active are those over which the electrical model is applied. For these layers, a finite-difference mesh must be defined. The mesh length must match the active layer length exactly—otherwise an error will occur. OghmaNano will usually generate a suitable mesh automatically, so for most simple devices you won’t need to think about it. However, when multiple active layers are present, or when you want to reduce the number of mesh points to speed up a simulation (or increase them for higher accuracy), you may need to manually configure the electrical mesh.
Optical mesh
The optical mesh controls both position and wavelength sampling. You may need to adjust it if you want to change the simulated wavelength range or refine how light interacts with different layers of the device. Increasing the number of mesh points improves optical accuracy but comes at the cost of longer simulation times.
Thermal mesh
The thermal mesh is only relevant when self-heating is enabled. In this case, it provides the resolution needed to model how temperature evolves across the device or how thermal effects couple to traps and recombination processes. Otherwise, it is handled automatically by OghmaNano.
Meshing tips
Should I be simulating in 1D, 2D, or 3D?
Choosing the correct dimensionality is one of the most important decisions in setting up a simulation. Always use the minimum number of dimensions required to capture the physics of interest—this saves time and computational resources.
- Solar cells: Typically require only 1D meshes, since variations are primarily along the vertical (thickness) direction.
- Optical filters: Also usually 1D, as the key optical interference occurs in the stack direction.
- OFETs: Require 2D, since both vertical current flow through the semiconductor and lateral current between source and drain must be resolved.
Speed vs. accuracy
Adding more mesh points generally improves accuracy but slows down the simulation. Conversely, using fewer mesh points speeds things up but risks losing important physical detail. The key is to strike a balance: begin with a coarse mesh to test your setup, then refine it only as much as necessary to achieve stable and reliable results.
When setting up a device in OghmaNano, keep the following guidelines in mind:
- Minimize mesh points where possible: Aim for the smallest number of points that still captures the essential physics. This improves computational speed without sacrificing accuracy.
- More points ≠ always better: In the electrical model, equations are solved as boundary value problems between mesh points rather than simple linear interpolations. This means you can often obtain good results with surprisingly few points—leading to very fast simulations.
- Use coarse meshes for exploration: When testing fits or investigating general device behavior, don’t hesitate to dramatically reduce mesh density. This gives rapid feedback. Once you’re confident in the setup, refine the mesh for accuracy.