In [ ]:
from IPython.core.display import HTML
with open('../../common/creativecommons.html', 'r') as f:
html = f.read()
with open('../../common/custom.css', 'r') as f:
styles = f.read()
HTML(styles)
text = 'Check this post at'
uri = 'http://nbviewer.ipython.org/urls/raw.github.com/ocefpaf/python4oceanographers/master/content/downloads/notebooks'
name = get_notebook_name()
link = """<p>%s <a href="%s/%s"><em>nbviewer</em>.</a></p>""" % (text, uri, name)
html += str(link)
In [ ]:
import numpy as np
import matplotlib.pyplot as plt
Short-wave dispersion relationship: $\omega = \sqrt{gk}$
In [ ]:
L = 15 # Lambda [m]
H = 20. # Water column depth [m].
N0 = 0.5 # Wave amplitude [m].
K = 2 * np.pi / L # Wave number [m^{-1}].
g = 9.8 # Gravity [m s^{-2}].
w = np.sqrt(g * K) # Short-wave dispersion [rad s^{-1}].
T = 2 * np.pi / w # Period [s].
t = np.arange(0, 2 * T, 0.1) # Two waves.
x = 0
z00, z02, z04, z06, z08, z10 = 0, -2, -4, -6, -8, -10 # Depths to plot.
In [ ]:
HoL = H/L
if HoL > 1./2:
print("H/L = %s. Short-wave! " % HoL)
else:
print("H/L = %s. This is not a shortwave :( " % HoL)
The code below solve the following equations:
Free surface displacement: $\eta = N_o\cos({kx - \omega t})$
x displacement: $\chi = -\eta_o\sin({kx - \omega t})[\cosh(kz) + \sinh(kz)]$
z displacement: $\zeta = \eta_o\cos({kx - \omega t})[\cosh(kz) + \sinh(kz)]$
In [ ]:
N = N0 * np.cos((K * x) - (w * t))
X00 = N0 * np.sin(K * x - w * t) * (np.cosh(K * z00) + np.sinh(K * z00))
X02 = N0 * np.sin(K * x - w * t) * (np.cosh(K * z02) + np.sinh(K * z02))
X04 = N0 * np.sin(K * x - w * t) * (np.cosh(K * z04) + np.sinh(K * z04))
X06 = N0 * np.sin(K * x - w * t) * (np.cosh(K * z06) + np.sinh(K * z06))
X08 = N0 * np.sin(K * x - w * t) * (np.cosh(K * z08) + np.sinh(K * z08))
X10 = N0 * np.sin(K * x - w * t) * (np.cosh(K * z10) + np.sinh(K * z10))
Z00 = N0 * np.cos(K * x - w * t) * (np.sinh(K * z00) + np.cosh(K * z00))
Z02 = N0 * np.cos(K * x - w * t) * (np.sinh(K * z02) + np.cosh(K * z02)) + z02
Z04 = N0 * np.cos(K * x - w * t) * (np.sinh(K * z04) + np.cosh(K * z04)) + z04
Z06 = N0 * np.cos(K * x - w * t) * (np.sinh(K * z06) + np.cosh(K * z06)) + z06
Z08 = N0 * np.cos(K * x - w * t) * (np.sinh(K * z08) + np.cosh(K * z08)) + z08
Z10 = N0 * np.cos(K * x - w * t) * (np.sinh(K * z10) + np.cosh(K * z10)) + z10
In [ ]:
# Figure.
fig, ax = plt.subplots(figsize=(4, 4))
ax.plot(X00, Z00, 'k',
X02, Z02, 'k',
X04, Z04, 'k',
X06, Z06, 'k',
X08, Z08, 'k',
X10, Z10, 'k')
ax.set_title(u'Ondas de águas profundas (ou ondas curtas)')
ax.set_xlabel(u'Distância [m]')
ax.set_ylabel('Profundidade [m]')
x = np.linspace(-X00.max()*10, X00.max()*10, N.size)
ax.plot(x, N, 'k:')
ax.grid(True)
ax.annotate(r'$\eta$', xy=(x[-4], N[-4]), xycoords='data',
xytext=(20, 20), textcoords='offset points',
arrowprops=dict(arrowstyle="->", connectionstyle="arc3,rad=0.2"))
fig.tight_layout()
In [ ]:
HTML(html)