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
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 of two scalars.

Parameters:arg1 (field) –
Return type:value_position
min(arg1, arg2)

Return the minimum value from the meshvar. Its position is also stored and is accessible via the position function.

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][, reduction])

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)
  • reduction (string) –

    The reduction function to use when putting values in bins. Available reductions are:

    • count (default): number of elements in a bin
    • min: minimum value in a bin
    • max: maximum value in a bin
    • sum: sum of values that fall in a bin
    • avg: average of values that fall in a bin
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 or absolute_index must be passed. If the argument name is not specified relative_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 by i and j.
    • lower: i.
    • higher: j.
    • nearest: i or j, whichever is nearest.
    • midpoint: (i + j) / 2
Return type:

double

Objects

histogram
Parameters:
  • value (array) –
  • min_val (double) –
  • max_val (double) –
  • num_bins (int) –
value_position
Parameters:
  • value (double) –
  • position (vector) –