Neko 1.99.1
A portable framework for high-order spectral element flow simulations
Loading...
Searching...
No Matches
Statistics guide

Statistics in the context of Neko, is the common name for fields that are averaged in time and possible also space.

The statistics module in Neko computes the temporal average of a wide range of fields.

In this page we use the following convention for a field

  • \( u \), the instantaneous field.
  • \( \langle u \rangle_t \), the temporal average of \( u \).
  • \( u = \langle u \rangle + u' \), the Reynolds decomposition of \( u \), where \( u' \) is the fluctuation of \( u \) around the mean field.

The temporal average of a field \(u\) is the approximation of the integral

$$ \langle u \rangle_t = \int_{T_0}^{T_N} u dt $$

In Neko, this is computed as

$$ \langle u \rangle_t = \sum_{i=0}^N u_i \Delta t_i $$ where \( u_0 \) is the fields value at \( T_0 \) and \( N \) is the number of time steps needed to reach \( T_N \), \( T_N = T_0 + \sum_{i=0}^N \Delta t_i \).

Fluid Statistics

In the fluid statistics in Neko, various averages of the different velocity components, derivatives and pressure are computed. In total, 44 "raw statistics" are computed that are required to compute the Reynolds stress budgets, mean fields, and the different terms in the turbulent kinetic energy equation.

Using statistics

Statistics are enabled in the case file as a simcomp with the added argument avg_direction, set_of_stats, and start_time:

Name Description Admissible values Default value
start_time Time at which to start gathering statistics. Positive real 0
avg_direction Directions to compute spatial average. x,y,z,xy,xz,yz No spatial average
set_of_stats What set of stats to compute. basic, full full
compute_value Interval, in timesteps or simulationtime, depending on compute_control, for sampling the flow fields for statistics. Positive real or int Not set (but recommended with every 50 timesteps or so
output_filename User-specified filename to store output in. filename fluid_statsX*

*The name of the written statistics file will by default be fluid_statsX0.f0000X,..., fluid_statsX0.f0000Y where X is the number of the first outputted statistic of the current run.

In addition, one can specify the usual controls for the output, which then outputs the averages computes from the last time the statistics were written to file. For example, if one wants to compute only the basic statistics and sample the fields every 4 time steps and compute and output batches every 20 time units and have an initial transient of 60 time units the following would work:

"simulation_components":
[
{
"type": "fluid_stats",
"compute_control": "tsteps",
"compute_value": 4,
"output_control": "simulationtime",
"output_value": 20,
"start_time":60.0,
"avg_direction":"xz",
"set_of_stats":"basic"
}
]
Attention
For simulations requiring restarts, it is recommended to run each restart in a different output directory as a precaution to avoid potential overwritings of files.

Preferably set the initial transient to a multiple of output_value as otherwise the first output will be slightly shorter than the rest. The code related to fluid statistics are located in fluid_stats and fluid_stats_simcomp.

The argument "avg_direction" is optional and if ignored we output 3d fields. The statistics are saved in a fld file according to the following in 2D and 3D. Observe that in 2D the mean Z-velocity is stored in a last scalar field. All other fields are kept the same. This is due to a limitation of the fld file format.

For 1D statistics a CSV file is outputted. The first column is the time at which the statistics are collected, the second column the spatial coordinate, and the rest of the data is stored in the order below. In this case all statistics are kept in the same order as in 3D. The name for these files are fluid_statsX.csv,..., fluid_statsX.csv where X is the number of the first outputted statistic of the current run.

List of fields in output files

When only the basic set of stats is enabled, only stats 1-11 are computed. When 2D stats are enabled \( \langle w \rangle \) is stored in s7 for basic stats and in s40 for the full set of statistics.

Number Statistic Stored in variable (for fld files)
1 \( \langle p \rangle \) Pressure
2 \( \langle u \rangle \) X-Velocity
3 \( \langle v \rangle \) Y-Velocity
4 \( \langle w \rangle \) Z-Velocity
5 \( \langle pp \rangle \) Scalar 1 (s1)
6 \( \langle uu \rangle \) Scalar 2 (s2)
7 \( \langle vv \rangle \) s3
8 \( \langle ww \rangle \) s4
9 \( \langle uv \rangle \) s5
10 \( \langle uw \rangle \) s6
11 \( \langle vw \rangle \) s7
12 \( \langle uuu \rangle \) s8
13 \( \langle vvv \rangle \) s9
14 \( \langle www \rangle \) s10
15 \( \langle uuv \rangle \) s11
16 \( \langle uuw \rangle \) s12
17 \( \langle uvv \rangle \) s13
18 \( \langle uvw \rangle \) s14
19 \( \langle vvw \rangle \) s15
20 \( \langle uww \rangle \) s16
21 \( \langle vww \rangle \) s17
22 \( \langle uuuu \rangle \) s18
23 \( \langle vvvv \rangle \) s19
24 \( \langle wwww \rangle \) s20
25 \( \langle ppp \rangle \) s21
26 \( \langle pppp \rangle \) s22
27 \( \langle pu \rangle \) s23
28 \( \langle pv \rangle \) s24
29 \( \langle pw \rangle \) s25
30 \( \langle p \frac{\partial u} {\partial x} \rangle \) s26
31 \( \langle p \frac{\partial u} {\partial y}\rangle \) s27
32 \( \langle p \frac{\partial u} {\partial z}\rangle \) s28
33 \( \langle p \frac{\partial v} {\partial x}\rangle \) s29
34 \( \langle p \frac{\partial v} {\partial y}\rangle \) s30
35 \( \langle p \frac{\partial v} {\partial z}\rangle \) s31
36 \( \langle p \frac{\partial w} {\partial x}\rangle \) s32
37 \( \langle p \frac{\partial w} {\partial y}\rangle \) s33
38 \( \langle p \frac{\partial w} {\partial z}\rangle \) s34
39 \( \langle e11 \rangle \) s35
40 \( \langle e22 \rangle \) s36
41 \( \langle e33 \rangle \) s37
42 \( \langle e12 \rangle \) s38
43 \( \langle e13 \rangle \) s39
44 \( \langle e23 \rangle \) s40

where \(e11,e22...\) is computed as: $$ \begin{aligned} e11 &= \left(\frac{\partial u}{\partial x}\right)^2 + \left(\frac{\partial u}{\partial y}\right)^2 + \left(\frac{\partial u}{\partial z}\right)^2 \\ e22 &= \left(\frac{\partial v}{\partial x}\right)^2 + \left(\frac{\partial v}{\partial y}\right)^2 + \left(\frac{\partial v}{\partial z}\right)^2 \\ e33 &= \left(\frac{\partial w}{\partial x}\right)^2 + \left(\frac{\partial w}{\partial y}\right)^2 + \left(\frac{\partial w}{\partial z}\right)^2 \\ e12 &= \frac{\partial u}{\partial x} \frac{\partial v}{\partial x} + \frac{\partial u}{\partial y}\frac{\partial v}{\partial y}+ \frac{\partial u}{\partial z}\frac{\partial v}{\partial z} \\ e13 &= \frac{\partial u}{\partial x} \frac{\partial w}{\partial x} + \frac{\partial u}{\partial y}\frac{\partial w}{\partial y}+ \frac{\partial u}{\partial z}\frac{\partial w}{\partial z} \\ e23 &= \frac{\partial v}{\partial x} \frac{\partial w}{\partial x} + \frac{\partial v}{\partial y}\frac{\partial w}{\partial y}+ \frac{\partial v}{\partial z}\frac{\partial w}{\partial z} \\ \end{aligned} $$

Postprocessing

These statistics are only the "raw statistics" in the sense that in general we are not interested in \( \langle uu\rangle \), but rather say \( \langle u'u'\rangle\). For this we need to postprocess the statistics.

There is some rudimentary postprocessing to compute the spatial averages of fld files and also to combine the statistics collected from several runs (compute average in time) and also compute both the mean velocity gradient and the Reynolds stresses available in the contrib scripts. By running the contrib scripts without any arguments one gets a hint on their usage, (e.g. by running ./average_fields_in_time will give the options).

To further postprocess the statistics it is suggested to look into PyNekTools which introduces convenient functions for postprocessing, largely based on the PyMech library with the addition of an expanding set of tools for interpolation, computing derivatives and more advanced functionality. PyNekTools is entirely parallelized in MPI and can also handle large data sets for postprocessing.

Scalar Statistics

In the scalar statistics in Neko, various averages of a given scalar and the different velocity components, derivatives and pressure are computed, in a similar fashion to the fluid statistics. In total, 42 "raw statistics" are computed that are required to compute the mean scalar transport equation, skewness and kurtosis, as well as the scalar variance budget, and turbulent scalar flux budgets.

Using statistics

Similar to fluid statistics, scalar statistics are enabled in the case file as a simcomp with an additional argument field for the name of the scalar field to be averaged:

Name Description Admissible values Default value
field Name of the scalar field to be averaged String s
start_time Time at which to start gathering statistics. Positive real 0
avg_direction Directions to compute spatial average. x,y,z,xy,xz,yz No spatial average
set_of_stats What set of stats to compute. basic, full full
compute_value Interval, in timesteps or simulationtime, depending on compute_control, for sampling the flow fields for statistics. Positive real or int Not set (but recommended with every 50 timesteps or so)
output_filename User-specified filename to store output in. filename fluid_statsX*

*The name of the written statistics file will by default be scalar_statsX0.f0000X,..., scalar_statsX0.f0000Y where X is the number of the first outputted statistic of the current run. Note that if you want to compute statistics for multiple scalars, you will need to specify an independent output_filename for each.

In addition, one can specify the usual controls for the output, in the same manner as for fluid statistics. For example, if one wants to compute only the basic statistics and sample the fields every 4 time steps and compute and output batches every 20 time units and have an initial transient of 60 time units the following would work:

"simulation_components":
[
{
"type": "scalar_stats",
"field": "s",
"compute_control": "tsteps",
"compute_value": 4,
"output_control": "simulationtime",
"output_value": 20,
"start_time": 60.0,
"avg_direction":"xz",
"set_of_stats":"basic"
}
]

List of fields in output files

When only the basic set of stats is enabled, only stats 1-5 are computed.

Number Statistic Stored in variable (for fld files)
1 \( \langle s \rangle \) Pressure
2 \( \langle us \rangle \) X-Velocity
3 \( \langle vs \rangle \) Y-Velocity
4 \( \langle ws \rangle \) Z-Velocity
5 \( \langle ss \rangle \) Scalar 1 (s1)
6 \( \langle sss \rangle \) Scalar 2 (s2)
7 \( \langle ssss \rangle \) s3
8 \( \langle uss \rangle \) s4
9 \( \langle vss \rangle \) s5
10 \( \langle wss \rangle \) s6
11 \( \langle uus \rangle \) s7
12 \( \langle vvs \rangle \) s8
13 \( \langle wws \rangle \) s9
14 \( \langle uvs \rangle \) s10
15 \( \langle uws \rangle \) s11
16 \( \langle vws \rangle \) s12
17 \( \langle ps \rangle \) s13
18 \( \langle p \frac{\partial s}{\partial x} \rangle \) s14
19 \( \langle p \frac{\partial s}{\partial y} \rangle \) s15
20 \( \langle p \frac{\partial s}{\partial z} \rangle \) s16
21 \( \langle u \frac{\partial s}{\partial x} \rangle \) s17
22 \( \langle u \frac{\partial s}{\partial y} \rangle \) s18
23 \( \langle u \frac{\partial s}{\partial z} \rangle \) s19
24 \( \langle v \frac{\partial s}{\partial x} \rangle \) s20
25 \( \langle v \frac{\partial s}{\partial y} \rangle \) s21
26 \( \langle v \frac{\partial s}{\partial z} \rangle \) s22
27 \( \langle w \frac{\partial s}{\partial x} \rangle \) s23
28 \( \langle w \frac{\partial s}{\partial y} \rangle \) s24
29 \( \langle w \frac{\partial s}{\partial z} \rangle \) s25
30 \( \langle s \frac{\partial u}{\partial x} \rangle \) s26
31 \( \langle s \frac{\partial u}{\partial y} \rangle \) s27
32 \( \langle s \frac{\partial u}{\partial z} \rangle \) s28
33 \( \langle s \frac{\partial v}{\partial x} \rangle \) s29
34 \( \langle s \frac{\partial v}{\partial x} \rangle \) s30
35 \( \langle s \frac{\partial v}{\partial x} \rangle \) s31
36 \( \langle s \frac{\partial w}{\partial x} \rangle \) s32
37 \( \langle s \frac{\partial w}{\partial x} \rangle \) s33
38 \( \langle s \frac{\partial w}{\partial x} \rangle \) s34
39 \( \langle e_{ss} \rangle \) s35
40 \( \langle e_{us} \rangle \) s36
41 \( \langle e_{vs} \rangle \) s37
42 \( \langle e_{ws} \rangle \) s38

where \(e_{ss}, e_{us}, e_{vs}, e_{ws}\) are computed as: $$ \begin{aligned} e_{ss} &= \left(\frac{\partial s}{\partial x}\right)^2 + \left(\frac{\partial s}{\partial y}\right)^2 + \left(\frac{\partial s}{\partial z}\right)^2 \\ e_{us} &= \frac{\partial u}{\partial x} \frac{\partial s}{\partial x} + \frac{\partial u}{\partial y}\frac{\partial s}{\partial y}+ \frac{\partial u}{\partial z}\frac{\partial s}{\partial z} \\ e_{vs} &= \frac{\partial v}{\partial x} \frac{\partial s}{\partial x} + \frac{\partial v}{\partial y}\frac{\partial s}{\partial y}+ \frac{\partial v}{\partial z}\frac{\partial s}{\partial z} \\ e_{ws} &= \frac{\partial w}{\partial x} \frac{\partial s}{\partial x} + \frac{\partial w}{\partial y}\frac{\partial s}{\partial y}+ \frac{\partial w}{\partial z}\frac{\partial s}{\partial z} \\ \end{aligned} $$