Source Of Complexity

Governing equations

Heat transfer

The challenge in this practical is to calculate the heat flux across the bottom of the ocean thermocline by solving the diffusion equation in the vertical.

Specifications of the ocean thermocline

Typically the ocean is stably strati ed and its density increases very slowly with depth. A mixed layer exists in the top 10 to 100m of the ocean due mainly to mechanical stirring by turbulence associated with wind stresses. Between the mixed layer and the deep ocean there can be a strong temperature gradient called the thermocline. In this practical, assume that the mixed layer is very shallow so that fluxes from the atmosphere feed directly into the thermocline. Take the thermocline to have a fixed depth of 200m with uniform thermal diffusivity and density . The abyssal ocean below is at a fixed temperature of

Initial and boundary conditions

Initially, the temperature is well-mixed across the top 20m with a temperature of . Temperature decreases linearly from 20m to the abyssal temperature ( ) at 200m depth. Assume that there are no fuxes across the top and bottom boundaries of the thermocline.

Question

Write a program to solve this model.

Question

Use a time-step of 3,600s. Conduct a 5-day experiment and investigate the change in temperature profile with time by plotting temperature versus depth at least once per day.

Question

Now implement more realistic boundary conditions. Assume that there is a constant heat flux into the ocean surface at rate and the temperature of the bottom boundary is fixed and equal to the abyssal temperature. In this case the flux across the bottom boundary is not specified. Run the model for 1,000 days

Solution
1
# -*- coding: utf-8 -*-
2
"""
3
Created on Tue May 10 10:08:27 2016
4
Program to model the diffusion of temperature
5
@author: yacine.mezemate
6
"""
7
8
import numpy as np
9
import matplotlib.pyplot as plt
10
11
#define the physical constants
12
dcoeff=1.0e-3         # diffusion coefficient (m^2/s)
13
depth=200.            # thermocline depth (m)
14
density=1000          # density (kg m^-3)
15
tint=5*86400.       # total run length (secs)
16
fluxtop=0.01          # flux into thermocline (kg m^-2 K s^-1)
17
18
# define the numerical constants
19
nlev=20               # Number of model levels
20
dz=depth/nlev         # Spacing between model levels
21
dt=3600.0             #time-step (unit=secs)
22
nsteps=tint/dt        #number of time-steps
23
dfac=dcoeff*dt/(dz*dz) #factor used in numerical scheme
24
25
#declare arrays to store the results
26
27
z= np.zeros(nlev)
28
tempnew=np.zeros(nlev) # new value of temperature (in each layer)
29
temp=np.zeros(nlev) # current temperature
30
tinit=np.zeros(nlev) # initial temperature
31
time=np.zeros(nsteps)  #array of time-points
32
fluxbot=np.zeros(nsteps) # flux through bottom of thermocline
33
34
# fill in the initial values of the arrays
35
t=0.0;
36
tair=27.0;
37
tabyss=7.0;
38
zmix=20 # depth of the well-mixed part of initial profile
39
40
# specify initial temperature profile
41
for i in range(0,nlev):
42
    z[i] = (i -0.5)*dz
43
    tinit[i]=tabyss+(tair-tabyss)*(z[i]-depth)/(zmix-depth)
44
    if (tinit[i] > tair):
45
        tinit[i] = tair        
46
temp = tinit
47
48
for n in range(0,int(nsteps)):
49
    #Find new temperature in the top layer (applying flux BCs)   
50
    tempnew[0]=temp[0]+dfac*(temp[1]-temp[0])+fluxtop*dt/(density*dz)    
51
    #Find new temperature for all interior layers
52
    for j in range(1,nlev-1):
53
        tempnew[j]=temp[j]+dfac*(temp[j+1]-2*temp[j]+temp[j-1])
54
    #Find new temperature in the bottom layer (applying fixed value BCs)
55
    tempnew[nlev-1]=temp[nlev-1]+dfac*(2*tabyss-3*temp[nlev-1]+temp[nlev-2])
56
    # Find flux through bottom of the thermocline
57
    time[n]=t/86400
58
    fluxbot[n]=-density*dcoeff*(temp[nlev-1]-tabyss)/(z[nlev-1]-depth)
59
    t=t+dt  #Find the new time-point
60
    temp=tempnew  #Copy new temperatures into temp array before next step
61
62
plt.figure(1)
63
plt.plot(tinit,-z, label='Initial')
64
plt.plot(tempnew,-z, label='1000 days')
65
plt.legend('loc= down left')
66
plt.title("Diffusion of temperature using fixed flux into top and fixed value at bottom")
67
plt.xlabel("Temperature (C)")
68
plt.ylabel("Z(m)")
69
plt.show()
70
71
plt.figure(2)
72
plt.plot(time,fluxbot)
73
plt.title("Flux out of the bottom of the thermocline versus time")
74
plt.xlabel("Time (days)")
75
plt.ylabel("Flux")
76
plt.show()
77
(a): Temperature obtained after 5 days using flux boundary conditions. (b): Flux out of the bottom of the thermocline versus time
PreviousPreviousNextNext
HomepageHomepagePrintPrintCreated with Scenari (new window)