In [ ]:
import numpy as np
import matplotlib.pyplot as plt

from sympy.mpmath import odefun
from sympy.interactive import printing
from sympy import Eq, Function, Derivative
from sympy import symbols, lambdify, dsolve, cos, sin

printing.init_printing()

In [ ]:
t = symbols('t')
g, f, ix = symbols('g f i_x', real=True) #nonzero=True, constant=True)
u = Function('u')
v = Function('v')

time = np.arange(10)
subs = [(g, -9.8), (ix, 1e-1), (f, 1e-4)]

Equação para $x$:


In [ ]:
dudt = Eq(Derivative(u(t), t), -g*ix + f*v(t))
dudt

Equação para $y$:


In [ ]:
dvdt = Eq(v(t).diff(t), -f*u(t))
dvdt

Fazendo $\dfrac{\partial}{\partial t}$ da eq. para $x$ e substituindo na eq. para $y$:


In [ ]:
d2udt2 = Eq(u(t).diff(t, t) - f*(-f*u(t)), 0)
d2udt2

Temos uma equação diferencial homogênea de segunda ordem. A Solução tem a forma:


In [ ]:
soln = dsolve(d2udt2, u(t))
soln

São necessárias no mínimo duas condições de contorno para resolver uma eq. de segunda ordem. Usaremos:

\begin{align*} u&=0, \quad t=0 \\ v&=0, \quad t=0 \end{align*}


In [ ]:
soln.subs(t, 0)

Logo, a constante $C_2$ é 0. Subistituindo temos.


In [ ]:
C2 = symbols('C_1', constant=True)

cond1 = Eq(u(t), C2*sin(t*abs(f)))
cond1

Substituindo na eq. para $x$ termos:


In [ ]:
app = dudt.subs(u(t), cond1.rhs)
app

In [ ]:
app = app.doit()
app

In [ ]:
a = app.subs(t, 0).subs(v(0), 0)
a

In [ ]:
import numpy as np
import seawater as sw
import matplotlib.pyplot as plt

lat = 10  # 30, 45, 60, 90
ix = 0.01  # 0.001
n_cycles = 4

g = sw.g(lat)
f = sw.f(lat)
time = np.linspace(0, n_cycles*2*np.pi, 100)

# Scales.
T = f
L = g*ix / f**2
U = g*ix / f

time /= T
x =  g*ix / f**2 * (np.cos(f*time) - 1 )
x = x / L
y =  g*ix / f**2 * (f*time - np.sin(f*time) )
y = y / L

u = -g*ix / f*np.sin(f*time)
v =  g*ix / f*(1 -np.cos(f*time))
u = u / U
v = v / U

time *= T
kw = dict(nrows=2, ncols=2, sharex=True, figsize=(12, 4))
fig, ((ax0, ax1), (ax2, ax3)) = plt.subplots(**kw) 
ax0.plot(time, u, 'k--')
ax0.set_ylabel('u-velocity')

ax1.plot(time, x, 'k--')
ax1.set_ylabel('x-displacement')
plt.xticks([0, 2*np.pi, 4*np.pi, 8*np.pi],
           ['$0$', r'$2\pi$', r'$4\pi$', r'$8\pi$'])

ax2.plot(time, v, 'k--')
ax2.set_ylabel('v-velocity')
ax2.set_xlabel('time')

ax3.plot(time, y, 'k--')
ax3.set_ylabel('y-displacement')
ax3.set_xlabel('time')
_ = plt.xticks([0, 2*np.pi, 4*np.pi, 6*np.pi, 8*np.pi],
               ['$0$', r'$2\pi$', r'$4\pi$', r'$6\pi$', r'$8\pi$'])

In [ ]:
fig, ax = plt.subplots(figsize=(6, 2))
ax.plot(y, x, 'k')
ax.set_xlabel('y')
ax.set_ylabel('x')
_ = plt.xticks([0, 2*np.pi, 4*np.pi, 6*np.pi, 8*np.pi],
               ['$0$', r'$2\pi$', r'$4\pi$', r'$6\pi$', r'$8\pi$'])

In [ ]: