Assignment 1: Flow over an obstacle and channel flow#

For this assignment you will do quantiative analysis for the flow over an obstacle (see Assignment 0: dense flow over an obstacle), and a qualitative analysis of rotating channel flow.

Q1.1 continuity in a box#

Using the simulated data set you produced in Assignment 0: dense flow over an obstacle:

Consider a single time step in the simulation. Define a largish box in your model domain with the sides defined at two values of x, and the top defined by one value of z. The bottom can be defined as the sea floor. Show that the net flow into the box is close to zero. You can express the flow in terms of \(m^2\,s^{-1}\) or \(m^3\,s^{-1}\), but given that the flow is 2-D \(m^2\,s^{-1}\) probably makes more sense.

Hint

Remember that you can do something like ds = ds.sel(xt=slice(-50, 50), xu=slice(-50, 50)) to get the data just between -50 and +50 km. And then repeat for the z direction to define your volume. Check that your shape is correct by doing something like display(ds).

For the vertical direction, w and u are offset from one another, with w on the bottom of the cell, so you want one more zw value than zt value in your final shape. You can do this using either sel or isel and taking care with the limits. For instance I ended up with dimensions ..., zt: 57, zw: 58, .... If you are careful with this, your answer will be closer than if sloppy.

import xarray as xr
import numpy as np
import matplotlib.pyplot as plt
# use the matplotlib widget
%matplotlib widget
# YOUR CODE HERE
raise NotImplementedError()
---------------------------------------------------------------------------
NotImplementedError                       Traceback (most recent call last)
Cell In[2], line 2
      1 # YOUR CODE HERE
----> 2 raise NotImplementedError()

NotImplementedError: 

Q1.2 Calculate the transport in a “layer”#

Consider all water colder than 12 degrees and plot its transport as a function of x along the channel. Do this for one time step (though bonus grades for also doing it as a Hovmoller diagram).

Hint

You can make a version of the data set with u=0 for water warmer than 12 degrees by doing ds['ucold'] = ds.u.where(ds.temp.values<=12, 0). The first argument is the condition, the second is the values to fill in ds.ucold if the condition is False. Don’t forget to use fillna to take care of the NaN’s in the data…

Discuss your result. Is the transport constant? If not, why do you think it is not constant?

# YOUR CODE HERE
raise NotImplementedError()
---------------------------------------------------------------------------
NotImplementedError                       Traceback (most recent call last)
Cell In[3], line 2
      1 # YOUR CODE HERE
----> 2 raise NotImplementedError()

NotImplementedError: 

YOUR ANSWER HERE

Q1.3 x-momentum budget (pointwise!)#

The 2_D x-momentum budget for a non-rotating fluid is:

\[ \frac{\partial u}{\partial t} + u\frac{\partial u}{\partial x} + w\frac{\partial u}{\partial z} = - \frac{1}{\rho} \frac{\partial p}{\partial x} + \nu_z \frac{\partial^2 u}{\partial z^2} + \nu_x \frac{\partial^2 u}{\partial x^2} \]

In the model, \(P\) is given by ds.p_hydro + ds.psi. The vertical viscosity is \(\nu_z=4\times10^{-4} \ \mathrm{m^2\,s^{-1}}\) and the horizontal is \(\nu_x = 10\ \mathrm{m^2\,s^{-1}}\).

Note

In the real world viscosity doesn’t depend on the direction. In the model, the viscosity parameterizes unresolved turbulence. Given that the horizontal scales are much larger than the vertical, the model works better if the horizontal viscsity is larger than the vertical.

For one timestep, calculate these terms at each point in the model and compare.

# YOUR CODE HERE
raise NotImplementedError()
---------------------------------------------------------------------------
NotImplementedError                       Traceback (most recent call last)
Cell In[4], line 2
      1 # YOUR CODE HERE
----> 2 raise NotImplementedError()

NotImplementedError: 

Q1.4 Describe#

Describe the breakdown of terms in the x-momentum budget. Focus in particular over obstacle, though the unsteady behaviour far from the obstacle is useful to think about as well.

  • Where is the flow almost in “steady state”?

  • What are the dominant terms in the momentum budget? Write out an approximate balance that would explain most of the balance.

  • Are the left- and right-hand terms exactly in balance. Any ideas why they are or are not.

  • Explain the sense of the the largest terms in terms of the structure of the flow (eg does the structure of the terms make sense with respect to the flow?).

YOUR ANSWER HERE

Q1.5 Internal versus external pressure#

Similar to the above, compare the external pressure due to surface tilt (psi) to the internal pressure (p_hydro) at a given depth, preferably one that goes through the overflowing water.

First, make a Hovmoller diagram of the surface pressure. Try and describe what you see - any idea what causes this?

# YOUR CODE HERE
raise NotImplementedError()
---------------------------------------------------------------------------
NotImplementedError                       Traceback (most recent call last)
Cell In[5], line 2
      1 # YOUR CODE HERE
----> 2 raise NotImplementedError()

NotImplementedError: 

YOUR ANSWER HERE

Q1.5 continued#

We need to do some smoothing to try and ignore the effect shown above, so average the data by 4 or 6 timesteps. Then compare the internal to the surface pressure gradient at a depth that includes the overflow.

Compare and contrast the two pressure signals. Does the pressure gradients make sense with respect to the direction that water flows? How many centimeters of surface defelection would you expect to see for the given external pressure gradient?

# YOUR CODE HERE
raise NotImplementedError()
---------------------------------------------------------------------------
NotImplementedError                       Traceback (most recent call last)
Cell In[6], line 2
      1 # YOUR CODE HERE
----> 2 raise NotImplementedError()

NotImplementedError: 

YOUR ANSWER HERE

Q2: Channel flow Qualitative#

In this simulation, we have a 50-m deep channel with quite steep sides 20 km apart in the y-direction. The flow starts at rest when a wind stress of \(\tau=0.2\,\mathrm{N\,m^{-2}}\) is applied in the positive x direction at time = 0. This is called a spin-up problem. We will do two simulations, one with rotation \(f=10^{-4}\ \mathrm{rad\, s^{-1}}\) and the other without.

Note that this problem has no variability in the x direction (though there is definitely x-direction velocities!), so we don’t use much resolution in the x direction.

Run channelnof.py and channelfplane.py and plot the outputs:

  • plot some represntative time steps of the channel crosssections (y versus z) for each run.

  • choose a time step at the end of the simulation and one location and plot u on the x-axis and v on the y-axis with a dot for each depth. This is called a “hodogram”.

  • what are the differences between the solution with rotation ansd the solution without rotation?

# YOUR CODE HERE
raise NotImplementedError()
---------------------------------------------------------------------------
NotImplementedError                       Traceback (most recent call last)
Cell In[7], line 2
      1 # YOUR CODE HERE
----> 2 raise NotImplementedError()

NotImplementedError: 
# YOUR CODE HERE
raise NotImplementedError()
---------------------------------------------------------------------------
NotImplementedError                       Traceback (most recent call last)
Cell In[8], line 2
      1 # YOUR CODE HERE
----> 2 raise NotImplementedError()

NotImplementedError: 

YOUR ANSWER HERE