pygetm.momentum module

class pygetm.momentum.CoriolisScheme(*values)[source]

Bases: IntEnum

DEFAULT = 1
ESPELID = 2

Espelid et al. (2000)

OFF = 0
class pygetm.momentum.Momentum(Am: float = 0.0, An: float = 0.0, cnpar: float = 1.0, advection_scheme: AdvectionScheme | None = None, advection_split_2d: AdvectionSplit = AdvectionSplit.FULL, coriolis_scheme: CoriolisScheme = CoriolisScheme.DEFAULT, avmmol: float = 1.8e-06)[source]

Bases: object

Create momentum handler

Parameters:
  • Am – horizontal viscosity (m2 s-1) If provided, this must be a constant.

  • An – horizontal diffusivity (m2 s-1) If provided, this must be a constant. It can subsequently be changed through attribute An, which also allows spatially varying diffusivities to be set.

  • cnpar – parameter for the Crank–Nicolson vertical diffusion solver

  • advection_scheme – advection scheme

  • advection_split_2d – directional splitting for advection solver

  • coriolis_scheme – interpolation method to use to recontruct velocities for Coriolis terms

  • avmmol – molecular viscosity (m2 s-1)

An
An_uu
An_uv
An_vu
An_vv
SS
SxA
SxB
SxD
SxF
SyA
SyB
SyD
SyF
U
Ui
V
Vi
advU
advV
advance(timestep: float, split_factor: int, tausx: Array, tausy: Array, dpdx: Array, dpdy: Array, idpdx: Array, idpdy: Array, viscosity: Array)[source]

Update depth-explicit transports (pk, qk) and velocities (uk, vk). This will also update their halos.

Parameters:
  • timestep – (macro) time step (s)

  • split_factor – number of microtimesteps per macrotimestep

  • tausx – surface stress (Pa) in x-direction

  • tausy – surface stress (Pa) in y-direction

  • dpdx – surface pressure gradient (dimensionless) in x-direction

  • dpdy – surface pressure gradient (dimensionless) in y-direction

  • idpdx – internal pressure gradient (m2 s-2) in x-direction

  • idpdy – internal pressure gradient (m2 s-2) in y-direction

  • viscosity – turbulent viscosity (m2 s-1)

advance_3d_transport(tp3d: Array, tp2d: Array, vel3d: Array, dp: Array, cor: Array, adv: Array, diff: Array, idp: Array, taus: Array, rr: Array, viscosity: Array, dev: Array, timestep: float)[source]

Advance 3D transports (layer-integrated velocities in m2 s-1) in x- or y-direction, using all relevant tendencies supplied as arguments. This also updates the halos.

Note that 3D velocities (transports divided by thicknesses) are not updated here and therefore will be out of sync with transports after this function returns.

advance_depth_integrated(timestep: float, tausx: Array, tausy: Array, dpdx: Array, dpdy: Array)[source]

Update depth-integrated transports (U, V) and depth-averaged velocities (u1, v1). This will also update their halos.

Parameters:
  • timestep – time step (s)

  • tausx – surface stress (Pa) in x-direction

  • tausy – surface stress (Pa) in y-direction

  • dpdx – surface pressure gradient (dimensionless) in x-direction

  • dpdy – surface pressure gradient (dimensionless) in y-direction

advection_scheme
advection_split_2d
advpk
advqk
apply_bottom_friction
avmmol
bottom_friction(u: Array, v: Array, DU: Array, DV: Array, ru: Array, rv: Array, update_z0b: bool = False)[source]

Calculate bottom friction

Parameters:
  • u – velocity in x-direction (m s-1) in bottom layer [U grid]

  • v – velocity in y-direction (m s-1) in bottom layer [V grid]

  • DU – thickness (m) of bottom layer on the U grid

  • DV – thickness (m) of bottom layer on the V grid

  • ru – the square of friction velocity (= stress in Pa divided by density), per actual velocity at the layer center on the U grid

  • rv – the square of friction velocity (= stress in Pa divided by density), per actual velocity at the layer center on the V grid

  • update_z0b – whether to iteratively update the hydrodynamic bottom roughness

cnpar
corU
corV
coriolis(U: Array, out: Array, x_direction: bool)[source]

Calculate change in transport due to Coriolis force

Parameters:
  • U – 2d or 3d transport in x- or y-direction (m2 s-1)

  • out – array to store change in complementary transport (y or x-direction) due to Coriolis force (m2 s-2)

coriolis_scheme
corpk
corqk
dampU
dampV
diffU
diffV
diffpk
diffqk
diffuse_momentum
ea2
ea4
hU_bot
hV_bot
initialize(logger: Logger, tgrid: Grid, runtype: RunType, default_advection_scheme: AdvectionScheme)[source]
logger
pk
qk
rru
rrv
ru
runtype
rv
shear_frequency(uk: Array, vk: Array, viscosity: Array, out: Array)[source]

Calculate squared shear frequency

Parameters:
  • uk – depth-explicit velocity in x-direction (m s-1)

  • vk – depth-explicit velocity in y-direction (m s-1)

  • viscosity – vertical viscosity (m2 s-1)

  • out – array to store squared shear frequency (s-2)

start()[source]
taub
u1
u_V
u_bot
uadv
udev
uk
update_depth_integrated_diagnostics(timestep: float, skip_coriolis: bool = False, update_z0b: bool = False)[source]

Update 2D momentum diagnostics, including the Coriolis terms that will drive the next 2D update.

Parameters:
  • timestep – time step (s) to calculate advection of momentum over

  • skip_coriolis – flag to indicate that Coriolis terms are already up-to-date and do not need recomputing, for instance, after a recent call to advance_depth_integrated()

  • update_z0b – whether to iteratively update hydrodynamic bottom roughness

update_diagnostics(timestep: float, viscosity: Array, skip_coriolis: bool = False)[source]

Update 3D momentum diagnostics, including the vertical velocity ww, the slow terms that will drive the 2D updates over the next macrotimestep, and the bottom friction and Coriolis terms that will drive the next 3D update. NB the Coriolis update is already done as part of the momentum update itself, so needed only when starting from a restart.

Parameters:
  • timestep – time step (s)

  • viscosity – turbulent viscosity (T grid, layer interfaces, m2 s-1)

  • skip_coriolis – flag to indicate that Coriolis terms are already up-to-date and do not need recomputing

ustar2_bx
ustar2_by
ustar_b
uua
uua3d
uva
uva3d
v1
v_U
v_bot
vadv
vdev
vk
vua
vua3d
vva
vva3d
ww