> For the complete documentation index, see [llms.txt](https://docs.gasflow-mpi.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.gasflow-mpi.com/3.-brief-user-guide/3.6.-numerical-control.md).

# 3.6. Numerical Control

## 3.6.1. General Setting

Function: Defining the physical problem time limit, computational time limit and maximum number of cycles.

<figure><img src="https://4265438985-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FdhqtzdFGgZTppLdxTCcJ%2Fuploads%2Fgit-blob-f8357deb7d4d1b7a3696faeafa652ab48b51eedd%2FImmagine%202022-07-04%20134302.png?alt=media" alt=""><figcaption></figcaption></figure>

## 3.6.1. Pressure Iteration

**Function:** Defining parameters for controlling the iteration of the pressure Elliptic equation.

The numerical algorithm used in GASFLOW-MPI for solving the coupled fluid mass, momentum, and energy equations includes an implicit pressure iteration phase, which enables the code to simulate compressible flows without the computational time step being limited by the speed of sound. The implicit, iterative calculation is the solution of matrix equations arising from discretization of Poisson-type pressure equations by the linear solvers in PETSc library. The algorithm is constructed such that the true solution is obtained after a finite number of iterations. We have to specify certain error acceptance criteria to terminate the iteration procedure and move on to the next calculation phase.

**Note** that the matrix solution has to be performed at each time cycle, so it is important to keep the iteration numbers reasonably low for complex, long transient problems.

The accuracy of an iterative solution is indicated by a residual vector r, which would be zero if the solution is exact. In GASFLOW-MPI, the iteration will stop if all the components in r are less than a specified error value.

The code provides the following input variable in NAMELIST group xput:

**epsi0** Initial value of ε. Default =1e-5.

the user can specify the maximum number of iterations after which the iteration stops and the calculation continues, regardless of whether the current matrix solution satisfies the convergence criterion. This is done via the following variable in NAMELIST group xput:

**itmax** Maximum number of iterations (per time cycle) allowed. Default = 1000.

The code prints out iteration and time-step information for each time cycle to a file called cyclinfo.

<figure><img src="https://4265438985-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FdhqtzdFGgZTppLdxTCcJ%2Fuploads%2Fgit-blob-474f919d406d11f3c3c89e5c74e1aa389b562c07%2FImmagine%202022-07-04%20145949.png?alt=media" alt=""><figcaption></figcaption></figure>

Where PITER is the number of pressure iterations that have been carried out. DMAX is the largest component in the residual vector **r**.

<figure><img src="https://4265438985-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FdhqtzdFGgZTppLdxTCcJ%2Fuploads%2Fgit-blob-c4ab28ba056b0664eeee6e372b4f44bed8366f7f%2FImmagine%202022-07-04%20150508.png?alt=media" alt=""><figcaption></figcaption></figure>

## 3.6.2. Time-Step Control

**Function**: Defining parameters for controlling the time step during the calculation. Because GASFLOW-MPI solves the time-dependent conservation equations, a calculation proceeds in finite time steps (also called cycles) until the problem end time or the specified maximum number of cycles has been reached.

The end time and maximum number of cycles are defined by the following input variables (all variables discussed in this section are in NAMELIST group xput):

**twfin** Time (s) at which the problem is finished. Default = 10.

**maxcyc** Maximum allowable number of cycles. Default = 10.

How fast a problem can be completed depends on the time-step size Δt chosen. The initial, minimum, and maximum values of Δt to be used are defined with the following input variables:

**delt0** Beginning time step size (s). Default = 0.02.

**deltmin** Minimum time step size (s). Default = 1e–4.

**deltmax** Maximum time step size (s). Default = 1e30.

**cflnum** Maximum CFL number for convection

**cfldiff** Maximum CFL number for diffusion

**autot**=0 Fixed time steps

**autot**=1 Automatic Control

**itdowdt** Increase time step size at lower iterations

**itupdt** Decrease time step size at upper iterations

![](https://4265438985-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FdhqtzdFGgZTppLdxTCcJ%2Fuploads%2Fgit-blob-1b1e1dd0114ef4bc56c529695a9bf6c8ef291550%2Fimage.png?alt=media)

The maximum and minimum values are used to define a range within which Δt can be varied during the calculation.

An example is shown here for the maximum time step, deltmax, as it is read in the NAMELIST XPUT:

![](https://4265438985-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FdhqtzdFGgZTppLdxTCcJ%2Fuploads%2Fgit-blob-ca1b4b63b8a8a2dd265fc9b2241630161100355e%2FImmagine%202022-07-04%20161238.png?alt=media)

For this example, the maximum time step is held constant at 0.5 s for (0 <= time < 10000), 0.6 s for (0 <= time < 20000), and so on.

<figure><img src="https://4265438985-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FdhqtzdFGgZTppLdxTCcJ%2Fuploads%2Fgit-blob-72b88675f2d952b9cde1b606af7ced52d161ccc3%2FImmagine%202022-07-04%20161343.png?alt=media" alt=""><figcaption></figcaption></figure>

Note that we’ve added a small amount of time, 0.1 seconds, to all the even entries in **deltmax**. This insures that the maximum time step allowed is updated at the requested time.

The numerical method used in GASFLOW-MPI treats most physical processes implicitly in time, except the advection and diffusion terms. Explicit treatment of these terms leads to the fact that the solution procedure is only stable if the time-step size Δt satisfies both the Courant criterion and the diffusion limit. To ensure numerical stability, the code limits Δt as follows:

![](https://4265438985-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FdhqtzdFGgZTppLdxTCcJ%2Fuploads%2Fgit-blob-716a523822accf79b085cfb6385d202fc0d8ff57%2FImmagine%202022-07-05%20092613.png?alt=media)

In GASFLOW-MPI, we have the option for users to define the maximum CFL number using cflnum and cfldiff for Courant and diffusion limit. The default values of **cflnum** and **cfldiff** are 0.25 which is also used in GASFLOW serial version. The user could increase **cflnum** and **cfldiff** (< 0.99) to allow a bigger time step.

The change of internal energy in each cell in one time step should not exceed the limit, **relde**. The default of **relde** is 0.2 meaning 20% of the internal energy in each cell is allowed to change in one time step.

GASFLOW by default will try to adjust Δt to achieve maximum efficiency while satisfying the stability limits. The code increases or decreases Δt for the next computational cycle according to the number of pressure iterations required for convergence in the current cycle.

If the user wants a fixed time-step size, the following input variable should be specified:

**autot** Option flag for automatic control of time-step size Δt

* 1.0 means Δt is adjusted by code during calculation (default);
* 0.0 means the input delt0 is used for Δt thoughout calculation.

## 3.6.3. Advection Scheme

**Function**: Options for discretize the convective flux term in each conservation equations ∇(ϕ•**u**), where ϕ is the conserved quantity (mass density, internal energy, or momentum) and **u** is the velocity vector.

There are two numerical method:

* **Donor-cell scheme** (default): first-order method, simple and fast and does not suffer from the spurious oscillations caused by some higher-order scheme. But, the solution obtained has larger numerical diffusion error then those given by higher-order scheme.
* Van Leer scheme: second order method, slope-limiting method that has the monotone property.

This can be done via the following input variable in NAMELIST group xput **ifvl**.

<figure><img src="https://4265438985-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FdhqtzdFGgZTppLdxTCcJ%2Fuploads%2Fgit-blob-ec045dab206eb7f43f12312f074f8c8c1d75f8cc%2FImmagine%202022-07-05%20104554.png?alt=media" alt=""><figcaption></figcaption></figure>

## 3.6.4. Control of Time Interval Variables

There are certain input array variables that provide time-dependent control of the maximum time step, **deltmax**, the maximum CFL number, **cflnum**, the plotting time, **pltdt**, the printing time, **prtdt**, the restart dump and 3D visualization time, **tddt**, and the plotting time history time, **thdt**. These variables have been extended to arrays with maximum number of elements equaling 20, and are shown here:

**deltmax**(1:20) maximum allowed time step (NAMELIST xput).

**cflnum**(1:20) maximum allowed CFL number (NAMELIST xput).

**pltdt**(1:20) plotting time interval to file profiles.nc (NAMELIST xput).

**prtdt**(1:20) printing time interval to file gfout (NAMELIST xput).

**tddt**(1:20) restart dump and 3D visualization time interval to file gfd\*.nc (NAMELIST xput).

**thdt**(1:20) time-history plotting time interval to file plothist.nc (NAMELIST grafic).

When there is only one entry in the above variable arrays, it is treated as a scalar constant, but when there are multiple entries, they are associated in pairs with the odd elements representing the time interval or time step and the even elements representing the upper time limit for that particular time interval or time step.

If the current time exceeds the last time specified in the array **deltmax**, the last maximum time step size will be held for the remaining simulation time up to **twfin**. This holds true for all the other variables list above as well.

**Example.**

![](https://4265438985-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FdhqtzdFGgZTppLdxTCcJ%2Fuploads%2Fgit-blob-f4608ff20d7598ea8a7f1308b5843f11e1b1fb1b%2FImmagine%202022-07-05%20113712.png?alt=media)

How many dumps will be generated up to 50 seconds? 3 up to 2 seconds (at\~0.5 s, \~1.0 s, \~1.5 s) and 4 up to 50(at \~11.5 s, \~21.5 s, \~31.5 s, 41.5 s). Why only three up to 2 s? Because the first output is done at time≥0.5 s. The time step will rarely hit 0.5 seconds exactly. Therefore the first input is somewhat delayed. At times> 2 s, the new interval(10 seconds) is already active.

If the user wants a restart dump at approximately 0.5, 1.0, 1.5, 2,0, 12,0, 22.0, 32.0, and 42.0 s, then the easiest way would be to add a small amount to the interval. In the above case, one could use:

![](https://4265438985-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FdhqtzdFGgZTppLdxTCcJ%2Fuploads%2Fgit-blob-b674c8a760ba090f5efcdabc75b5acdfb86c5abb%2FImmagine%202022-07-05%20114541.png?alt=media)

and this would insure that the interval 2.0 is reached before the increment is updated.

**Example.**

![](https://4265438985-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FdhqtzdFGgZTppLdxTCcJ%2Fuploads%2Fgit-blob-65c68136faf1040718ac88f8161ec4961a3049a9%2FImmagine%202022-07-05%20114736.png?alt=media)

<figure><img src="https://4265438985-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FdhqtzdFGgZTppLdxTCcJ%2Fuploads%2Fgit-blob-f0f812e378574050793e9f685306acc0329c1c5e%2FImmagine%202022-07-05%20115403.png?alt=media" alt=""><figcaption></figcaption></figure>

**pltdt** and **prtdt** can be controlled in a similar fashion.
