# An Automated Framework for Streamlined CFD-Based Design and Optimization of Fixed-Wing UAV Wings
## 3 Framework Breakdown
### Solver Module  
The solver module integrates ANSYS Fluent 2023R2 via PyFluent to automate simulation setup, execution, and post-processing. Utilizing Fluent's GPU-native solver, calculations achieve up to 7\(\times\) faster computational times compared to parallel CPU solvers, significantly reducing simulation duration [47]. A dedicated _solution_ class, illustrated in Figure 8, manages input and output files, simulation setup, and execution. It also supports stall detection and convergence monitoring methods, ensuring high-fidelity results with minimal manual effort. To initiate this process, instantiating the solution class also launches Fluent automatically according to the specified launcher settings. Whether running in GPU or CPU mode, with or without GUI, and using a predefined number of processors, the solver is initialized with the appropriate computational resources before proceeding with the case setup and execution. Once Fluent is up and running, the module proceeds with loading the computational mesh from a _.msh.h5_ file. It then parses the XML file, extracting previously calculated attributes, including the MAC, reference surface area, Reynolds number, velocity, and altitude. These values are utilized in defining the simulation's boundary conditions and reference parameters for later force and moment calculations. The simulation setup is then performed iteratively over a predefined range of angles of attack. For each AoA in the range, the class executes all setup procedures detailed in Appendix A.4. Monitoring report files for lift, drag, and moments are also generated during the simulation, providing real-time feedback on solution convergence and stability. After initializing the solution, the simulation then enters an iterative solution phase, where Fluent runs for a predefined number of iterations while continuously checking for convergence, as described in Algorithm for Convergence Detection section. Once the solver detects convergence, the aerodynamic coefficients \(C_{L}\), \(C_{D}\), and \(C_{M}\) are computed using the final force and moment values. Post-processing includes extracting maximum and mean \(y^{+}\) values to evaluate the quality of the boundary layer resolution. The final results are stored in the XML file, and Fluent's output files (_.cas.h5_, _.dat.h5_, _.out_) are also saved. Throughout this process, robust error handling mechanisms ensure that Fluent automatically retries execution or logs issues if it encounters errors such as failed launches or missing files. The class is designed to efficiently manage multiple cases, automating the CFD workflow. Algorithm for Convergence Detection  
In CFD, convergence refers to the stabilization of iterative calculations of flow variables, indicating that the numerical solution is approaching a state that sufficiently satisfies the governing equations and boundary conditions. Typically, convergence is judged by a three-order-of-magnitude drop in residuals of continuity, momentum, and turbulence equations, alongside the stabilization of forces such as lift and drag [48]. Achieving convergence to machine precision is realistically impossible, and practical thresholds must balance accuracy and computational cost. In this framework, a custom convergence detection algorithm is implemented due to the limitations of Fluent's built-in methods for GPU-native solvers (Fluent v2023R2--v2024R2). This algorithm is incorporated as a hidden method within the _solution_ class and called by the _solve_ method while a simulation is running. This dependency can be observed in Figures 4 and 8. The method incorporates residual monitoring, periodicity checks, and termination criteria, focusing specifically on the aerodynamic quantities of interest: the forces acting along the \(x\) and \(z\) axes. The residual of these forces is calculated iteratively as  
Figure 8: Solution class responsible for solution setup and execution. the maximum relative change in force values over a specified window of past iterations (\(N\)), using the formula of Equation (1).