Skip to content

Oceanography

Oceanography systems.

The package covers the thermohaline circulation and the wind-driven gyres.

DoubleGyreSystem(n_sites=64, *, length=1.0, beta=1.0, Rd=1.0, nu=0.000125, tau0=1e-05, label='system', solver='auto', backend='auto')

Bases: BaseSystem

The quasi-geostrophic double gyre.

It is the wind-driven circulation of a closed ocean basin.

The potential vorticity q = laplacian(psi) - psi / Rd**2 + beta y of a square basin of side length is carried by the geostrophic velocity (-psi_y, psi_x) of the streamfunction psi, driven by the curl of the wind stress -tau0 cos(2 pi y / length), and damped by the viscosity nu. The state is the relative potential vorticity zeta = q - beta y, held at zero on the walls for free slip, so that

zeta_t + divergence(u zeta) = -beta psi_x - tau0 (2 pi / length) sin(2 pi y / length) + nu laplacian(zeta),

with psi = inverse_helmholtz(zeta, 1 / Rd, ('fixed', 0)). In the viscous steady regime the interior follows the Sverdrup balance beta psi_x = curl(tau), and the return flow closes in Munk western boundary layers of width (nu / beta) ** (1 / 3), so the streamfunction forms a subtropical and a subpolar gyre of opposite sign whose extrema lie close to the western wall. The defaults keep the wind weak, so the boundary layers stay viscous rather than inertial, and the circulation is steady after a few hundred units of time. The catalog entry streams the streamfunction as the observable psi. The system has the relative potential vorticity basin.zeta.

Parameters:

Name Type Description Default
n_sites int

The number of sites along each side of the basin.

64
length float

The side of the basin.

1.0
beta float

The gradient of the planetary vorticity.

1.0
Rd float

The deformation radius.

1.0
nu float

The viscosity.

0.000125
tau0 float

The amplitude of the wind stress.

1e-05
label str

The label of the system, which names it when it is nested in another one.

'system'
solver BaseSolver | str

The solver of the problem, or 'auto' for the one the system chooses.

'auto'
backend BaseBackend | str

The backend that evaluates the compiled functions, or 'auto' for the one the system chooses.

'auto'

Examples:

>>> from skcomplex.systems.physics.oceanography import DoubleGyreSystem
>>> DoubleGyreSystem(16).prepare().system_.elements[0].beta
1.0
Source code in src/skcomplex/systems/physics/oceanography/_gyres.py
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
def __init__(
    self,
    n_sites: int = 64,
    *,
    length: float = 1.0,
    beta: float = 1.0,
    Rd: float = 1.0,
    nu: float = 1.25e-4,
    tau0: float = 1e-5,
    label: str = 'system',
    solver: BaseSolver | str = 'auto',
    backend: BaseBackend | str = 'auto',
) -> None:
    super().__init__(label, solver=solver, backend=backend)
    self.n_sites = n_sites
    self.length = length
    self.beta = beta
    self.Rd = Rd
    self.nu = nu
    self.tau0 = tau0

QuasiGeostrophicSiteElement(label, *, zeta=0.0, beta=1.0, Rd=1.0, nu=0.0001, curl=0.0, space=None)

Bases: Element

Sites of a quasi-geostrophic ocean basin.

Every site holds the relative potential vorticity of the water column at one position.

A site holds the relative potential vorticity zeta = laplacian(psi) - psi / Rd**2, the potential vorticity without the planetary part beta y, with the planetary vorticity gradient beta, the deformation radius Rd, the viscosity nu, and the curl of the wind stress curl at the site.

Parameters:

Name Type Description Default
label str

The label of the basin.

required
zeta object

The initial relative potential vorticity, one value or one per site.

0.0
beta Annotated[float, open(0, oo)]

The gradient of the planetary vorticity.

1.0
Rd Annotated[float, open(0, oo)]

The deformation radius.

1.0
nu Annotated[float, open(0, oo)]

The viscosity.

0.0001
curl object

The curl of the wind stress, one value or one per site.

0.0
space BaseSpace | None

The lattice of the sites, or None for one site.

None

Examples:

>>> from skcomplex.systems.physics.oceanography import QuasiGeostrophicSiteElement
>>> QuasiGeostrophicSiteElement('site').beta
1.0
Source code in src/skcomplex/systems/physics/oceanography/_gyres.py
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
def __init__(
    self,
    label: str,
    *,
    zeta: object = 0.0,
    beta: Annotated[float, RealSet.open(0, oo)] = 1.0,
    Rd: Annotated[float, RealSet.open(0, oo)] = 1.0,
    nu: Annotated[float, RealSet.open(0, oo)] = 1e-4,
    curl: object = 0.0,
    space: BaseSpace | None = None,
) -> None:
    super().__init__(label, space=space)
    self.zeta = zeta
    self.beta = beta
    self.Rd = Rd
    self.nu = nu
    self.curl = curl

StommelInteraction(label, *, target, eta1=3.0, eta2=1.2, eta3=0.3)

Bases: Interaction

Relaxation and mixing of the temperature and salinity differences of two ocean boxes.

The differences T and S of the target follow T' = eta1 - T (1 + |T - S|) and S' = eta2 - S (eta3 + |T - S|), a relaxation to their forcing and a mixing by a flow proportional to the density difference.

Parameters:

Name Type Description Default
label str

The label of the interaction.

required
target Role

The path of the boxes.

required
eta1 float

The thermal forcing.

3.0
eta2 float

The freshwater forcing.

1.2
eta3 float

The ratio of the relaxation times of temperature and salinity.

0.3

Examples:

>>> from skcomplex.systems.physics.oceanography import StommelInteraction
>>> StommelInteraction('circulation', target='ocean', eta2=1.0).eta2
1.0
Source code in src/skcomplex/systems/physics/oceanography/_thermohaline.py
51
52
53
54
55
56
57
58
59
60
61
62
63
64
def __init__(
    self,
    label: str,
    *,
    target: Role,
    eta1: float = 3.0,
    eta2: float = 1.2,
    eta3: float = 0.3,
) -> None:
    super().__init__(label)
    self.target = target
    self.eta1 = eta1
    self.eta2 = eta2
    self.eta3 = eta3

StommelSystem(T=3.0, S=0.0, *, eta1=3.0, eta2=1.2, eta3=0.3, label='system', solver='auto', backend='auto')

Bases: BaseSystem

Stommel's two-box thermohaline circulation.

The circulation is bistable between a thermal and a haline mode.

The dimensionless differences of temperature T and salinity S between an equatorial and a polar box relax to their forcing and are mixed by a flow proportional to the density difference |T - S|: dT/dt = eta1 - T (1 + |T - S|) and dS/dt = eta2 - S (eta3 + |T - S|). For the default parameters a strong circulation driven by temperature and a weak one driven by salinity are both stable. The system has the differences ocean.T and ocean.S.

Parameters:

Name Type Description Default
T float

The initial temperature difference.

3.0
S float

The initial salinity difference.

0.0
eta1 float

The thermal forcing.

3.0
eta2 float

The freshwater forcing.

1.2
eta3 float

The ratio of the relaxation times of temperature and salinity.

0.3
label str

The label of the system, which names it when it is nested in another one.

'system'
solver BaseSolver | str

The solver of the problem, or 'auto' for the one the system chooses.

'auto'
backend BaseBackend | str

The backend that evaluates the compiled functions, or 'auto' for the one the system chooses.

'auto'

Examples:

>>> from skcomplex.systems.physics.oceanography import StommelSystem
>>> StommelSystem(eta2=1.0).prepare().system_.interactions[0].eta2
1.0
Source code in src/skcomplex/systems/physics/oceanography/_thermohaline.py
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
def __init__(
    self,
    T: float = 3.0,
    S: float = 0.0,
    *,
    eta1: float = 3.0,
    eta2: float = 1.2,
    eta3: float = 0.3,
    label: str = 'system',
    solver: BaseSolver | str = 'auto',
    backend: BaseBackend | str = 'auto',
) -> None:
    super().__init__(label, solver=solver, backend=backend)
    self.T = T
    self.S = S
    self.eta1 = eta1
    self.eta2 = eta2
    self.eta3 = eta3

WindStressInteraction(label, *, target)

Bases: Interaction

Input of vorticity into a basin by the curl of the wind stress.

The relative potential vorticity zeta of every site of the target grows at the curl curl of the wind stress at the site, zeta' = curl.

Parameters:

Name Type Description Default
label str

The label of the interaction.

required
target Role

The path of the basin.

required

Examples:

>>> from skcomplex.systems.physics.oceanography import WindStressInteraction
>>> WindStressInteraction('wind', target='basin').target
'basin'
Source code in src/skcomplex/systems/physics/oceanography/_gyres.py
116
117
118
def __init__(self, label: str, *, target: Role) -> None:
    super().__init__(label)
    self.target = target