.. _python_API_sweep_template:

.. currentmodule:: flow360

**************************
Sweep Template Script
**************************

This template script demonstrates the fundamental workflow for conducting parametric studies using the Flow360 Python API. The script provides a structured approach to uploading meshes, configuring simulation parameters, and executing either single cases or parameter sweeps.

The script is organized into several key functions:

- ``upload_mesh()``: Handles mesh upload and project creation
- ``make_params()``: Configures simulation parameters
- ``launch_sweep()``: Implements parameter sweep functionality
- ``main()``: Orchestrates the overall workflow

The following example demonstrates an angle of attack sweep study, but the template can be adapted for other parametric studies by modifying the relevant parameters.

.. literalinclude:: ../../../../Flow360/examples/getting_started/template_script_load_mesh_run_case_or_sweep.py
  :language: python
  :linenos:

Notes
====

- Verify boundary names in the mesh match those used in ``make_params()`` by checking ``vm.boundary_names``
- For parameter sweeps, adjust the ``alphas`` list in ``launch_sweep()`` to define the range of angles to study
- The script supports both new mesh uploads and existing project loading - comment/uncomment the appropriate section in ``main()``
