Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
johnryantaylor committed Nov 14, 2024
2 parents e44e5dd + d1aef64 commit 3473ce7
Show file tree
Hide file tree
Showing 8 changed files with 38 additions and 32 deletions.
4 changes: 2 additions & 2 deletions Project2/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ Although most natural flows are time-varying, and have complicated spatial struc
Kelvin-Helmholtz billows developing in a cloud layer over Mount Shasta, California. Photo copyright 1999, Beverly Shannon.

## Introduction
Here, we will examine the basic stability properties of a stratified shear flow, and will then use Diablo to examine the nonlinear evolution of the unstable state.
Here, we will examine the basic stability properties of a stratified shear flow, and will then use Oceananigans to examine the nonlinear evolution of the unstable state.

Start by considering a stratified shear flow of the form:

Expand Down Expand Up @@ -55,6 +55,6 @@ Finally, try making a plot of the gradient Richardson number as a function of de
In a stratified flows, kinetic energy can be converted to potential energy by mixing the stable density profile, raising the center of mass of the fluid. Some kinetic energy is also lost to viscous dissipation. The mixing efficiency, $\Lambda$,of great interest in the stratified turbulence literature, is the ratio of the kinetic energy used to mix the density profile to the loss to viscous dissipation. Set up and run a simulation of K-H instability using Oceananigans, and let the flow evolve long enough so that it settles back into a non-turbulent state (you may need to decrease the resolution for this, and you might also want to increase the size of the domain in $z$ to minimise boundary effects). Calculate the kinetic and potential energy at the start and end of the simulation, and the change over the simulation, $\Delta KE$ and $\Delta PE$. Calculate the flux coefficient $\Gamma \equiv B/\epsilon \simeq \Delta PE/(-\Delta KE-\Delta PE)$, where $B$ is the buoyancy flux, and $\epsilon$ is the kinetic energy dissipation. Then, use the flux coefficient to estimate the mixing efficiency, $\eta$, using the relation $\Gamma=\eta/(1-\eta)$. Many parameterizations for mixing in the ocean and atmosphere use a constant mixing efficiency with a value close to $\eta \simeq 0.2$. How does your result compare? Using time series of the kinetic and potential energy, can you estimate the instantaneous mixing efficiency as a function of time?

## Holmboe instability
When the profiles of shear and stratification are not identical, a second type of instability called 'Holmboe instability' can develop. Specifically, this instability develops when the width of the shear layer is larger than the width of the stratified layer. Holboe instability is characterized by disturbances that propagate relative to the mean flow, while the billows associated with Kelvin-Helmholtz instability remain nearly stationary. Repeat the process used to analyze K-H instability (starting from the linear stability analysis), but use a buoyancy profile where the width of the tanh is a factor of four smaller than for the velocity. Can you identify Holmboe instability based on the stability analysis? Once you find a set of parameters where Holmboe instability grows faster than K-H, try simulating it in Oceananigans. Note that you may need to increase the Reynolds number or Prandtl number in this simulation to prevent the density interface from smearing out too broadly before the simulation begins.
When the profiles of shear and stratification are not identical, a second type of instability called 'Holmboe instability' can develop. Specifically, this instability develops when the width of the shear layer is larger than the width of the stratified layer. Holboe instability is characterized by disturbances that propagate relative to the mean flow, while the billows associated with Kelvin-Helmholtz instability remain nearly stationary. Repeat the process used to analyze K-H instability (starting from the linear stability analysis), but use a buoyancy profile where the width of the tanh used to create the initial buoyancy profile is smaller than for the velocity. The parameters listed in Table 1 from [Salehipour et al.](./papers/Salehipour.pdf) should provide a good starting point. Can you identify Holmboe instability based on the stability analysis? Once you find a set of parameters where Holmboe instability grows faster than K-H, try simulating it in Oceananigans. Note that you may need to increase the Reynolds number or Prandtl number in this simulation to prevent the density interface from smearing out too broadly before the simulation begins.


Binary file added Project2/papers/Salehipour.pdf
Binary file not shown.
4 changes: 2 additions & 2 deletions Project3/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@ To gain further insight, add code to `rossbywave.jl` to calculate and save the a
Try adding a non-zero zonal (east/west) mean flow to your initial conditions (in other words add a function $g(y)$ to $u_i$.) How does this modify the phase speed of the waves? Explore various configurations for the mean flow and the wave perturbations. For example, what happens if the wave perturbations are isolated to a region with zero or non-zero mean flow? How do the waves interact with the mean flow and how does this vary with the amplitude of the waves and the mean flow?

### Rossby graveyard
[Zhai et al.](papers/Zhai.pdf) proposed that a significant amount of energy is dissipated when nonlinear Rossby waves and westward propagating eddies 'break' at western boundaries. Change the topology of the grid to `bounded` in the x-direction, and apply either free-slip (the default) or no-slip boundary conditions (perhaps try both). Examine what happens when the Rossby waves encounter the boundary on the western side of the domain. How do the results change when you vary the amplitude of the initial velocity perturbation?
[Zhai et al.](./papers/Zhai.pdf) proposed that a significant amount of energy is dissipated when nonlinear Rossby waves and westward propagating eddies 'break' at western boundaries. Change the topology of the grid to `bounded` in the x-direction. What happens when the Rossby waves encounter the boundary on the western side of the domain? How do the results change when you vary the amplitude of the initial velocity perturbation?

### Zonal jets
When the amplitude of the initial perturbation is large, the resulting flow will be highly nonlinear. In 2D (or quasi-geostrophic) turbulence, energy is transferred on average to large scales. On a $\beta$-plane, this eventually manifests in the spontaneous formation of zonal jets, e.g. east/west flow that is also coherent in the east/west direction. This was discussed in a classic paper by [Rhines](papers/Rhines75.pdf) who proposed that the jets form with a horizontal lengthscale set by $(U/\beta)^{1/2}$. This process is thought to be important in forming the zonal jets (and banded cloud patterns) on Jupiter and the other gas giants. Explore the formation and dynamics of zonal jets by varying the parameters in `rossbywaves.jl`. For a velocity perturbation with a fixed amplitude, how does the number of jets that form depend on $\beta$? Are the jets stationary, or do they meander?
When the amplitude of the initial perturbation is large, the resulting flow will be highly nonlinear. In 2D (or quasi-geostrophic) turbulence, energy is transferred on average to large scales. On a $\beta$-plane, this eventually manifests in the spontaneous formation of zonal jets, e.g. east/west flow that is also coherent in the east/west direction. This was discussed in a classic paper by [Rhines](./papers/Rhines75.pdf) who proposed that the jets form with a horizontal lengthscale set by $(U/\beta)^{1/2}$. This process is thought to be important in forming the zonal jets (and banded cloud patterns) on Jupiter and the other gas giants. Explore the formation and dynamics of zonal jets by varying the parameters in `rossbywaves.jl`. For a velocity perturbation with a fixed amplitude, how does the number of jets that form depend on $\beta$? Are the jets stationary, or do they meander?

2 changes: 1 addition & 1 deletion Project3/rossbywave.jl
Original file line number Diff line number Diff line change
Expand Up @@ -67,4 +67,4 @@ simulation.output_writers[:jld2] = JLD2OutputWriter(model, (; u, v, w, c),
run!(simulation)

# Make a plot of u at y=Ly/2 and save a movie
include("plot_rossbywave.jl")
include("plot_rossbywave.jl")
8 changes: 3 additions & 5 deletions Project4/PZ.jl
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,7 @@ end
# The following tells OceanBioME and Oceananigans which tracers are needed
required_biogeochemical_tracers(::PhytoplanktonZooplankton) = (:P, :Z)

function light(a,λ,z)
a * exp(z/λ)
end
@inline light(a,λ,z) = a * exp(z / λ)

# The following function defines the forcing (RHS) for the phytoplankton (prey)
# Note that when running as a box model (PZ_box.jl), z = 0
Expand All @@ -41,7 +39,7 @@ end
γ = bgc.zooplankton_mortality_rate
λ = bgc.light_decay_length
a = bgc.light_amplitude
return light(a,λ,z) * α * P - β * P * Z
return light(a, λ, z) * α * P - β * P * Z
end

# The following function defines the forcing (RHS) for the zooplankton (predator)
Expand All @@ -50,7 +48,7 @@ end
β = bgc.grazing_rate
δ = bgc.grazing_efficiency
γ = bgc.zooplankton_mortality_rate
return β *δ * P * Z - γ * Z
return β * δ * P * Z - γ * Z
end

using Oceananigans.Fields: ZeroField, ConstantField
Expand Down
2 changes: 1 addition & 1 deletion Project4/PZ_cavity.jl
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ w_bcs = FieldBoundaryConditions(east = ValueBoundaryCondition(0.0), west = Value
λ = 0.1
w₀ = 0.05

w_sinking(x, y, z) = - w₀ * (tanh(z/λ) - tanh((-z - 1)/λ) - 1)
w_sinking(x, y, z) = - w₀ * (tanh(-z / λ) - tanh((-z - 1) / λ) - 1)

sinking_velocity = Oceananigans.Fields.FunctionField{Center, Center, Center}(w_sinking, grid)

Expand Down
6 changes: 3 additions & 3 deletions Project4/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ This is illustrated in the figure below which shows two quasi true-color satelli

Fluid dynamics has a very strong influence on phytoplankton (and hence the global carbon cycle). Sunlight needed for photosynthesis illuminates a relatively thin layer of the upper ocean. When phytoplankton are advected into the dark ocean interior for extended periods of time, they will become dormant or die. Different populations of phytoplankton, the nutrients that they rely on, and their predators are co-mingled and mixed by ocean currents.

This project will use [OceanBioME.jl](https://github.com/OceanBioME/OceanBioME.jl)) (Ocean Biogeochemical Modelling Environment), a Julia package developed in the DAMTP Ocean Dynamics group at Cambridge to provide biogeochemical models for Oceananigans. OceanBioME has powerful features including state-of-the-art biogeochemical models, models for the air-sea gas exchange, sediment models, and biologically-active particles. Here, we will use OceanBioME to provide a model of the predator-prey dynamics of a population of phytoplankton and zooplankton. We will then use Oceananigans to explore how advection and diffusion modifies the intrinsic ecosystem dynamics.
This project will use [OceanBioME.jl](https://github.com/OceanBioME/OceanBioME.jl) (Ocean Biogeochemical Modelling Environment), a Julia package developed in the DAMTP Ocean Dynamics group at Cambridge to provide biogeochemical models for Oceananigans. OceanBioME has powerful features including state-of-the-art biogeochemical models, models for the air-sea gas exchange, sediment models, and biologically-active particles. Here, we will use OceanBioME to provide a model of the predator-prey dynamics of a population of phytoplankton and zooplankton. We will then use Oceananigans to explore how advection and diffusion modifies the intrinsic ecosystem dynamics.

Before you can use the code for this project, you will need to install OceanBioME. To do this, from the Julia REPL (command prompt), type `]`, followed by `add OceanBiome`. Once the package installs, return to the command prompt using the `delete` key.
OceanBioME is included in the FDSE project environment, so if you type `activate .` and `instantiate` in the Julia package manager starting from the FDSE folder, you will already have it installed. If you have installed the packages manually, you will need to install OceanBioME using the package manager. From the Julia REPL (command prompt), type `]`, followed by `add OceanBiome`. Once the package installs, return to the command prompt using the `delete` key.

# 0-dimensional 'box' model
Although OceanBioME is primarily intended to be coupled with Oceananigans, it can be used on its own to integrate the equations describing the dynamics of the ocean ecosystem. This is useful for developing an understanding of the intrinsic ecosystem dynamics, before adding the complications of fluid dynamics, and for debugging new models.
Expand Down Expand Up @@ -43,7 +43,7 @@ Consider the timescales involved in this system associated with advection, diffu
# Suggested further investigations

## Buoyant / sinking phytoplankton
Often phytoplankton cells are slightly more or less dense than the surrounding seawater, causing them to slowly sink or rise in the absence of vertical currents. There is a parameter in `PZ.jl` called `sinking_velocity` which causes the phytoplankton to rise or sink with a prescribed vertical velocity relative to the surrounding water (note that positive values of the parameter correspond to rising motion and negative values correspond to sinking motion). Try changing this parameter and explore the consequences on the predator-prey system. You can explore the effect of this change both in `PZ_column.jl` and `PZ_cavity.jl`. Note that you might need to reduce the size of the timestep to prevent numerical instabilities.
Often phytoplankton cells are slightly more or less dense than the surrounding seawater, causing them to slowly sink or rise in the absence of vertical currents. There is a parameter in `PZ.jl` called `sinking_velocity` which causes the phytoplankton to rise or sink with a prescribed vertical velocity relative to the surrounding water (note that positive values of the parameter correspond to rising motion and negative values correspond to sinking motion). Try changing this parameter and explore the consequences on the predator-prey system with `PZ_cavity.jl`. Note that you might need to reduce the size of the timestep to prevent numerical instabilities.

Note that in order to conserve total phytoplankton in our domain, it necessary to define the sinking velocity so that it goes to zero at the top and bottom boundaries. To do this, we can use a function field so that the sinking velocity will be a function of space. For example:
```julia
Expand Down
44 changes: 26 additions & 18 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,29 @@ https://docs.julialang.org/en/v1/manual/noteworthy-differences/

Julia is a modern programming language which is as easy to use as python or Matlab, but provides the speed of languages like Fortran and C.

There are two ways of working with the projects in this repository: you can either install the required software on your own computer, or run the code in a browser using GitHub Codespaces. If you want to spend time going through the projects and tinker with the code, then we recommend downloding on your own computer. The projects have been designed to run quickly even on slow laptops.

<details>
<summary>Instructions to run FDSE projects on GitHub Codespaces</summary>

The instructions below describe how to run the projects using [GitHub codespaces](https://github.com/features/codespaces), which is useful if you don't have Julia installed and want to have a quick look at the projects, or have problems installing Julia.

To run this way:
1. Fork this repository by clicking the "Fork" button above
2. In your fork click the "<> Code" button, move to the "Codespaces" tab, then "Creat codespaces on main"
<img width="421" alt="Screenshot 2023-09-06 at 15 24 55" src="https://github.com/jagoosw/FDSE/assets/26657828/cd90bd7e-33d8-4b02-849f-ed11b8de1a6e">

3. This will open a codespace which may take a while to setup
4. Once everything has been setup open the command palette by clicking "View > Command Palette", then select "Julia: Start REPL"
5. Once this is open type `]` to open the package manager, type `instantiate` and return, this will install the required packages and may take a while
6. Once this is done you can run the project files by opening them in the editor and clicking the run arrow in the top right corner.

You can run codespaces for 60 hours a month with a normal GitHub account, or if you are a student you can [upgrade to GitHub Pro for free](https://education.github.com/pack) which will give you 180 hours a month.
</details>

<details>
<summary>Instructions to install and run on your own computer</summary>

Julia comes with a REPL (which stands for read-evaluate-print-loop) which provides a command-line interface much like python or Matlab. While it is possible to use this on its own, we suggest using a code development platform which provides a single tool to edit and run the scripts and display plots. In particular, we recommend Visual Studio Code which is an excellent tool and free to use.

For the recommended installation, follow these steps:
Expand All @@ -27,28 +50,13 @@ For the recommended installation, follow these steps:
14. Find and install the Julia Language Support extension in VS code
15. Find and install the GitHub Pull Requests and Issues extension in VS code

For the next steps, see the README file inside the Project 1 folder.

<details>
<summary>Alternative setup instructions in GitHub Codespaces</summary>

An alternative way to run these projects is in [GitHub codespaces](https://github.com/features/codespaces) which is useful if you have problems installing Julia etc.

To run this way:
1. Fork this repository by clicking the "Fork" button above
2. In your fork click the "<> Code" button, move to the "Codespaces" tab, then "Creat codespaces on main"
<img width="421" alt="Screenshot 2023-09-06 at 15 24 55" src="https://github.com/jagoosw/FDSE/assets/26657828/cd90bd7e-33d8-4b02-849f-ed11b8de1a6e">

3. This will open a codespace which may take a while to setup
4. Once everything has been setup open the command palette by clicking "View > Command Palette", then select "Julia: Start REPL"
5. Once this is open type `]` to open the package manager, type `instantiate` and return, this will install the required packages and may take a while
6. Once this is done you can run the project files by opening them in the editor and clicking the run arrow in the top right corner.

You can run codespaces for 60 hours a month with a normal GitHub account, or if you are a student you can [upgrade to GitHub Pro for free](https://education.github.com/pack) which will give you 180 hours a month.
</details>

For the next steps, see the README file inside the Project 1 folder.

I hope you enjoy the projects!

John Taylor



Expand Down

0 comments on commit 3473ce7

Please sign in to comment.