Mesh Generation
1. How do I create a mesh for my device?
The first step involves creating a mesh that represents the device geometry.
You can utilize the devicegen package, maintained by Nanoacademic Technologies,
to generate meshes directly from GDS layout files. The package is open source and
available on GitHub.
Alternatively, users can create meshes using the Gmsh software and import them
into QTCAD for simulation purposes.
For guidance on mesh creation with Gmsh, refer to the official tutorials:
Gmsh Tutorials.
2. What should I do if I encounter an error when importing a mesh?
Errors during mesh import are often caused by overlapping surfaces or the presence of unsupported element types in the mesh file.
To resolve these issues:
Check Mesh Path: Ensure the mesh exists at the specified path.
Inspect the mesh: Use Gmsh’s GUI to check for disconnected or overlapping regions.
Check file format: Ensure the mesh is in a supported format such as
.msh,.msh2, or.msh4.Verify mesh conformity: Make sure all subdomains are properly connected and share boundaries.
Check element types: QTCAD supports only first- and second-order triangles in 2D and tetrahedrons in 3D. Element types such as quadrangles, prisms, and hexahedrons are not supported.
Use devicegen: We recommend using the
devicegenpackage to generate the mesh for full compatibility with QTCAD. Thedevicegenpackage currently only supports extruded geometries.Check for overlapping geometries: If the mesh contains overlapping geometries, you may need to adjust the mesh generation parameters in Gmsh to avoid overlaps.
One common cause of mesh import errors is that the mesh is non-conformal—meaning that different parts of the geometry (such as the gates and the simulation domain) are meshed independently and do not share common nodes or boundaries, even if they appear visually connected.
For example:
Fig. 2 In this figure, the green and orange regions are meshed separately. Although they appear adjacent, they are not connected at the mesh level. Attempting to import this mesh will raise an error.
Fig. 3 This figure shows a conformal mesh where the green and orange regions share nodes at their interface. This type of mesh is valid and can be successfully imported.
In one reported case, a 2D mesh for the gates and a 3D mesh for the simulation domain were disjoint. Because they were not connected, the mesh import failed, as it could not reconcile the domains into a unified structure.
To prevent this issue:
Use the
BooleanFragmentsoperation in Gmsh to generate a conformal mesh that enforces shared boundaries, for example:BooleanFragments{ Surface{1:N}; Delete; }{ }
where
1:Nrepresents the surfaces of your device geometry. Note that this operation is only available when using the OpenCASCADE kernel in Gmsh (not the Built-in kernel).Always verify mesh conformity before attempting to import the mesh.
If the issue persists, please contact us by submitting a ticket to the Nanoacademic Customer Support Center.
4. What should I do if I encounter a non-conformal warning when solving the Poisson equation?
A non-conformal warning from the Poisson solver typically indicates the presence of a hanging node or a non-conformal boundary condition in the mesh. To resolve this issue, consider the following steps:
Check geometry connectivity: Ensure that all geometries are properly connected and share boundaries without gaps or overlaps.
Regenerate the mesh: If the geometries are correctly defined, try generating a new mesh by adjusting the characteristic length parameters in your Gmsh script. For example:
Mesh.CharacteristicLengthMin = 0.1; Mesh.CharacteristicLengthMax = 0.5;
Use adaptive refinement: If the warning persists, try using a coarser mesh initially and enable the adaptive meshing step in the Poisson solver to refine the mesh automatically during simulation.
Change the meshing algorithm: You can also try changing the meshing algorithm in Gmsh. Gmsh supports various meshing algorithms. In QTCAD, we recommend using the Delaunay or HXT algorithms for a better result. You can specify the adaptive meshing algorithm in QTCAD by assigning the
meshing_algoattribute in ourPoisson solver’sSolverParamsclass:from qtcad.device.poisson import SolverParams p_params = SolverParams() p_params.meshing_algo = "delaunay" # or "hxt" # Set other parameters as needed
Note
The HXT method is only available in 3D geometries. Although this method is more efficient than Delaunay, we have experienced stabilitiy issues in special cases.
5. What should I do if my mesh is too large?
If your mesh contains a very large number of elements, it may lead to excessive memory usage or long simulation times. When using adaptive meshing, you can reduce mesh size by adjusting the refinement parameters used in the Poisson solver. Please refer to our API documentation. section for guidance on tuning these parameters.
For static meshes, please consider increasing the characteristic length parameters in your Gmsh script to reduce the number of elements. For example, you can include the commands:
Mesh.CharacteristicLengthMin = 2;
Mesh.CharacteristicLengthMax = 4;
to your .geo file to alter the minimum and maximum mesh element sizes.
As a general recommendation based on our experience:
Laptop-class machines: up to 0.5 million elements
PCs or workstations: up to 5 million elements
See the Software requirements section for hardware recommendations.
6. Does QTCAD support GPU acceleration?
Currently, QTCAD does not support GPU acceleration, but adding this capability is on our roadmap.
7. Is there a way to visualize the mesh in QTCAD?
Yes, you can use the command mesh.show() to visualize the mesh in QTCAD.
Furthermore, you can use Gmsh’s GUI to inspect the mesh visually before importing it into QTCAD by running the command:
gmsh your_mesh_file.msh
Finally, you can also save the geometry index of an already imported mesh as a .vtu file for visualization in Paraview or other compatible software:
from qtcad.device import io
# calculate the region index for the device
region_index = d.get_region_index()
# save the mesh and region index to a .vtu file
io.save("path\to\save\geometry.vtu", region_index, d.mesh)