Averaging

Integration and averaging over 2D cuts of the flow.

Reduces a cut – a structured 2D Block or an UnstructuredBlock surface – to the flows through it and to representative averages, for comparison with mean-line design points and measurements:

As discussed by Cumpsty and Horlock [4], reducing a non-uniform flow to a uniform one loses information, so the conserved quantities should be chosen for the purpose. Burdett and Povey [5] show that mixed-out averages are the least sensitive to where along the flow the cut is taken. Averages are taken in whatever frame their argument is given: pass a relative-frame quantity for a relative-frame average.

average.flow_mass(block, axes=None)[source]

Integrate mass flow through faces of a 2D block.

Calculates the mass flow over the block faces,

\[\dot{m} = \int \rho \mathbf{V}\cdot\mathrm{d}\mathbf{A} \,.\]

This is the first component of flow_conserved(), but needs no equation-of-state evaluation, so is several times cheaper on a structured block: use it where only the mass flow is wanted.

Parameters:
  • block (Block, shape (ni, nj), or UnstructuredBlock) – 2D structured block or unstructured surface.

  • axes (tuple of int, optional) – For a structured block, the face axes to sum over: (0,), (1,) or the default (0, 1), all of them. For an unstructured block, must be None, and every face is summed.

Returns:

mass_flow – Mass flow through the block [kg/s]: a scalar if every face axis is summed, else one value per face along the axis not in axes.

Return type:

float or Array

average.flow_conserved(block, axes=None)[source]

Integrate conserved flows through faces of a 2D block.

Calculates the conserved flows over the block faces,

\[\int \mathcal{F}\cdot\mathrm{d}\mathbf{A} \,,\]

where the conserved flux tensor \(\mathcal{F}\) carries the fluxes of mass, axial momentum, radial momentum, angular momentum and stagnation enthalpy (energy),

\[\begin{split}\mathcal{F} = \rho \mathbf{V} \begin{bmatrix} 1 \\ V_x \\ V_r \\ r V_\theta \\ h_0 \end{bmatrix} + p \begin{bmatrix} \mathbf{0} \\ \mathbf{e}_x \\ \mathbf{e}_r \\ r\,\mathbf{e}_\theta \\ \Omega r\,\mathbf{e}_\theta \end{bmatrix} \,.\end{split}\]
Parameters:
  • block (Block, shape (ni, nj), or UnstructuredBlock) – 2D structured block or unstructured surface.

  • axes (tuple of int, optional) – For a structured block, the face axes to sum over: (0,), (1,) or the default (0, 1), all of them. For an unstructured block, must be None, and every face is summed.

Returns:

flow_conserved – Flows of mass [kg/s], axial and radial momentum [N], angular momentum [N m] and energy [W], summed over every face, or over axes leaving one row per face along the other axis.

Return type:

Array, shape (5,) or (n, 5)

average.total_area(block)[source]

Compute total vector area of a 2D block.

Calculates the total vector area as the integral of the face area vectors,

\[\mathbf{A} = \int \mathrm{d}\mathbf{A} \,.\]

For a cut of constant \(x\) the axial component is its annulus area; a cut that is not flat in the meridional plane has both axial and radial components.

Parameters:

block (Block, shape (ni, nj), or UnstructuredBlock) – 2D structured block or unstructured surface.

Returns:

A – Total vector area [m^2], components \((A_x, A_r, A_\theta)\).

Return type:

Array, shape (3,)

Raises:

ValueError – If block is structured but not 2D.

average.area_average(scalar_node, block, axes=None)[source]

Take area-weighted average of a 2D nodal scalar field.

Calculates the area-weighted average of the scalar field \(\phi\),

\[\bar{\phi} = \frac{\int \phi\, \mathrm{d}A}{\int \mathrm{d}A} \,.\]
Parameters:
  • scalar_node (Array, shape (ni, nj, ...) or (n_node, ...)) – Scalar field at the nodes of block, such as block.s. Any frame-dependent quantity is averaged in whatever frame it is given, so pass block.ho_rel, say, for a relative-frame average. Axes after the node axes are averaged separately, so several fields stacked on a last axis, np.stack([block.ho, block.s], axis=-1), are averaged in one pass.

  • block (Block, shape (ni, nj), or UnstructuredBlock) – 2D structured block or unstructured surface.

  • axes (tuple of int, optional) – For a structured block, the face axes to average over: (0,), (1,) or the default (0, 1), all of them. For an unstructured block, must be None, and every face is averaged.

Returns:

avg_scalar – Area-weighted average: a scalar if every face axis is averaged, else one value per face along the axis not in axes, followed by any trailing axes of scalar_node.

Return type:

float or Array

Raises:

ValueError – If scalar_node does not lead with one value per node.

average.mass_average(scalar_node, block, axes=None)[source]

Take mass-weighted average of a 2D nodal scalar field.

Calculates the mass-weighted average of the scalar field \(\phi\),

\[\bar{\phi} = \frac{\int \phi\, \rho \mathbf{V}\cdot\mathrm{d}\mathbf{A}} {\int \rho \mathbf{V}\cdot\mathrm{d}\mathbf{A}} \,.\]
Parameters:
  • scalar_node (Array, shape (ni, nj, ...) or (n_node, ...)) – Scalar field at the nodes of block, such as block.s. Any frame-dependent quantity is averaged in whatever frame it is given, so pass block.ho_rel, say, for a relative-frame average. Axes after the node axes are averaged separately, so several fields stacked on a last axis, np.stack([block.ho, block.s], axis=-1), are averaged in one pass.

  • block (Block, shape (ni, nj), or UnstructuredBlock) – 2D structured block or unstructured surface.

  • axes (tuple of int, optional) – For a structured block, the face axes to average over: (0,), (1,) or the default (0, 1), all of them. For an unstructured block, must be None, and every face is averaged.

Returns:

avg_scalar – Mass-weighted average: a scalar if every face axis is averaged, else one value per face along the axis not in axes, followed by any trailing axes of scalar_node.

Return type:

float or Array

Raises:

ValueError – If the net mass flux through the block is zero, or, for a partial average, through any one strip; or if scalar_node does not lead with one value per node.

average.mix_out(block, AR=1.0, axes=None)[source]

Mix out a 2D cut to uniformity, optionally then changing its area.

The mixed-out state is the uniform flow that, passed through the total area \(\mathbf{A} = \int \mathrm{d}\mathbf{A}\), carries the same conserved flows as the non-uniform cut. Its conserved variables \(\mathcal{U}\) are found by solving

\[\mathcal{F}(\mathcal{U})\cdot\mathbf{A} = \int \mathcal{F}\cdot\mathrm{d}\mathbf{A} \,,\]

for the five conserved flows (mass, axial and radial momentum, angular momentum and energy), where \(\mathcal{F}\) is the flux tensor of flow_conserved(), by Newton steps with a backtracking line search. With axes, each strip of faces summed over them is mixed out on its own, as a pitchwise mix-out gives one state per strip along the span.

Two uniform states carry the flows, one subsonic and one supersonic through the cut, linked by a normal shock. The result is supersonic if the mass-averaged Mach number through the cut exceeds one and the supersonic state does not lower the entropy below the cut’s mass average, which mixing cannot do; otherwise subsonic. A near-sonic cut may have neither: it is choked, and RuntimeError is raised.

The optional area ratio AR then takes the uniform state isentropically to AR times its area, conserving mass, stagnation enthalpy, entropy and angular momentum \(r V_\theta\) while holding the pitch angle \(\beta\). This step is reversible, so the mixing loss is independent of AR. It stays on the meridional branch of the mixed-out state, and raises RuntimeError if it would choke.

Parameters:
  • block (Block, shape (ni, nj), or UnstructuredBlock) – 2D structured block or unstructured surface.

  • AR (float, default 1.0) – Area ratio of the isentropic area change after mixing out; AR<1 contracts the uniform state, AR=1 leaves it at constant area.

  • axes (tuple of int, optional) – For a structured block, the face axes to mix over: (1,) mixes each strip of faces along axis 1, one state per strip along axis 0, (0,) the reverse, and the default (0, 1) the whole cut. For an unstructured block, must be None.

Returns:

mix – New block holding the mixed-out state, or one per strip, with the fluid, reference length, rotation speed, blade count and label of the cut. Each state sits at the root mean square of its faces’ least and greatest radius, and the midpoints of their axial and circumferential extents. Velocities are absolute, as on the cut.

Return type:

Block, shape () or (n,)

Raises:
  • ValueError – If AR is not positive, or the cut is not a surface of revolution: its faces have area in the circumferential direction.

  • RuntimeError – If the Newton iteration fails to converge for any state, as when its strip is choked, or if the area change would choke the flow.

average.streamtube(block, lo, hi, along=0)[source]

Extract the stream tube of a structured 2D cut between two mass fractions.

Integrates the mass flow strip by strip along axis along, summing across the other axis, to give a cumulative mass fraction \(\psi\) running from zero at the first node to one at the last. The stream tube is the region \(\mathrm{lo} \le \psi \le \mathrm{hi}\), so lo=0.45, hi=0.55 on a hub-to-casing axis is the stream tube carrying the central tenth of the flow. It is bounded by surfaces of constant mass fraction, as in a throughflow calculation, so is a true stream tube only as far as the flow does not migrate across those surfaces; this cut alone cannot tell.

The two ends of the stream tube sit at fractional node positions inside the strips where \(\psi\) first reaches lo and hi. The data are interpolated linearly to those two positions and the original nodes between them are copied through, so the stream tube keeps the resolution of the cut it came from. Each end is placed by bisection on the mass flow of the partial strip it bounds, integrated just as flow_mass() integrates the stream tube, so it carries \(\mathrm{hi} - \mathrm{lo}\) of the flow to round-off — not merely to within the variation of flux and face area across a strip, which a linear interpolation of \(\psi\) would leave.

The first crossing is taken rather than an inverse interpolation of \(\psi\), which need not be monotonic: a strip of backflow in a corner elsewhere on the cut does not stop the stream tube being found.

Parameters:
  • block (Block, shape (ni, nj)) – Structured 2D block.

  • lo (float) – Mass fractions bounding the stream tube, \(0 \le \mathrm{lo} < \mathrm{hi} \le 1\).

  • hi (float) – Mass fractions bounding the stream tube, \(0 \le \mathrm{lo} < \mathrm{hi} \le 1\).

  • along (int, default 0) – Axis along which the mass fraction runs. The stream tube spans the whole of the other axis. Note the sense is opposite to axes in the averaging functions, which names the axes summed over.

Returns:

tube – New block holding the stream tube, with the metadata of block.

Return type:

Block, shape (ntube, nj) or (ni, ntube)

Raises:

ValueError – If block is unstructured or not 2D, if along is not 0 or 1, if the fractions are out of order or out of range, or if the net mass flux through the block is zero.