# Flying wing autosolve

This project presents the development of a parametric optimization algorithm for designing a stable, high-endurance flying-wing UAV. The approach integrates FreeCAD for geometry generation and OpenFOAM for RANS-based CFD analysis, while applying a gradient descent method with finite difference sensitivities.

## Usage

The software is operated through the FreeCAD interface using macros in the `FlyingWingAutoSolve_newParameter.FCStd` file.

### Setting up the design
- Open the spreadsheet `ParameterDescription` to set the initial values of the design variables, as well as their minimum and maximum bounds. Step sizes are automatically calculated.
- In the spreadsheet `SolverControl`, you can adjust solver settings such as `max iterations` or `learning rate`.

### Available macros
- **WingSolver_ResetDefaults.FCMacro**: Resets the design to default values.
- **WingSolver_CompleteLoop.FCMacro**: Starts the entire optimization process.
- **WingSolver_CalcGradient.FCMacro**: Calculates only the gradient for a given design.
- **EvaluateResults.FCMacro**: Evaluates the optimization results at the end of the process.

### Results
- All results are saved in the `results/` folder.
- In the `sstate` spreadsheet information on each iteration can be found

### Dependencies
- **Software:** FreeCAD (with the following addons: CFDOF, Curved Shapes), OpenFOAM.
- **Folder `WingSolver_dependencies`** contains key functions such as the objective function used in the optimization.

---

