Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update documentation for Solver Setup #81

Open
wants to merge 7 commits into
base: develop
Choose a base branch
from
Open
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
137 changes: 127 additions & 10 deletions _docs_v7/Solver-Setup.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,13 @@ permalink: /docs_v7/Solver-Setup/

This is a basic introduction on how to set up a simulation using SU2. We distinguish between single-zone computations and multi-zone computations. The following considers a single zone only. For an explanation on multi-zone problems, continue with [Basics of Multi-Zone Computations](/docs_v7/Multizone).

Three different types of mathematical problems can be solved in SU2. The type of problem to be solved is specified on the config file by the `MATH_PROBLEM` field. The options are:
pcarruscag marked this conversation as resolved.
Show resolved Hide resolved
`DIRECT`: Also referred to as primal, this is the default when SU2_CFD or SU2_DEF are used.
`DISCRETE_ADJOINT`: A discrete adjoint methodology based on Automatic Differentiation, available for most solvers.
pcarruscag marked this conversation as resolved.
Show resolved Hide resolved
`CONTINUOUS_ADJOINT`: A hand-derived continuous adjoint methodology available only for compressible flows.

See the [Software Components](/docs_v7/Software-Components/) documentation to determine which software module is required for each problem.

---

- [Defining the Problem](#defining-the-problem)
Expand All @@ -22,9 +29,11 @@ This is a basic introduction on how to set up a simulation using SU2. We disting

| Solver | Version |
| --- | --- |
| `ALL`| 7.0.0 |
| `ALL`| 7.3.1 |

## Direct ##

SU2 is capable of dealing with different kinds of physical problems. The kind of problem is defined by choosing a solver using the `SOLVER` option. A list of possible values and a description can be found in the following table:
SU2 is capable of dealing with different kinds of physical problems. The kind of problem is defined by choosing a solver using the `SOLVER` option. The list of possible values and a description can be found in the following table:

| Option Value | Problem | Type |
|---|---|---|
Expand All @@ -40,15 +49,111 @@ SU2 is capable of dealing with different kinds of physical problems. The kind of
|`FEM_NAVIER_STOKES`| **Navier-Stokes' equation** | Discontinuous Galerkin FEM |
|`MULTIPHYSICS` | Multi-zone problem with different solvers in each zone | - |

### Turbulence modeling ###

This section describes how to define the turbulence model in SU2 to be coupled to RANS or INC_RANS. The selected model must be specified in the config file by the `KIND_TURB_MODEL` option. The current available turbulence models are the:
- `NONE`: No turbulence model.
- `SST`: Mentor Shear Stress Transport.
- `SA`: Spalart-Allmaras.

Different corrections and variations are implemented for each turbulence model. These are specified accordingly either in `SST_OPTIONS` or in `SA_OPTIONS`. The folowing options are available:
- `SST_OPTIONS`:
- `NONE`: No SST turbulence model (default).
- `V1994m`: refers to the "Standard" Menter SST model from 1994 with the modified constant $\sigma_{k1}$ and the redefinition of the turbulent eddy viscosity.
- `V2003m`: refers to the Menter SST model from 2003 ignoring the $\tau_{ij}$ in the momentum and energy equations and the production term is approximated by $P = \mu_t S^2$.
- `VORTICITY`: refers to the vorticity source term correction.
- `KATO_LAUNDER`: refers to the Kato-Launder correction.
- `UQ`: refers to the V1994m version with uncertainty quantification modifications.??
- `SUSTAINING`: refers to the controlled decay correction.

- `SA_OPTIONS`:
- `NONE`: refers to the modification where the $f_{t2}$ term is set to zero, i.e., $c_{t3} = 0$ (default).
Comment on lines +60 to +70
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This does not have to be repeated here... just point to the section in Physical definition.

- `NEGATIVE`: refers to the negative Spalart-Allmaras modification.
- `EDWARDS`: refers to the so-called Edwards modification.
- `WITHFT2`: refers to the standalone version.
- `QCR2000`: refers to the Quadratic Constitutive Relation modification, 2000 version.
- `COMPRESSIBILITY`: refers to the Mixing Layer Compressibility modification.
- `ROTATION`: refers to the rotation and curvature effects correction.
- `BCM`: refers to the SA-BCM transitional turbulence model.
- `EXPERIMENTAL`: Allow experimental combinations of options (according to [NASA TMR](https://turbmodels.larc.nasa.gov/)).

We refer for example to [NASA TMR](https://turbmodels.larc.nasa.gov/) for a detailed explanation and definition of each correction and variation.

#### Spalart-Allamaras ####
The single transported Spalart-Allmaras variable $\tilde{\nu}$ is initialized with the value at the farfield or inlet boundary. As suggested in the literature, the value there is computed as $\tilde{\nu}/\nu=\text{turb2lam}$. In SU2 the free-stream Spalart-Allmaras variable to kinematic laminar viscosity ratio, $\text{turb2lam}$, is defined by the `FREESTREAM_NU_FACTOR` config file field. The default value is $\tilde{\nu}/\nu = 3.0$ avoiding laminar solutions.

An extension of SU2 includes an hybrid turbulence model: the Spalart-Allmaras original model with Detached-Eddy Simulation (DES) modification. Refer to Eduardo Moina's thesis?. The use of the hybrid RANS/LES model is specified in the cofig file with the field `HYBRID_RANSLES`. Four different techniques are currently implemented:

- `SA_DES` Detached-Eddy Simulation
- `SA_DDES` Delayed Detached-Eddy Simulation
- `SA_ZDES` Zonal Detached-Eddy Simulation
- `SA_EDDES` Enhanced Detached-Eddy Simulation

The DES constant can be controlledd by the field `DES_CONST`, with 0.65 as default.

#### Menter’s k-omega SST Model ####
As initial conditions, the values of are initialized at all grid point with the farfield values. The farfield conditions for the turbulent kinetic energy $k$ is computed as: $k = \frac{3}{2}(UI)$, whereby $U$ is the freestream velocity magnitude and $I$ is the turbulence intensity. This latter value can be specified in the config file by the `FREESTREAM_TURBULENCEINTENSITY` field, with defaul value to 0.05 which corresponds to a $5\%$. The freestream value of the turbulent frequency $\omega$ is computed as: $\omega = \frac{\rho k}{\mu}(\frac{\mu_t}{\mu})^{-1}$, where $\rho$ and $\mu$ are the freestream density and laminar viscosity respectively and $\frac{\mu_t}{\mu}$ is the turbulent viscosity ratio, also known as freestream dissipation. Its value can be specified in the `FREESTREAM_TURB2LAMVISCRATIO` field, defaulting to $10$.
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would be nice if someone checks the boundary conditions for omega. I am not that familiar with the k-w model.


##### Limitations of k and omega #####
To increase robustness and prevent negative values, a hard-coded upper and lower limit are set for each turbulent variable:
```
// turbulence kinetic energy
lowerlimit = 1.0e-10;
upperlimit = 1.0e10;

//
lowerlimit = 1.0e-4;
upperlimit = 1.0e15;
```
Further, by the model definition in the farfield region there is no production of $k$ nor $\omega$ while destruction still takes place. Consequently the turbulence quantities typically decay on their way from the farfield boundary to the airfoil. In order to prevent the non-physical decay <!--of the turbulence variables--> in SU2 there are implemented to two approaches:
- Sustaining terms: it consists on the introduction of additional source terms in the turbulence model equations compensating the destruction terms in the farfield flow. This approach is activated by using the modified version of the SST moodel, `SST-sust`.
- Floor values: this approach is equivalent to setting the lowerlimit to the farfield values in the upstream region of an airfoil. The floor values are implemented in the form of fixed values. This correction can be activated with the following parameters in the config file:
`TURB_FIXED_VALUES= YES`
`TURB_FIXED_VALUES_DOMAIN= -1.0`
To determine those grid points where the correction should be applied, we compare the dot product of the normalized freestream velocity vector and the grid point coordinates. For those points which dot product result is lower than the specified `TURB_FIXED_VALUES_DOMAIN` value, the turbulence quantities are just set to the farfield values there. Note that although the Spalart-Allmaras turbulence model does not suffer from a decaying turbulence variable, the floor values limitation can also be employed. <!--The implementation is analogous to the strong boundary conditions, setting the turbulent residual equal zero at those locations.-->

### Foward mode of AD ###
The forward mode of AD capability allows to compute the forward derivatives (see [Advanced AD Techniques](/docs_v7/Advanced-AD-Techniques)) of an specified function with respect to a registered variable/s. If multiple design variables are registered as input, the output will consist on the accumulation. The function to be differentiated can be any of the variables specified as `COEFFICIENT` in the `SetHistoryOutputFields` functions of the flow output classes. To get the derivative, one just needs to write D_< string group name > in the `HISTORY_OUTPUT` field from the config file. Addioiniallty, the field `DIRECT_DIFF` specifies the variable to be registered as an input. In SU2 it is possible to register almost any variable. Currently SU2 has implemented the following variables:

`D_MACH` Freestream Mach number
`D_AOA` angle of attack
`D_PRESSURE` freestream pressure
`D_TEMPERATURE` freestream temperature
`D_DENSITY` freestream density
`D_TURB2LAM` freestream ratio of turbulent to laminar viscosity
`D_SIDESLIP` sideslip angle
`D_VISCOSITY` freestream laminar viscosity
`D_REYNOLDS` freestream Reynolds number
`D_DESIGN` design??
`D_YOUNG` Young's modulus
`D_POISSON` Poisson's ratio
`D_RHO` solid density (inertial)
`D_RHO_DL` density for dead loads
`D_EFIELD` electric field

The execution of this capability is done by the module `SU2_CFD_DIRECTDIFF`. See the [Software Components](/docs_v7/Software-Components/) for further details.

## Adjoint Formulations ##

### Discrete adjoint ###

SU2 can compute the sensitivities of an objective function with respect to the control points defining the shape of the design surface. For the detailed list of available objective functions in SU2 we address to the enumeration declaration ['ENUM_OBJECTIVE'](https://github.com/su2code/SU2/blob/42d157143f6d11fc7393c17fd4b6bb8ade30ce6b/Common/include/option_structure.hpp#L1536). The associated nomenclature for the configuration file is specified in ['Objective_Map'](https://github.com/su2code/SU2/blob/42d157143f6d11fc7393c17fd4b6bb8ade30ce6b/Common/include/option_structure.hpp#L1581)

The objective function value can be scaled by a weighting factor. This value can be specified in the `OBJECTIVE_WEIGHT` field on the config file.

### Continuous adjoint ###

Same as the discrete adjoint but using the continuous adjoint approach :)

Every solver has its specific options and we refer to the tutorial cases for more information. However, the basic controls detailed in the remainder of this page are the same for all problems.

## Restarting the simulation ##

| Solver | Version |
| --- | --- |
| `ALL`| 7.0.0 |
| `ALL`| 7.3.1 |

A simulation can be restarted from a previous computation by setting `RESTART_SOL=YES`. If it is a time-dependent problem, additionally `RESTART_ITER` must be set to the time iteration index you want to restart from:
A simulation can be restarted from a previous computation by setting `RESTART_SOL=YES`. The field data is imported from the restart file `SOLUTION_FILENAME` and must be located in the same directory. The solution file can be either a `.csv` or `.dat` file. The number of points must be the same as that for the simulation. If it is a time-dependent problem, additionally `RESTART_ITER` must be set to the time iteration index you want to restart from. For example, the following code will restart an unsteady problem from iteration number 2:

```
% ------------------------- Solver definition -------------------------------%
Expand All @@ -57,13 +162,15 @@ A simulation can be restarted from a previous computation by setting `RESTART_SO
SOLVER= EULER
%
% Restart solution (NO, YES)
RESTART_SOL= NO
RESTART_SOL= YES
%
% Iteration number to begin unsteady restarts (used if RESTART_SOL= YES)
RESTART_ITER= 0
RESTART_ITER= 2
%
```

Additionally the solution files solution_flow_00000 and solution_flow_00001, corresponding to steps or iteration 0 and 1 respectively, will be used for restarting the simulation.

<!-- ## Direct and Adjoint ##
The option `MATH_PROBLEM` defines whether the direct problem (`DIRECT`, default) or the adjoint problem should be solved. For the latter you have the choice between the continuous adjoint solver (`CONTINUOUS_ADJOINT`) or the discrete adjoint solver (`DISCRETE_ADJOINT`). Note that the discrete adjoint solver requires the `*_AD` binaries (i.e. SU2 must be [compiled](/docs_v7/Build-SU2-From-Source) with the `-Denable-autodiff=true` flag). Not all problems have a corresponding adjoint solver (yet). See below for a compatibility list:

Expand All @@ -86,7 +193,7 @@ The option `MATH_PROBLEM` defines whether the direct problem (`DIRECT`, default)

| Solver | Version |
| --- | --- |
| `ALL`| 7.0.0 |
| `ALL`| 7.3.1 |

A simulation is controlled by setting the number of iterations the solver should run (or by setting a convergence critera). The picture below depicts the two types of iterations we consider.

Expand All @@ -95,11 +202,21 @@ A simulation is controlled by setting the number of iterations the solver should

SU2 makes use of an outer time loop to march through the physical time, and of an inner loop which is usually a pseudo-time iteration or a (quasi-)Newton scheme. The actual method used depends again on the specific type of solver.

## Courant-Friedrichs-Lewy number ##

The Courant-Friedrichs-Lewy number is specified by the `CFL_NUMBER` parameter. It is possible to adapt locally its magnitude on each pseudo-iteration according to the solver residual convergence. To enable this capability, the `CFL_ADAPT` must be set to `YES`.

The option `CFL_ADAPT_PARAM` controls the adaptative CFL number, which parameters are: factor-down, factor-up, CFL min value, CFL max value and acceptable linear solver convergence.

If an adaptative CFL number is used, the initial CFL number for the finest grid is set to <CFL min value>. The local CFL number increases by <factor-up> until <CFL max value> if the solution rate of change is not limited, and acceptable linear convergence is achieved. It is reduced by <factor-down> if rate is limited, there is not enough linear convergence, or the nonlinear residuals are stagnant and oscillatory. It is reset back to <CFL min value> when linear solvers diverge, or if nonlinear residuals increase too much.

No idea about the acceptable <linear solver convergence> parameter?

## Time-dependent Simulation ##

| Solver | Version |
| --- | --- |
| `ALL`| 7.0.0 |
| `ALL`| 7.3.1 |

To enable a time-dependent simulation set the option `TIME_DOMAIN` to `YES` (default is `NO`). There are different methods available for certain solvers which can be set using the `TIME_MARCHING` option. For example for any of the FVM-type solvers a first or second-order dual-time stepping (`DUAL_TIME_STEPPING-1ST_ORDER`/`DUAL_TIME_STEPPING-2ND_ORDER`) method or a conventional time-stepping method (`TIME_STEPPING`) can be used.

Expand Down Expand Up @@ -128,7 +245,7 @@ The solver will stop either when it reaches the maximum time (`MAX_TIME`) or the

| Solver | Version |
| --- | --- |
| `ALL`| 7.0.0 |
| `ALL`| 7.3.1 |

A steady-state simulation is defined by using `TIME_DOMAIN=NO`, which is the default value if the option is not present. In this case the number of iterations is controlled by the option `ITER`.

Expand All @@ -138,7 +255,7 @@ A steady-state simulation is defined by using `TIME_DOMAIN=NO`, which is the def

| Solver | Version |
| --- | --- |
| `ALL`| 7.0.0 |
| `ALL`| 7.3.1 |

Despite setting the maximum number of iterations, it is possible to use a convergence criterion so that the solver will stop when it reaches a certain value of a residual or if variations of a coefficient are below a certain threshold. To enable a convergence criterion use the option `CONV_FIELD` to set an output field that should be monitored. The list of possible fields depends on the solver. Take a look at [Custom Output](/docs_v7/Custom-Output/) to learn more about output fields. Depending on the type of field (residual or coefficient) there are two types of methods:

Expand Down