Skip to main content

KRATOS Multiphysics ("Kratos") is a framework for building parallel, multi-disciplinary simulation software, aiming at modularity, extensibility, and high performance. Kratos is written in C++, and counts with an extensive Python interface.

Project description

Statistics Application

Statistics application consist of widely used methods to calculate statistics in various containers of KratosMultiphysics. There are mainly two groups of statistical methods namely Spatial and Temporal. Spatial methods calculate statistics on spatial containers and output the values whenever they are called. Temporal methods calculate statistics on the fly in a transient simulation. All the temporal methods gurantee that, the resultant statistics will be same as the ones if one calculates accumulating all the data upto that time instance and calculate the same statistics. All of these methods in each group is OpenMP and MPI compatible, and tested.

Following table summarize capabilities of Statistics Application.

Statistical Methods Norm Types Spatial Domain Temporal Domain Data types
Sum Value Spatial methods Temporal methods Double
Mean Magnitude Spatial containers Temporal containers Array 3D
Root mean square Euclidean nodal_historical nodal_historical_historical Vector
Variance Infinity nodal_non_historical nodal_historical_non_historical Matrix
Min P-Norm condition_non_historical nodal_non_historical
Max Lpq-Norm element_non_historical element_non_historical
Median Frobenius Spatial statistics process condition_non_historical
Distribution Trace Temporal statistics process
Norm methods Index
Component

JSON Examples

If you prefer to use statistics of a simulation using StatisticsApplication, there is spatial_statistics_process for spatial statistics calculations and temporal_statistics_process for temporal statistics. These processes can be included via JSON settings under auxiliary_processes.

Spatial statistics process examples

Following example illustrates different methods used in different containers with different norms. input_variable_settings holds an array of methods for specified containers, specified norm and specified variables. They can be customized for your requirement. output_settings holds information about how the output should be handled.

{
                "kratos_module" : "KratosMultiphysics.StatisticsApplication",
                "python_module" : "spatial_statistics_process",
                "Parameters" : {
                    "model_part_name" : "test_model_part",
                    "input_variable_settings" : [
                        {
                            "method_name"    : "sum",
                            "norm_type"      : "none",
                            "container"      : "nodal_historical",
                            "variable_names" : ["PRESSURE", "VELOCITY"],
                            "method_settings": {}
                        },
                        {
                            "method_name"    : "mean",
                            "norm_type"      : "none",
                            "container"      : "nodal_non_historical",
                            "variable_names" : ["PRESSURE", "VELOCITY"],
                            "method_settings": {}
                        },
                        {
                            "method_name"    : "variance",
                            "norm_type"      : "none",
                            "container"      : "element_non_historical",
                            "variable_names" : ["PRESSURE", "VELOCITY"],
                            "method_settings": {}
                        },
                        {
                            "method_name"    : "rootmeansquare",
                            "norm_type"      : "none",
                            "container"      : "condition_non_historical",
                            "variable_names" : ["PRESSURE", "VELOCITY"],
                            "method_settings": {}
                        },
                        {
                            "method_name"    : "sum",
                            "norm_type"      : "magnitude",
                            "container"      : "nodal_historical",
                            "variable_names" : ["PRESSURE", "VELOCITY", "LOAD_MESHES", "GREEN_LAGRANGE_STRAIN_TENSOR"],
                            "method_settings": {}
                        },
                        {
                            "method_name"    : "mean",
                            "norm_type"      : "pnorm_2.5",
                            "container"      : "nodal_non_historical",
                            "variable_names" : ["VELOCITY", "LOAD_MESHES", "GREEN_LAGRANGE_STRAIN_TENSOR"],
                            "method_settings": {}
                        },
                        {
                            "method_name"    : "variance",
                            "norm_type"      : "component_x",
                            "container"      : "condition_non_historical",
                            "variable_names" : ["VELOCITY"],
                            "method_settings": {}
                        },
                        {
                            "method_name"    : "rootmeansquare",
                            "norm_type"      : "index_3",
                            "container"      : "nodal_non_historical",
                            "variable_names" : ["LOAD_MESHES"],
                            "method_settings": {}
                        },
                        {
                            "method_name"    : "min",
                            "norm_type"      : "frobenius",
                            "container"      : "nodal_non_historical",
                            "variable_names" : ["GREEN_LAGRANGE_STRAIN_TENSOR"],
                            "method_settings": {}
                        }
                    ],
                    "output_settings" : {
                        "output_control_variable": "STEP",
                        "output_time_interval"   : 1,
                        "write_kratos_version"   : false,
                        "write_time_stamp"       : false,
                        "output_file_settings"   : {
                            "file_name"  : "<model_part_name>_<container>_<norm_type>_<method_name>.dat",
                            "output_path": "spatial_statistics_process",
                            "write_buffer_size" : -1
                        }
                    }
                }
            }

Temporal statistics process example

Following is an example on how to use temporal_statistics_process in json. The output variables data type should be matched with the input variables order and the data type for "norm_type" = "none". If "norm_type" != "none", then output variables should be scalars. If "container" = "nodal_historical_historical" is used as the container type, then output variables should be added to NodalSolutionStepVariables list in Kratos since this container type outputs temporal statistics variables to nodal historical container. This json settings also can be added to auxiliary_processes list.

For details about all the available statistical methods, norm_types, etc, please refer to rest of the README.md file.

        {
            "kratos_module": "KratosMultiphysics.StatisticsApplication",
            "python_module": "temporal_statistics_process",
            "Parameters": {
                "model_part_name": "FluidModelPart.fluid_computational_model_part",
                "input_variable_settings": [
                    {
                        "method_name": "variance",
                        "norm_type": "none",
                        "container": "nodal_historical_non_historical",
                        "echo_level": 1,
                        "method_settings": {
                            "input_variables": [
                                "VELOCITY",
                                "PRESSURE"
                            ],
                            "output_mean_variables": [
                                "VECTOR_3D_MEAN",
                                "SCALAR_MEAN"
                            ],
                            "output_variance_variables": [
                                "VECTOR_3D_VARIANCE",
                                "SCALAR_VARIANCE"
                            ]
                        }
                    }
                ],
                "statistics_start_point_control_variable_name": "TIME",
                "statistics_start_point_control_value": 2.5
            }
        }

Method definitions

There are two types of methods under each Spatial and Temporal method groups. They are namely Value and Norm methods. In these methods, i index refers to spatial domain element index, and k index refers to time step.

Value methods

Sum

In the case of spatial domain, it adds up all the variable values for a given container and returns summed up value as shown in following equation. xi is the ith element's variable value of the corresponding container. Result will have the same type as the type of the variable specified by the user

Following is an example of summation of non historical VELOCITY over the whole model part's nodes

import KratosMultiphysics as Kratos
import KratosMultiphysics.StatisticsApplication as KratosStats
model = Kratos.Model()
model_part = model.CreateModelPart("test_model_part")
sum = KratosStats.SpatialMethods.NonHistorical.Nodes.ValueMethods.Sum(model_part, Kratos.VELOCITY)

In the case of temporal domain, Sum methods is the time integrated quantity for a specific variable. It will be stored each element under user specified variable and a user specified container. xi is the ith element's variable value of the corresponding container. Result will have the same type as the type of the variable specified by the user.

Following is an example of integration calculation of non historical velocity. Input variable is node's non-historical container's VELOCITY and output variable is same containers DISPLACEMENT where integrated value will be stored for each node. The 0 represents echo level for this method object. Blank "" indicates that value method is used.

import KratosMultiphysics as Kratos
import KratosMultiphysics.StatisticsApplication as KratosStats
model = Kratos.Model()
model_part = model.CreateModelPart("test_model_part")
sum_method = KratosStats.TemporalMethods.NonHistorical.Nodes.ValueMethods.Sum.Array(model_part, "", Kratos.VELOCITY, 0, Kratos.DISPLACEMENT)
integration_starting_time = 2.0
sum_method.InitializeStatisticsMethod(integration_starting_time)
for t in range(3, 6):
    sum_method.CalculateStatistics()

Mean

In the case of spatial domain, it calculates mean of a given variable for a given container and returns it as shown in following equation. xi is the ith element's variable value of the corresponding container. Result will have the same type as the type of the variable specified by the user. (If it has higher dimension than a scalar, mean of each dimension will be calculated seperately resulting with a mean having same dimension as the input dimension)

Following is an example of mean calculation of non historical VELOCITY over the whole model part's nodes

import KratosMultiphysics as Kratos
import KratosMultiphysics.StatisticsApplication as KratosStats
model = Kratos.Model()
model_part = model.CreateModelPart("test_model_part")
mean = KratosStats.SpatialMethods.NonHistorical.Nodes.ValueMethods.Mean(model_part, Kratos.VELOCITY)

In the case of temporal domain, Mean methods is the time integrated quantity's mean for a specific variable. It will be stored each element under user specified variable and a user specified container. xi is the ith element's variable value of the corresponding container. Result will have the same type as the type of the variable specified by the user preserving the dimensionality as in the spatial case.

Following is an example of mean calculation of non historical velocity. Input variable is node's non-historical container's VELOCITY and output variable is same containers VECTOR_3D_MEAN where mean will be stored for each node. The 0 represents echo level for this method object. Blank "" indicates that value method is used.

import KratosMultiphysics as Kratos
import KratosMultiphysics.StatisticsApplication as KratosStats
model = Kratos.Model()
model_part = model.CreateModelPart("test_model_part")
mean_method = KratosStats.TemporalMethods.NonHistorical.Nodes.ValueMethods.Mean.Array(model_part, "", Kratos.VELOCITY, 0, KratosStats.VECTOR_3D_MEAN)
integration_starting_time = 2.0
mean_method.InitializeStatisticsMethod(integration_starting_time)
for t in range(3, 6):
    mean_method.CalculateStatistics()

Root mean square

In the case of spatial domain, it calculates root mean square of a given variable for a given container and returns it as shown in following equation. xi is the ith element's variable value of the corresponding container. Result will have the same type as the type of the variable specified by the user. (If it has higher dimension than a scalar, root mean square of each dimension will be calculated seperately resulting with a mean having same dimension as the input dimension)

Following is an example of root mean square calculation of non historical VELOCITY over the whole model part's nodes

import KratosMultiphysics as Kratos
import KratosMultiphysics.StatisticsApplication as KratosStats
model = Kratos.Model()
model_part = model.CreateModelPart("test_model_part")
rms = KratosStats.SpatialMethods.NonHistorical.Nodes.ValueMethods.RootMeanSquare(model_part, Kratos.VELOCITY)

In the case of temporal domain, Root Mean Square methods is the time integrated quantity's root mean square for a specific variable. It will be stored each element under user specified variable and a user specified container. xi is the ith element's variable value of the corresponding container. Result will have the same type as the type of the variable specified by the user preserving the dimensionality as in the spatial case.

Following is an example of root mean square calculation of non historical velocity. Input variable is node's non-historical container's VELOCITY and output variable is same containers VECTOR_3D_MEAN where root mean square value will be stored for each node. The 0 represents echo level for this method object. Blank "" indicates that value method is used.

import KratosMultiphysics as Kratos
import KratosMultiphysics.StatisticsApplication as KratosStats
model = Kratos.Model()
model_part = model.CreateModelPart("test_model_part")
rms_method = KratosStats.TemporalMethods.NonHistorical.Nodes.ValueMethods.RootMeanSquare.Array(model_part, "", Kratos.VELOCITY, 0, KratosStats.VECTOR_3D_MEAN)
integration_starting_time = 2.0
rms_method.InitializeStatisticsMethod(integration_starting_time)
for t in range(3, 6):
    rms_method.CalculateStatistics()

Variance

In the case of spatial domain, it calculates variance of a given variable for a given container and returns mean and variance as shown in following equations. xi is the ith element's variable value of the corresponding container. Results will have the same type as the type of the variable specified by the user. (If it has higher dimension than a scalar, mean of each dimension will be calculated seperately resulting with a mean having same dimension as the input dimension)

Following is an example of variance calculation of non historical VELOCITY over the whole model part's nodes

import KratosMultiphysics as Kratos
import KratosMultiphysics.StatisticsApplication as KratosStats
model = Kratos.Model()
model_part = model.CreateModelPart("test_model_part")
mean, variance = KratosStats.SpatialMethods.NonHistorical.Nodes.ValueMethods.Variance(model_part, Kratos.VELOCITY)

In the case of temporal domain, Variance method is the time integrated quantity's variance for a specific variable. Mean and variance will be stored each element under user specified variables and a user specified container. xi is the ith element's variable value of the corresponding container. Results will have the same type as the type of the variable specified by the user preserving the dimensionality as in the spatial case.

Following is an example of root mean square calculation of non historical velocity. Input variable is node's non-historical container's VELOCITY and output variable VECTOR_3D_MEAN will store mean and VECTOR_3D_VARIANCE will store variance in same container for each node. The 0 represents echo level for this method object. Blank "" indicates that value method is used.

import KratosMultiphysics as Kratos
import KratosMultiphysics.StatisticsApplication as KratosStats
model = Kratos.Model()
model_part = model.CreateModelPart("test_model_part")
variance_method = KratosStats.TemporalMethods.NonHistorical.Nodes.ValueMethods.Variance.Array(model_part, "", Kratos.VELOCITY, 0, KratosStats.VECTOR_3D_MEAN, KratosStats.VECTOR_3D_VARIANCE)
integration_starting_time = 2.0
variance_method.InitializeStatisticsMethod(integration_starting_time)
for t in range(3, 6):
    variance_method.CalculateStatistics()

Min

In the case of spatial domain, it returns minimum of a given variable's norm for a given container, and the corresponding items id. xi is the ith element's variable value of the corresponding container. Results will be double and integer, irrespective of the input type, since higher dimensional variable types will be reduced to scalars by the use of norms.

Following is an example of min method of non historical VELOCITY's magnitude over the whole model part's nodes. It returns a tuple, first argument being the minimum, and the second argument being the id of the node where the minimum is found.

import KratosMultiphysics as Kratos
import KratosMultiphysics.StatisticsApplication as KratosStats
model = Kratos.Model()
model_part = model.CreateModelPart("test_model_part")
min_value, min_id = KratosStats.SpatialMethods.NonHistorical.Nodes.NormMethods.Min(model_part, Kratos.VELOCITY, "magnitude")

In the case of temporal domain, Min method returns minimum value in the temporal domain, and the time minimum is found. Minimum and its occurring time will be stored each element under user specified variables and a user specified container. xk is the kth time step element's variable value of the corresponding container. Results will have the same type as the type of the variable specified by the user preserving the dimensionality as in the spatial case.

Following is an example of min method in non historical velocity. Input variable is node's non-historical container's VELOCITY and output variable VECTOR_3D_NORM will store minimum and TIME will store the time minimum occured for each node. The 0 represents echo level for this method object. "magnitude" indicates that magnitude norm is used.

import KratosMultiphysics as Kratos
import KratosMultiphysics.StatisticsApplication as KratosStats
model = Kratos.Model()
model_part = model.CreateModelPart("test_model_part")
min_method = KratosStats.TemporalMethods.NonHistorical.Nodes.NormMethods.Min.Array(model_part, "magnitude", Kratos.VELOCITY, 0, KratosStats.VECTOR_3D_NORM, Kratos.TIME)
integration_starting_time = 2.0
min_method.InitializeStatisticsMethod(integration_starting_time)
for t in range(3, 6):
    min_method.CalculateStatistics()

Max

In the case of spatial domain, it returns maximum of a given variable's norm for a given container, and the corresponding items id. xi is the ith element's variable value of the corresponding container. Results will be double and integer, irrespective of the input type, since higher dimensional variable types will be reduced to scalars by the use of norms.

Following is an example of max method of non historical VELOCITY's magnitude over the whole model part's nodes. It returns a tuple, first argument being the maximum, and the second argument being the id of the node where the maximum is found.

import KratosMultiphysics as Kratos
import KratosMultiphysics.StatisticsApplication as KratosStats
model = Kratos.Model()
model_part = model.CreateModelPart("test_model_part")
max_value, max_id = KratosStats.SpatialMethods.NonHistorical.Nodes.NormMethods.Max(model_part, Kratos.VELOCITY, "magnitude")

In the case of temporal domain, Max method returns maximum value in the temporal domain, and the time maximum is found. Maximum and its occurring time will be stored each element under user specified variables and a user specified container. xk is the kth time step element's variable value of the corresponding container. Results will have the same type as the type of the variable specified by the user preserving the dimensionality as in the spatial case.

Following is an example of max method in non historical velocity. Input variable is node's non-historical container's VELOCITY and output variable VECTOR_3D_NORM will store maximum and TIME will store the time maximum occured for each node. The 0 represents echo level for this method object. "magnitude" indicates that magnitude norm is used.

import KratosMultiphysics as Kratos
import KratosMultiphysics.StatisticsApplication as KratosStats
model = Kratos.Model()
model_part = model.CreateModelPart("test_model_part")
max_method = KratosStats.TemporalMethods.NonHistorical.Nodes.NormMethods.Max.Array(model_part, "magnitude", Kratos.VELOCITY, 0, KratosStats.VECTOR_3D_NORM, Kratos.TIME)
integration_starting_time = 2.0
max_method.InitializeStatisticsMethod(integration_starting_time)
for t in range(3, 6):
    max_method.CalculateStatistics()

Median

Median returns the median value in spatial domain of a given variable's norm for a given container. xi is the ith element's variable value of the corresponding container. Results will be double value type, irrespective of the input type, since higher dimensional variable types will be reduced to scalars by the use of norms.

Following is an example of median method of non historical VELOCITY's magnitude over the whole model part's nodes. It returns a double which is the median.

import KratosMultiphysics as Kratos
import KratosMultiphysics.StatisticsApplication as KratosStats
model = Kratos.Model()
model_part = model.CreateModelPart("test_model_part")
median_value = KratosStats.SpatialMethods.NonHistorical.Nodes.NormMethods.Median(model_part, Kratos.VELOCITY, "magnitude")

Distribution

Distribution methods calculates distribution of a given variable with respect to given norm in a given container in spatial domain. xi is the ith element's variable value of the corresponding container. Result will be a tuple with followings in the same order:

  1. min in the domain or user specified min value
  2. max in the domain or user specified min value
  3. group limits of the distribution (only upper limit) (double array)
  4. number of occurences of items within each group (int array)
  5. percentage distribution of number of occurences of items within each group (double array)
  6. Each group's seperate means
  7. Eash group's seperate variances

This method requires followings as the parameters as a object of Kratos.Parameters, if nothing is provided, then followings are assumed as defaults.

{
    "number_of_value_groups" : 10,
    "min_value"              : "min",
    "max_value"              : "max"
}

In here, "min_value" can either be "min" or a double value. In the case of a double, it will be used as the minimum when creating groups to identify distribution. "max_value" also can either be "max" of double value, which will determine the maximum value when creating the groups. This will create 2 additional groups to represent values below the specified "min_value" and "max_value" apart from the "number_of_value_groups" specified by the user.

Following is an example of median method of non historical VELOCITY's magnitude over the whole model part's nodes.

import KratosMultiphysics as Kratos
import KratosMultiphysics.StatisticsApplication as KratosStats
model = Kratos.Model()
model_part = model.CreateModelPart("test_model_part")
min_value, max_value, group_upper_values, group_histogram, group_percentage_distribution, group_means, group_variances = KratosStats.SpatialMethods.NonHistorical.Nodes.NormMethods.Distribution(model_part, Kratos.VELOCITY, "magnitude")

Norm methods

All of the value methods mentioned before supports norm version of it, in these methods, higher dimensional values are transformed in to scalar values by a use specified norm, and then statistics are calculated based on the chosen method. Supported norm types may differ based on the variable data type being used. There are few methods, which only supports norm methods. Following table summarize availability of value and norm methods.

Statistical Methods Value Method Norm Method
Sum [x] [x]
Mean [x] [x]
Root mean square [x] [x]
Variance [x] [x]
Min [x]
Max [x]
Median [x]
Distribution [x]

Following example shows variance method, under value category and norm category for nodal non historical velocity. Norm method uses "magnitude" as the norm to reduce VELOCITY to a scalar value. value_mean and value_variance will be of Array 3D type, whereas norm_mean and norm_variance will be of Double type.

import KratosMultiphysics as Kratos
import KratosMultiphysics.StatisticsApplication as KratosStats
model = Kratos.Model()
model_part = model.CreateModelPart("test_model_part")
value_mean, value_variance = KratosStats.SpatialMethods.NonHistorical.Nodes.ValueMethods.Variance(model_part, Kratos.VELOCITY)
norm_mean, norm_variance = KratosStats.SpatialMethods.NonHistorical.Nodes.NormMethods.Variance(model_part, Kratos.VELOCITY, "magnitude")

Norm definitions

Few different norms are predefined in this application. Following table summarize

Double Array 3D Vector Matrix
Value [x]
Magnitude [x] [x] [x] [x]
Euclidean [x] [x]
Infinity [x] [x] [x]
P-Norm [x] [x] [x]
Lpq-Norm [x]
Frobenius [x]
Trace [x]
Index [x] [x]
Component [x]

Value

This returns the exact value. Only available for Double type variables.

Magnitude

This returns the second norm of the variable.

  1. For a Double type, it returns the absolute value.
  2. For a Array 3D type, it returns the magnitude of the 3D vector.
  3. For a Vector type, it returns root square sum of the vector.
  4. For a Matrix type, it returns the frobenius norm.

Euclidean

This again returns the second norm of the variable for following variable types.

  1. For a Array 3D type, it returns the magnitude of the 3D vector.
  2. For a Vector type, it returns root square sum of the vector.

Frobenius

This is only available for Matrix data type variables only. Following equation illustrates the norm, where A is the matrix and aij is the ith row, jth column value.

Infinity

This is infinity (i.e. max norm) which is available for Array 3D, Vector and Matrix type. For an Array 3D variable following equation is used.

For a Vector variable following equation is used.

For a Matrix variable following equation is used.

Trace

Trace is only for Matrix type variables. If the given matrix is not squre, an error is thrown.

P norm

P norm is applicable for Array 3D, Vector and Matrix variables. The p-norm is used as pnorm_p where, p represents the value to be used as p in the p-norm equation given below. p should be greater than or equal to 1.0.

For Array 3D and Vector:

For Matrix:

Lpq norm

This norm is only applicable to Matrix type variables.

Index based

Index based norms are available for both Vector and Matrix based variable types. index_i is used for Vector variables, where i represents the index of the vector to be used as the scalar representing a corresponding vector. index_(i,j) is used for Matrix variables, where i represents the row index and j represents the column index of the matrix value which to be used as the scalar representation of the given matrix.

Component based

Component based norms are available only for Array 3D type variables. component_x represents the x component of 3D variable, component_y represents y component, component_z represents the z component.

Spatial methods

All the spatial statistical methods can be found in the SpatialMethods submodule. ValueMethods container will contain all available spatial value methods, and NormMethods container will contain all available norm methods.

Following example illustrates all the available value methods executed on nodal non historical variable velocity.

import KratosMultiphysics as Kratos
import KratosMultiphysics.StatisticsApplication as KratosStats
model = Kratos.Model()
model_part = model.CreateModelPart("test_model_part")
sum_value = KratosStats.SpatialMethods.NonHistorical.Nodes.ValueMethods.Sum(model_part, Kratos.VELOCITY)
mean_value = KratosStats.SpatialMethods.NonHistorical.Nodes.ValueMethods.Mean(model_part, Kratos.VELOCITY)
rms_value = KratosStats.SpatialMethods.NonHistorical.Nodes.ValueMethods.RootMeanSquare(model_part, Kratos.VELOCITY)
mean_value, variance_value = KratosStats.SpatialMethods.NonHistorical.Nodes.ValueMethods.Variance(model_part, Kratos.VELOCITY)

Following example illustrates all the available norm methods executed on nodal non historical variable velocity's magnitude.

import KratosMultiphysics as Kratos
import KratosMultiphysics.StatisticsApplication as KratosStats
model = Kratos.Model()
model_part = model.CreateModelPart("test_model_part")
sum_norm = KratosStats.SpatialMethods.NonHistorical.Nodes.NormMethods.Sum(model_part, Kratos.VELOCITY, "magnitude")
mean_norm = KratosStats.SpatialMethods.NonHistorical.Nodes.NormMethods.Mean(model_part, Kratos.VELOCITY, "magnitude")
rms_norm = KratosStats.SpatialMethods.NonHistorical.Nodes.NormMethods.RootMeanSquare(model_part, Kratos.VELOCITY, "magnitude")
mean_norm, variance_norm = KratosStats.SpatialMethods.NonHistorical.Nodes.NormMethods.Variance(model_part, Kratos.VELOCITY, "magnitude")
min_norm, min_norm_id = KratosStats.SpatialMethods.NonHistorical.Nodes.NormMethods.Min(model_part, Kratos.VELOCITY, "magnitude")
max_norm, max_norm_id = KratosStats.SpatialMethods.NonHistorical.Nodes.NormMethods.Max(model_part, Kratos.VELOCITY, "magnitude")
min_norm, max_norm, group_upper_norms, group_histogram, group_percentage_distribution = KratosStats.SpatialMethods.NonHistorical.Nodes.NormMethods.Distribution(model_part, Kratos.VELOCITY, "magnitude")

Spatial containers

Four different types of containers are supported for spatial methods.

  1. nodal_historical
  2. nodal_non_historical
  3. condition_non_historical
  4. element_non_historical

Spatial nodal historical

Nodal historical containers methods can be accessed through Historical submodule in SpatialMethods. This calculates chosen statistics of the variable in the nodal historical data. Following example illustrates use of value and norm methods.

import KratosMultiphysics as Kratos
import KratosMultiphysics.StatisticsApplication as KratosStats
model = Kratos.Model()
model_part = model.CreateModelPart("test_model_part")
model_part.AddNodalSolutionStepVariable(Kratos.VELOCITY)
sum_value = KratosStats.SpatialMethods.Historical.ValueMethods.Sum(model_part, Kratos.VELOCITY)
sum_norm = KratosStats.SpatialMethods.Historical.NormMethods.Sum(model_part, Kratos.VELOCITY, "magnitude")

Spatial nodal non historical

Nodal non historical containers methods can be accessed through NonHistorical.Nodes submodule in SpatialMethods. This calculates chosen statistics of the variable in the nodal non historical data. Following example illustrates use of value and norm methods.

import KratosMultiphysics as Kratos
import KratosMultiphysics.StatisticsApplication as KratosStats
model = Kratos.Model()
model_part = model.CreateModelPart("test_model_part")
sum_value = KratosStats.SpatialMethods.NonHistorical.Nodes.ValueMethods.Sum(model_part, Kratos.VELOCITY)
sum_norm = KratosStats.SpatialMethods.NonHistorical.Nodes.NormMethods.Sum(model_part, Kratos.VELOCITY, "magnitude")

Spatial condition non historical

Condition non historical containers methods can be accessed through NonHistorical.Conditions submodule in SpatialMethods. This calculates chosen statistics of the variable in the condition non historical data. Following example illustrates use of value and norm methods.

import KratosMultiphysics as Kratos
import KratosMultiphysics.StatisticsApplication as KratosStats
model = Kratos.Model()
model_part = model.CreateModelPart("test_model_part")
sum_value = KratosStats.SpatialMethods.NonHistorical.Conditions.ValueMethods.Sum(model_part, Kratos.VELOCITY)
sum_norm = KratosStats.SpatialMethods.NonHistorical.Conditions.NormMethods.Sum(model_part, Kratos.VELOCITY, "magnitude")

Spatial element non historical

Element non historical containers methods can be accessed through NonHistorical.Elements submodule in SpatialMethods. This calculates chosen statistics of the variable in the element non historical data. Following example illustrates use of value and norm methods.

import KratosMultiphysics as Kratos
import KratosMultiphysics.StatisticsApplication as KratosStats
model = Kratos.Model()
model_part = model.CreateModelPart("test_model_part")
sum_value = KratosStats.SpatialMethods.NonHistorical.Elements.ValueMethods.Sum(model_part, Kratos.VELOCITY)
sum_norm = KratosStats.SpatialMethods.NonHistorical.Elements.NormMethods.Sum(model_part, Kratos.VELOCITY, "magnitude")

Spatial statistics process

This is a seperate process, which can be included in the json file as an auxiliary process. Followings are the defaults used in this process.

{
    "model_part_name" : "PLEASE_SPECIFY_MODEL_PART_NAME",
    "input_variable_settings" : [
        {
            "method_name"    : "sum",
            "norm_type"      : "none",
            "container"      : "nodal_historical",
            "variable_names" : [],
            "method_settings": {}
        }
    ],
    "output_settings" : {
        "output_control_variable": "STEP",
        "output_time_interval"   : 1,
        "write_kratos_version"   : true,
        "write_time_stamp"       : true,
        "output_file_settings"   : {
            "file_name"  : "<model_part_name>_<container>_<norm_type>_<method_name>.dat",
            "output_path": "spatial_statistics_output",
            "write_buffer_size" : -1
        }
    }
}

model_part_name indicates which model part to be operated on for statistics calculation. input_variable_settings contains list of statistics and/or norm methods along with their acting containers of the model part. method_name is the statistics method name (always everything is in lower case). norm_type is the applied norm, none means, value methods are used, otherwise specified norm is used. container is the container to be specified for statistical value calculation. method_settings is used to pass additional information required by statistics method such as in Distribution method. Output is written to a file in the format given at file_name, under the folder folder_name. This process can be used, if someone prefers not to modify their python scripts to calculate statistics as mentioned in the previous sections

Temporal methods

All the temporal methods are available through TemporalMethods submodule under StatisticsApplication. In the case of temporal methods, seperate objects needs to be created for each input variable for different type of variables as shown in following example for nodal non historical data container value methods.

import KratosMultiphysics as Kratos
import KratosMultiphysics.StatisticsApplication as KratosStats
model = Kratos.Model()
model_part = model.CreateModelPart("test_model_part")
sum_double_method = KratosStats.TemporalMethods.NonHistorical.Nodes.ValueMethods.Sum.Double(model_part, "", Kratos.PRESSURE, 0, Kratos.DENSITY)
sum_array_method = KratosStats.TemporalMethods.NonHistorical.Nodes.ValueMethods.Sum.Array(model_part, "", Kratos.VELOCITY, 0, Kratos.DISPLACEMENT)
sum_vector_method = KratosStats.TemporalMethods.NonHistorical.Nodes.ValueMethods.Sum.Vector(model_part, "", Kratos.LOAD_MESHES, 0, Kratos.MATERIAL_PARAMETERS)
sum_matrix_method = KratosStats.TemporalMethods.NonHistorical.Nodes.ValueMethods.Sum.Matrix(model_part, "", Kratos.GREEN_LAGRANGE_STRAIN_TENSOR, 0, Kratos.CAUCHY_STRESS_TENSOR)

In order to remove the hassle of using different names (such as Double, Array...), one can get the advantage of common methods available in each of the containers. Following example will create the same objects as in the previous example in one go using simplified sum method.

import KratosMultiphysics as Kratos
import KratosMultiphysics.StatisticsApplication as KratosStats
model = Kratos.Model()
model_part = model.CreateModelPart("test_model_part")
params = Kratos.Parameters(r"""
{
    "input_variables" : ["PRESSURE", "VELOCITY", "LOAD_MESHES", "GREEN_LAGRANGE_STRAIN_TENSOR"],
    "output_variables" : ["DENSITY", "DISPLACEMENT", "MATERIAL_PARAMETERS", "CAUCHY_STRESS_TENSOR"]
}""")
sum_methods = KratosStats.TemporalMethods.NonHistorical.Nodes.Sum(model_part, "none", 0, params)

For Sum, Mean, RootMeanSquare methods, above Kratos.Parameters object keys will remain the same. But for Variance method following json parameters are used.

{
    "input_variables"           : [],
    "output_mean_variables"     : [],
    "output_variance_variables" : []
}

When using these simplified, one needs to take care of compatibility of input and output variables depending on the method and norm type, otherwise runtime errors will be thrown.

Temporal containers

In the temporal domain, there are five different containers available for user to calculate temporal statistics. They are,

  1. nodal_historical_historical
  2. nodal_historical_non_historical
  3. nodal_non_historical
  4. condition_non_historical
  5. element_non_historical

Temporal nodal historical historical

In this container, statistics are calculated on user specified variables in the nodal historical container and, output is also written to the nodal historical container. Example is given below.

import KratosMultiphysics as Kratos
import KratosMultiphysics.StatisticsApplication as KratosStats
model = Kratos.Model()
model_part = model.CreateModelPart("test_model_part")
sum_value = KratosStats.TemporalMethods.Historical.HistoricalOutput.ValueMethods.Sum.Array(model_part, "", Kratos.VELOCITY, 0, Kratos.DISPLACEMENT)
sum_norm = KratosStats.TemporalMethods.Historical.HistoricalOutput.NormMethods.Sum.Array(model_part, "magnitude", Kratos.VELOCITY, 0, Kratos.DENSITY)

Temporal nodal historical non historical

In this container, statistics are calculated on user specified variables in the nodal historical container and, output is also written to the nodal non historical container. Example is given below.

import KratosMultiphysics as Kratos
import KratosMultiphysics.StatisticsApplication as KratosStats
model = Kratos.Model()
model_part = model.CreateModelPart("test_model_part")
sum_value = KratosStats.TemporalMethods.Historical.NonHistoricalOutput.ValueMethods.Sum.Array(model_part, "", Kratos.VELOCITY, 0, Kratos.DISPLACEMENT)
sum_norm = KratosStats.TemporalMethods.Historical.NonHistoricalOutput.NormMethods.Sum.Array(model_part, "magnitude", Kratos.VELOCITY, 0, Kratos.DENSITY)

Temporal nodal non historical

In this container, statistics are calculated on user specified variables in the nodal non historical container and, output is also written to the nodal non historical container. Example is given below.

import KratosMultiphysics as Kratos
import KratosMultiphysics.StatisticsApplication as KratosStats
model = Kratos.Model()
model_part = model.CreateModelPart("test_model_part")
sum_value = KratosStats.TemporalMethods.NonHistorical.Nodes.ValueMethods.Sum.Array(model_part, "", Kratos.VELOCITY, 0, Kratos.DISPLACEMENT)
sum_norm = KratosStats.TemporalMethods.NonHistorical.Nodes.NormMethods.Sum.Array(model_part, "magnitude", Kratos.VELOCITY, 0, Kratos.DENSITY)

Temporal condition non historical

In this container, statistics are calculated on user specified variables in the condition non historical container and, output is also written to the condition non historical container. Example is given below.

import KratosMultiphysics as Kratos
import KratosMultiphysics.StatisticsApplication as KratosStats
model = Kratos.Model()
model_part = model.CreateModelPart("test_model_part")
sum_value = KratosStats.TemporalMethods.NonHistorical.Conditions.ValueMethods.Sum.Array(model_part, "", Kratos.VELOCITY, 0, Kratos.DISPLACEMENT)
sum_norm = KratosStats.TemporalMethods.NonHistorical.Conditions.NormMethods.Sum.Array(model_part, "magnitude", Kratos.VELOCITY, 0, Kratos.DENSITY)

Temporal element non historical

In this container, statistics are calculated on user specified variables in the element non historical container and, output is also written to the element non historical container. Example is given below.

import KratosMultiphysics as Kratos
import KratosMultiphysics.StatisticsApplication as KratosStats
model = Kratos.Model()
model_part = model.CreateModelPart("test_model_part")
sum_value = KratosStats.TemporalMethods.NonHistorical.Elements.ValueMethods.Sum.Array(model_part, "", Kratos.VELOCITY, 0, Kratos.DISPLACEMENT)
sum_norm = KratosStats.TemporalMethods.NonHistorical.Elements.NormMethods.Sum.Array(model_part, "magnitude", Kratos.VELOCITY, 0, Kratos.DENSITY)

Temporal statistics process

This is a seperate process, which can be included in the json file as an auxiliary process. Followings are the defaults used in this process.

    "model_part_name" : "PLEASE_SPECIFY_MODEL_PART_NAME",
    "input_variable_settings" : [
        {
            "method_name"     : "sum",
            "norm_type"       : "none",
            "container"       : "nodal_historical_non_historical",
            "echo_level"      : 0,
            "method_settings" : {}
        }
    ],
    "echo_level" : 0,
    "statistics_start_point_control_variable_name" : "TIME",
    "statistics_start_point_control_value"         : 0.0

model_part_name is the model part which all of the mentioned statistics will be calculated. input_variable_settings contains list of statistical methods, their norms and container combinations where statistics will be calculated. under each input_variable_settings_block, method_name is the statistics method, norm_type is the norm type ("none" for value methods, other wise norms are used), container to tell from which container to read/write, method_settings to specifiy input/output variables for the method. Apart from that, there are few global settings. statistics_start_point_control_variable_name is the temporal statistics calculation start control variable name. This variable should be present in the model_part specified in order to calculate temporal statistics. Statistics calculation will start when this variable's value passes user specified value in statistics_start_point_control_value.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distributions

KratosStatisticsApplication-10.1.0-cp312-cp312-win_amd64.whl (850.9 kB view details)

Uploaded CPython 3.12 Windows x86-64

KratosStatisticsApplication-10.1.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (2.3 MB view details)

Uploaded CPython 3.12 manylinux: glibc 2.17+ x86-64

KratosStatisticsApplication-10.1.0-cp311-cp311-win_amd64.whl (849.9 kB view details)

Uploaded CPython 3.11 Windows x86-64

KratosStatisticsApplication-10.1.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (2.3 MB view details)

Uploaded CPython 3.11 manylinux: glibc 2.17+ x86-64

KratosStatisticsApplication-10.1.0-cp310-cp310-win_amd64.whl (849.4 kB view details)

Uploaded CPython 3.10 Windows x86-64

KratosStatisticsApplication-10.1.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (2.4 MB view details)

Uploaded CPython 3.10 manylinux: glibc 2.17+ x86-64

KratosStatisticsApplication-10.1.0-cp39-cp39-win_amd64.whl (834.8 kB view details)

Uploaded CPython 3.9 Windows x86-64

KratosStatisticsApplication-10.1.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (2.3 MB view details)

Uploaded CPython 3.9 manylinux: glibc 2.17+ x86-64

KratosStatisticsApplication-10.1.0-cp38-cp38-win_amd64.whl (849.3 kB view details)

Uploaded CPython 3.8 Windows x86-64

KratosStatisticsApplication-10.1.0-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (2.3 MB view details)

Uploaded CPython 3.8 manylinux: glibc 2.17+ x86-64

File details

Details for the file KratosStatisticsApplication-10.1.0-cp312-cp312-win_amd64.whl.

File metadata

  • Download URL: KratosStatisticsApplication-10.1.0-cp312-cp312-win_amd64.whl
  • Upload date:
  • Size: 850.9 kB
  • Tags: CPython 3.12, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/34.0 requests/2.31.0 requests-toolbelt/0.9.1 urllib3/1.26.9 tqdm/4.63.1 importlib-metadata/6.8.0 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.9.11

File hashes

Hashes for KratosStatisticsApplication-10.1.0-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 2984c352a9bc4b21fb937521f3f4a4911be14ec5c2e11656bc11a74e0c74acb5
MD5 9cb3ce82c3b5d85878c5d4bf6367f4f9
BLAKE2b-256 5698f06f2d01bbf9b448e1ee5b728798c017d208ab1b628fd5b368ebdb1ff57f

See more details on using hashes here.

File details

Details for the file KratosStatisticsApplication-10.1.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for KratosStatisticsApplication-10.1.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 865fd3e0afce3fce0684a3f8835bf85df54376732de26adc06cf6401317351d6
MD5 fff59425ba05b8e5eb1e1ed234cb5bef
BLAKE2b-256 57d8a7d107aa7e08f42e3a73c4e6f45d982c5813a0a5173951e13fe5a4929bd1

See more details on using hashes here.

File details

Details for the file KratosStatisticsApplication-10.1.0-cp311-cp311-win_amd64.whl.

File metadata

  • Download URL: KratosStatisticsApplication-10.1.0-cp311-cp311-win_amd64.whl
  • Upload date:
  • Size: 849.9 kB
  • Tags: CPython 3.11, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/34.0 requests/2.31.0 requests-toolbelt/0.9.1 urllib3/1.26.9 tqdm/4.63.1 importlib-metadata/6.8.0 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.9.11

File hashes

Hashes for KratosStatisticsApplication-10.1.0-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 ff173c28e7ba1f14eb10a5af1e922591bda8d75022e9da0698a27268fa527c91
MD5 c1448f786f61af6f79b619a50f0d66ae
BLAKE2b-256 ffae37aeab29529aef50f587a44b854608029f0a9aa6af9b067bf6cd894edc85

See more details on using hashes here.

File details

Details for the file KratosStatisticsApplication-10.1.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for KratosStatisticsApplication-10.1.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 8d7a4929296df2a9e4cfaf0b6c2c8f56ea9788ff22e3ae80a743d51c69982976
MD5 23ab39900475b4ad518a56f74b362c39
BLAKE2b-256 99e96834768ce3894d7f0e024f31b23de78263585b677e75b28c65ae546bd71f

See more details on using hashes here.

File details

Details for the file KratosStatisticsApplication-10.1.0-cp310-cp310-win_amd64.whl.

File metadata

  • Download URL: KratosStatisticsApplication-10.1.0-cp310-cp310-win_amd64.whl
  • Upload date:
  • Size: 849.4 kB
  • Tags: CPython 3.10, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/34.0 requests/2.31.0 requests-toolbelt/0.9.1 urllib3/1.26.9 tqdm/4.63.1 importlib-metadata/6.8.0 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.9.11

File hashes

Hashes for KratosStatisticsApplication-10.1.0-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 38d0c48c85708e01f0fa933ba8987735cc989743ae29a6eae437c3d8f748b5a3
MD5 0b258a06e53285ca682a61be1910c25e
BLAKE2b-256 d0176c07839a3794bd48f7eb0e2192ea16bae8b7b5f8c4c000b01b0492c0cb5f

See more details on using hashes here.

File details

Details for the file KratosStatisticsApplication-10.1.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for KratosStatisticsApplication-10.1.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 db53d61c40dc580004aa3c23d376f5d6deaff2514b50d3d75ab0403f86386cbf
MD5 2c20ab1852617e8dad6de4b7765166e5
BLAKE2b-256 fabeeb50f5bbe7b49505fad0bb8e43d7cfc08f966b324828fe251669f8bd861a

See more details on using hashes here.

File details

Details for the file KratosStatisticsApplication-10.1.0-cp39-cp39-win_amd64.whl.

File metadata

  • Download URL: KratosStatisticsApplication-10.1.0-cp39-cp39-win_amd64.whl
  • Upload date:
  • Size: 834.8 kB
  • Tags: CPython 3.9, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/34.0 requests/2.31.0 requests-toolbelt/0.9.1 urllib3/1.26.9 tqdm/4.63.1 importlib-metadata/6.8.0 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.9.11

File hashes

Hashes for KratosStatisticsApplication-10.1.0-cp39-cp39-win_amd64.whl
Algorithm Hash digest
SHA256 d368bf6eea31dfc3cc19d90c3161b65ce269ab9c1568dbae939bfd1a7992aa4c
MD5 dd9ead846cf497bb645503e81642e809
BLAKE2b-256 7aa440c7f272aeb75352ef9c9529b25176e30a7ab12a3ce545f748d1c75d82f1

See more details on using hashes here.

File details

Details for the file KratosStatisticsApplication-10.1.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for KratosStatisticsApplication-10.1.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 bc39a455001c99e70ff0c6f2dc41f72ac52e50e4e286807b9d57d770352333e6
MD5 d715975e96ae6fa906510a486ba10556
BLAKE2b-256 f9b2a19265ba81fa243a01f332892102f015ba1ee650510edcb5404c008538db

See more details on using hashes here.

File details

Details for the file KratosStatisticsApplication-10.1.0-cp38-cp38-win_amd64.whl.

File metadata

  • Download URL: KratosStatisticsApplication-10.1.0-cp38-cp38-win_amd64.whl
  • Upload date:
  • Size: 849.3 kB
  • Tags: CPython 3.8, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/34.0 requests/2.31.0 requests-toolbelt/0.9.1 urllib3/1.26.9 tqdm/4.63.1 importlib-metadata/6.8.0 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.9.11

File hashes

Hashes for KratosStatisticsApplication-10.1.0-cp38-cp38-win_amd64.whl
Algorithm Hash digest
SHA256 4ded81ece56458c7fb4d854ed74fd1c626ea8a6bbd64be478332a41f3dd1ab79
MD5 a46916eee415b2d6959a91e05a44dac9
BLAKE2b-256 8fce2fabe5442382a815a88bcfbb7c7b54a5e34ae835eb5a68bf6c08cfacafd3

See more details on using hashes here.

File details

Details for the file KratosStatisticsApplication-10.1.0-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for KratosStatisticsApplication-10.1.0-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 b864497613a8ee4f0dbbe8ade935b454fece1a54754a26d868e065489aa99fdf
MD5 232699a95cdcd75ce6106acfea66a59f
BLAKE2b-256 a52ba76a684a8ee34ab22ee090eab301dc537e805a37399eb7ea9d99cf0d1548

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page