Mesh Generation
1. How do I create a mesh for my device?
The first step is to create a mesh representing the device geometry. For this purpose, we recommend using the QTCAD Builder package, which is included in QTCAD.
The QTCAD Builder package provides a range of workflows that offer significant flexibility for generating realistic device geometries and meshes. In addition, it includes validation checks to ensure that the generated meshes are compatible with QTCAD simulation requirements.
Another option is to create meshes directly using the Gmsh software and then import them into QTCAD for simulations. For guidance on mesh creation with Gmsh, please 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 QTCAD Builder: when possible: We strongly recommend using the QTCAD Builder package to generate meshes, as it ensures compatibility with QTCAD and performs several internal validation checks.
If you choose to generate meshes directly using the Gmsh API instead of QTCAD Builder, additional care is required. Unlike QTCAD Builder, which automatically performs geometry validation and handles operations needed to avoid overlapping or disconnected regions, manual Gmsh workflows require the user to ensure that the constructed geometry and mesh is valid for QTCAD simulation.
In particular, users should pay attention to geometry conformity and shared interfaces between subdomains, as these checks are handled internally by QTCAD Builder but must be managed manually when using Gmsh directly.
Check for overlapping or non-conformal geometries: A common issue in manually constructed Gmsh geometries is the creation of a non-conformal mesh, where the geometry contains overlapping regions. These overlapping regions may be meshed independently and therefore 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. 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)