Ascent Expressions Documentation¶
Functions¶
-
avg
(arg1)¶ Return the average of an array.
Parameters: arg1 (array) – Return type: double
-
avg
(arg1) Return the field average of a mesh variable.
Parameters: arg1 (field) – Return type: double
-
field_nan_count
(arg1)¶ Return the number of NaNs in a mesh variable.
Parameters: arg1 (field) – Return type: double
-
field_inf_count
(arg1)¶ Return the number of -inf and +inf in a mesh variable.
Parameters: arg1 (field) – Return type: double
-
max
(arg1, arg2)¶ Return the maximum of two scalars.
Parameters: - arg1 (scalar) –
- arg2 (scalar) –
Return type: double
-
max
(arg1) Return the maximum value from the meshvar. Its position is also stored and is accessible via the position function.
Parameters: arg1 (field) – Return type: value_position
-
max
(arg1) Return the maximum of an array.
Parameters: arg1 (array) – Return type: double
-
min
(arg1)¶ Return the minimum value from the meshvar. Its position is also stored and is accessible via the position function.
Parameters: arg1 (field) – Return type: value_position
-
min
(arg1, arg2) Return the minimum of two scalars.
Parameters: - arg1 (scalar) –
- arg2 (scalar) –
Return type: double
-
min
(arg1) Return the minimum of an array.
Parameters: arg1 (array) – Return type: double
-
sum
(arg1)¶ Return the sum of a field.
Parameters: arg1 (field) – Return type: double
-
sum
(arg1) Return the sum of an array.
Parameters: arg1 (array) – Return type: double
-
cycle
()¶ Return the current simulation cycle.
Return type: int
-
vector
(arg1, arg2, arg3)¶ Return the 3D position vector for the input value.
Parameters: - arg1 (scalar) –
- arg2 (scalar) –
- arg3 (scalar) –
Return type: vector
-
magnitude
(arg1)¶ Return the magnitude of the input vector.
Parameters: arg1 (vector) – Return type: double
-
histogram
(arg1[, num_bins][, min_val][, max_val])¶ Return a histogram of the mesh variable. Return a histogram of the mesh variable.
Parameters: - arg1 (field) –
- num_bins (int) – defaults to
256
- min_val (scalar) – defaults to
min(arg1)
- max_val (scalar) – defaults to
max(arg1)
Return type: histogram
-
history
(expr_name[, relative_index][, absolute_index])¶ As the simulation progresses the expressions are evaluated repeatedly. The history function allows you to get the value of previous evaluations. For example, if we want to evaluate the difference between the original state of the simulation and the current state then we can use an absolute index of 0 to compare the initial value with the current value:
val - history(val, absolute_index=0)
. Another example is if you want to evaluate the relative change between the previous state and the current state:val - history(val, relative_index=1)
.Note
Exactly one of
relative_index
orabsolute_index
must be passed. If the argument name is not specifiedrelative_index
will be used.Parameters: - expr_name (anytype) – expr_name should be the name of an expression that was evaluated in the past.
- relative_index (int) – The number of evaluations ago. This should be less than the number of past evaluations. For example,
history(pressure, relative_index=1)
returns the value of pressure one evaluation ago. - absolute_index (int) – The index in the evaluation history. This should be less than the number of past evaluations. For example,
history(pressure, absolute_index=0)
returns the value of pressure from the first time it was evaluated.
Return type: anytype
-
entropy
(hist)¶ Return the Shannon entropy given a histogram of the field.
Parameters: hist (histogram) – Return type: double
-
pdf
(hist)¶ Return the probability distribution function (pdf) from a histogram.
Parameters: hist (histogram) – Return type: histogram
-
cdf
(hist)¶ Return the cumulative distribution function (cdf) from a histogram.
Parameters: hist (histogram) – Return type: histogram
-
bin
(hist, bin)¶ Return the value of the bin at index bin of a histogram.
Parameters: - hist (histogram) –
- bin (int) –
Return type: double
-
bin
(hist, val) Return the value of the bin with axis-value val on the histogram.
Parameters: - hist (histogram) –
- val (scalar) –
Return type: double
-
field
(arg1)¶ Return a mesh field given a its name.
Parameters: arg1 (string) – Return type: field
-
quantile
(cdf, q[, interpolation])¶ Return the q-th quantile of the data along the axis of cdf. For example, if q is 0.5 the result is the value on the x-axis which 50% of the data lies below.
Parameters: - cdf (histogram) – CDF of a histogram.
- q (double) – Quantile between 0 and 1 inclusive.
- interpolation (string) –
Specifies the interpolation method to use when the quantile lies between two data points
i < j
:- linear (default):
i + (j - i) * fraction
, where fraction is the fractional part of the index surrounded byi
andj
. - lower:
i
. - higher:
j
. - nearest:
i
orj
, whichever is nearest. - midpoint:
(i + j) / 2
- linear (default):
Return type: double
-
axis
(name[, bins][, min_val][, max_val][, num_bins][, clamp])¶ Defines a uniform or rectilinear axis. When used for binning the bins are inclusive on the lower boundary and exclusive on the higher boundary of each bin. Either specify only
bins
or a subset of themin_val
,max_val
,num_bins
options.Parameters: - name (string) – The name of a scalar field on the mesh or one of
'x'
,'y'
, or'z'
. name can also be the empty string ‘’ if reduction_op is either sum or pdf to mean we want to count the number of elements in the bin as our reduction variable. - bins (list) – A strictly increasing list of scalars containing the values for each tick. Used to specify a rectilinear axis.
- min_val (scalar) – Minimum value of the axis (i.e. the value of the first tick). Defaults to
min(name)
for fields and for'x'
,'y'
, or'z'
the minimum value on the topology. - max_val (scalar) – Maximum value of the axis (i.e. the value of the last tick).Defaults to
max(name)
for fields and for'x'
,'y'
, or'z'
the maximum value on the topology. - num_bins (int) – Number of bins on the axis (i.e. the number of ticks minus 1). Defaults to
256
. - clamp (bool) – Defaults to
False
. IfTrue
, values outside the axis should be put into the bins on the boundaries.
Return type: axis
- name (string) – The name of a scalar field on the mesh or one of
-
binning
(reduction_var, reduction_op, bin_axes[, empty_bin_val][, output])¶ Returns a multidimensional data binning.
Parameters: - reduction_var (string) – The variable being reduced. Either the name of a scalar field on the mesh or one of
'x'
,'y'
, or'z'
. - reduction_op (string) –
The reduction operator to use when putting values in bins. Available reductions are:
- min: minimum value in a bin
- max: maximum value in a bin
- sum: sum of values in a bin
- avg: average of values in a bin
- pdf: probability distribution function
- std: standard deviation of values in a bin
- var: variance of values in a bin
- rms: root mean square of values in a bin
- bin_axes (list) – List of Axis objects which define the bin axes.
- empty_bin_val (scalar) – The value that empty bins should have. Defaults to
0
. - output (string) – Defaults to
'none'
. If set to'bins'
a binning with 3 or fewer dimensions will be output as a new topology on the dataset. This is useful for directly visualizing the binning. If set to'mesh'
the bins will be “painted” back onto the original mesh as a new field.
Return type: binning
- reduction_var (string) – The variable being reduced. Either the name of a scalar field on the mesh or one of