**El objetivo final es que logren juntar 60 puntos. Es decir resolver 2 problemas por completo. **
Considere un oscilador armónico simple(péndulo), cuya variación en $\theta$ está dada por:
Considere la siguiente función que calcula $\theta$ en $t$. Para responder las siguientes actividades.
In [4]:
import numpy as np
import matplotlib.pyplot as plt
%matplotlib inline
In [5]:
def theta_t(theta_0, theta_0_dot, g, l, t):
omega_0 = np.sqrt(g/l)
return theta_0 * np.cos(omega_0 * t) + theta_0_dot * np.sin(omega_0 * t)/omega_0
Ahora si gráficamos al péndulo en las coordenas $x,y$, se obtiene algo similar a lo siguiente:
In [6]:
t = np.linspace(0,10)
In [7]:
fig = plt.figure(figsize = (5,5))
ax = fig.add_subplot(1, 1, 1)
x = 2 * np.sin(theta_t(.4, .6, 9.8, 2, t))
y = - 2 * np.cos(theta_t(.4, .6, 9.8, 2, t))
ax.plot(x, y, 'ko', ms = 1.5)
ax.plot([0], [0], 'rD')
ax.set_xlim(xmin = -2.2, xmax = 2.2)
ax.set_ylim(ymin = -2.2, ymax = .2)
plt.show()
Actividad 1.1
Actividad 1.2
In [8]:
# Respuesta
import numpy as np
import matplotlib.pyplot as plt
%matplotlib inline
In [9]:
def theta_t(theta_0, theta_0_dot, g, l, t):
omega_0 = np.sqrt(g/l)
return theta_0 * np.cos(omega_0 * t) + theta_0_dot * np.sin(omega_0 * t)
In [10]:
t = np.linspace(0,10)
In [74]:
fig = plt.figure(figsize = (7,5))
ax = fig.add_subplot(1, 1, 1)
x = 2 * np.sin(theta_t(1.57, .6, 9.8, 2, t))
y = - 2 * np.cos(theta_t(1.57, .6, 9.8, 2, t))
ax.plot(x, y, 'bd', ms = 5)
ax.plot([0], [0], 'gD')
ax.set_xlim(xmin = -2.2, xmax = 2.2)
ax.set_ylim(ymin = -2.2, ymax = .2)
plt.show()
In [12]:
# Respuesta
import numpy as np
import matplotlib.pyplot as plt
%matplotlib inline
In [13]:
def theta_t(theta_0, theta_0_dot, g, l, t):
omega_0 = np.sqrt(g/l)
return theta_0 * np.cos(omega_0 * t) + theta_0_dot * np.sin(omega_0 * t)
In [14]:
t = np.linspace(0,10)
In [76]:
fig = plt.figure(figsize = (7,5))
ax = fig.add_subplot(1, 1, 1)
x = 2 * np.sin(theta_t(1.57, 0, 9.8, 2, t))
y = - 2 * np.cos(theta_t(1.57, 0, 9.8, 2, t))
ax.plot(x, y, 'bo', ms = 3)
ax.plot([0], [0], 'gD')
ax.set_xlim(xmin = -3, xmax = 3)
ax.set_ylim(ymin = -3, ymax = .3)
plt.show()
In [16]:
z=x[x<0]
z
Out[16]:
In [17]:
len(x[x<0])
Out[17]:
In [18]:
np.where(x<0)
Out[18]:
In [19]:
x1=x[np.where(x<0)]
In [20]:
x2=x[np.where(x>0)]
In [21]:
y2=y[np.where(x>0)]
In [22]:
y1=y[np.where(x<0)]
In [61]:
fig = plt.figure(figsize = (6,3))
ax = fig.add_subplot(1, 1, 1)
ax.plot(x1, y1, 'm*')
ax.plot(x2, y2, 'cd')
ax.set_xlim(xmin = -3, xmax = 3)
ax.set_ylim(ymin = -3, ymax = .3)
plt.show()
In [24]:
gravedad = np.array ([.5, 1, 2, 4, 8, 16])
In [25]:
def theta_t(theta_0, theta_0_dot, g, l, t):
omega_0 = np.sqrt(g/l)
return theta_0 * np.cos(omega_0 * t) + theta_0_dot * np.sin(omega_0 * t)
for indx, g in enumerate (gravedad):
x = 2 * np.sin(theta_t(.4, .6, g, 2, t))
y = - 2 * np.cos(theta_t(.4, .6, g, 2, t))
(x)
(y)
Out[25]:
In [65]:
cmap= ['red','blue','green','black','orange',]
In [88]:
fig = plt.figure(figsize = (15,10))
for indx, g in enumerate (gravedad):
ax = fig.add_subplot(1, 1, 1)
x = 2 * np.sin(theta_t(1.57, 0, g, 2, t))
y = - 2 * np.cos(theta_t(1.57, 0, g, 2, t))
plt.scatter(x,y, cmap = 'inferno', s= 35, lw=0)
ax.plot(x, y, 'k*', ms = 7)
ax.plot([0], [0], 'gD')
ax.set_xlim(xmin = -2.2, xmax = 2.2)
ax.set_ylim(ymin = -2.2, ymax = .2)
plt.show()
In [ ]:
In [ ]:
Ley de Newton de enfriamiento
La ley empírica de Newton, relativa al enfriamiento de un objeto, se expresa con la ecuación diferencial lineal de primer orden
donde $k$ es una constante de proporcionalidad, $T$ es la temperatura del objeto para $t>0$
In [28]:
def temperatura(T, Tm, k, t):
return k*(T - Tm)
In [29]:
# usar odeint para encontrar la solución. (Puede ayudarle la clase de mapa logistico)
In [30]:
import numpy as np
from scipy.integrate import odeint
import matplotlib.pyplot as plt
%matplotlib inline
Actividad 2.1 ¿Cuánto esperar para tomar el café?
Primero calentamos agua a 80°C . Posteriormente agregamos café al vaso con el agua caliente. Después realizamos la medición de la temperatura ambiente, la cual fue de 24°C.
In [95]:
def temperatura(T,t):
k=-.0565
Tm=34
return k*(T-Tm)
t = np.linspace(0,120)
T0=80
t = np.linspace(0,120)
respuesta = odeint(temperatura,T0,t)
plt.plot(t,respuesta)
plt.xlabel('$t$', fontsize = 40)
plt.ylabel('$T$', fontsize = 40)
plt.show()
Recuerden $C_k$ es la meta $$C_k=C_0(1+ki).$$
$$C_k=C_0(1+i)^k.$$
Actividad 3.1
In [33]:
# Respuesta
In [ ]:
In [ ]:
In [ ]:
In [ ]: