polaris.tasks.ocean.horiz_press_grad.finite_volume.centered_shift_accumulated

polaris.tasks.ocean.horiz_press_grad.finite_volume.centered_shift_accumulated(ds: Dataset, anchor: str = 'surface') → DataArray[source]

S_{e,k} accumulated down the column through [gamma-increments].

Mathematically identical to centered_shift(), but it never forms the two large terms that cancel there. With Gamma_{e,k} = Delta_e Z_k + (alphabar_{e,k}/g) Delta_e q_k and Gamma^+_{e,k} the same at interface k+1, so that S_{e,k} = (Gamma + Gamma^+)/2, the design’s [gamma-increments] gives

Gamma^+_{e,k} - Gamma_{e,k}

= -rho0 * htildebar_{e,k} * Delta_e alpha_k

Gamma_{e,k+1} - Gamma^+_{e,k}

= (Delta_e q_{k+1}/g) * (alphabar_{e,k+1} - alphabar_{e,k})

Both increments are a small factor times a bounded one – the horizontal contrast in specific volume within a layer, and the vertical contrast between adjacent layers – so the walk introduces no cancellation of large numbers anywhere. The starting value is the inverse-barometer residual at the sea surface, itself small for a state at rest.

Per §3.7.5 this is why a single-precision build might pass at all: the round-off exposure of the centered scheme lives entirely in the two ~3500 m terms of [centered-shift], and this form never builds them.

Parameters:
  • ds (xarray.Dataset) – The two-column state, as for centered_shift().

  • anchor ({'surface', 'bathymetry'}) – Which end of the column to accumulate from. §3.7.4 leaves this open as a round-off question rather than a consistency one; the two agree to round-off in double precision, which tests/ocean/horiz_press_grad/test_finite_volume.py measures.

Returns:

shift (xarray.DataArray) – S_{e,k} at layer midpoints, in m.