Sometimes the values you get out of your calculator look wrong to you when you compare them to hand calculations.

For example, a user reports the following situation using our flow2d dataset included in

$CEI_HOME/ensight101/data/flow2d

**Problem:**

I calculated a variable using the TempMean function in EnSight, then I just added up the values and divided by the number of timesteps and the two don't agree. Is that an EnSight bug?

I created a variable with TempMean function as follows:

1) Load "flow2d.case"

2) Select "Part by All Elements" part

2) Choose TempMean function in the Calculator tool box dialog

3) Choose PRESSION in "variable" combobox

4) Input "0" in "t1" field

5) Input "2" in "t2" field

6) Click "Evaluate for selected parts" button.

Then "TempMean" variable was created.

Then I displayed the value of "TempMean" variable on Node ID "7" with Interactive Probe Query.

The value was 4.19725E-002.

The values of PRESSION variable at Node ID "7" are as follows:

Time step Value

-------------------------

0 2.41700E-02

1 3.71700E-02

2 6.93800E-02

and the mean value I calculate by adding them up and dividing by 3 is 4.35733E-02.

The value which was evaluated with TempMean function is different from this mean value 4.35733E-02.

Is this a bug?

**Answer:**

When your numbers look wrong (but close) go to the User Manual.

The User Manual tells us that Temp mean uses the equation

(1/Total time) * integral of data over time.

and the integral of data is done with Trapezoidal rule

So you have to assume that the data is weighted with time (larger timesteps have a larger contribution) but here the time is uniform.

There are two trapezoids that make up the integral of this data. So let's add up the trapezoids.

Trapezoid 1:

(1-0) * (2.42+3.72) / 2 = 3.067 e -2

Trapezoid 2:

(2-1) * (6.94-3.72) / 2 = 5.3275 e -2

Sum these areas up to obtain the trapezoidal rule estimate of the area under the curve:

8.3945 e -2

Now the temp mean equation divides the result by the total time, which in this case is:

(2-0) = 2

8.3945e-2/ 2 = 4.19725E-2

which is exactly the answer that EnSight got.

**Analysis:**

Why was your technique wrong, but close?

Because you were lucky (or unlucky) in using this flow2d dataset.

It has both of the following:

1. Uniform timesteps

2. Simple delta time of 1

Now copy the flow2d.case file to flow2d_mod.case and let's modify our second case file:

Change the time values and do this again:

time values: 0 4 5 7 10 11 12 13 14 15 16 17 18 19 20 21 22

23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41

42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60

61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79

80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98

99 100 101 102 103 104 105 106 107 108 109 110 111 112

113 114 115 116 117 118 119 120 121 122 123 124 125 126

127 128 129 130 131 132 133 134 135 136 137 138 139 140

141 142 143 144 145 146 147 148 149 150 151 152 153 154

155 156 157 158 159 160 161 162 163 164 165

Now load the flow2d_mod.case file and do the same thing and just sum up the three values and compare to the temp mean calculated 3.5191e-02 using the flow2d_mod.case.

You see more clearly that EnSight is weighting each temporal trapezoid by the non - uniform delta time values then summing them up to get the total area from timestep 0 to 2 and then dividing by the total time (5-0).

## Comments