Skip to content

Commit e51c9dd

Browse files
committed
Added an SQG model.
1 parent 219f360 commit e51c9dd

File tree

2 files changed

+43
-1
lines changed

2 files changed

+43
-1
lines changed

model.py

Lines changed: 39 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -266,6 +266,44 @@ def invmatrix(self, k, l):
266266
return L
267267

268268

269+
class Surface(Model):
270+
271+
"""
272+
Surface QG model
273+
274+
This implements an SQG model that consists of surface buoyancy conserva-
275+
tion and implicit dynamics in an infinitely deep interior determined by
276+
zero PV there. The conserved quantity here is PV-like and implements the
277+
"oceanographic" case, where the surface is an upper surface. The dynamics
278+
can also be used in an "atmospheric" case or a case with an interface
279+
between two semi-infinite layers (see Held et al., 1995). The conserved
280+
quantity is
281+
q[0] = - f b(0) / N^2.
282+
"""
283+
284+
def __init__(self):
285+
Model.__init__(self, 1)
286+
287+
def initmean(self, f, N, Sx, Sy):
288+
"""Set up the mean state."""
289+
self.f = f # Coriolis parameter
290+
self.N = N # buoyancy frequency
291+
# Set up mean flow.
292+
self.u = np.array([0])
293+
self.v = np.array([0])
294+
# Set up mean PV gradients.
295+
self.qx = np.array([- f**2 * Sy / N**2])
296+
self.qy = np.array([+ f**2 * Sx / N**2])
297+
298+
def invmatrix(self, k, l):
299+
"""Set up the inversion matrix L."""
300+
kh = np.hypot(k, l)[:,:,0]
301+
kh[kh == 0.] = 1. # preventing div. by zero for wavenumber 0
302+
L = np.empty((l.size, k.size, 1, 1))
303+
L[:,:,0,0] = - self.f * kh / self.N
304+
return L
305+
306+
269307
class Layered(Model):
270308

271309
"""
@@ -278,7 +316,7 @@ class Layered(Model):
278316

279317
def initmean(self, f, h, g, u, v, beta):
280318
"""Set up the mean state."""
281-
self.f = np.array(f) # Coriolis parameter
319+
self.f = f # Coriolis parameter
282320
self.h = np.array(h) # layer thicknesses
283321
self.g = np.array(g) # buoyancy jumps at interfaces
284322
self.u = np.array(u) # mean zonal flow

run.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,10 @@
3636
#m = model.TwoDim()
3737
#m.initmean(0, 2e-11)
3838

39+
#folder = 'sqg'
40+
#m = model.Surface()
41+
#m.initmean(1e-4, 8e-4, 1e-4, 0)
42+
3943
#folder = 'two-layer'
4044
#m = model.Layered(2)
4145
#m.initmean(1e-4, 2*[250.], [1.6e-2], [2.5e-2, 0.], 2*[0.], 0.)

0 commit comments

Comments
 (0)