Diferencia entre revisiones de «Ecuación del calor MMA»
De MateWiki
| (No se muestran 4 ediciones intermedias de 2 usuarios) | |||
| Línea 5: | Línea 5: | ||
Andrea Sánchez}} | Andrea Sánchez}} | ||
| − | [[Archivo: foto MMA. | + | [[Archivo: foto MMA.jpeg||800px]] |
| + | === Dispersión de partículas === | ||
| + | <syntaxhighlight lang="python"> | ||
| − | + | import numpy as np | |
| + | import matplotlib.pyplot as plt | ||
| + | # Parámetros | ||
| + | np.random.seed(42) | ||
| + | n_particles = 400 | ||
| + | times = [0.05, 0.4, 1.0] | ||
| − | + | fig, axes = plt.subplots(1, 3, figsize=(12, 4)) | |
| − | + | for ax, t in zip(axes, times): | |
| + | # Movimiento aleatorio (normal) | ||
| + | x = np.random.normal(0, np.sqrt(t), n_particles) | ||
| + | y = np.random.normal(0, np.sqrt(t), n_particles) | ||
| − | + | ax.scatter(x, y, s=10, alpha=0.7) | |
| − | + | ax.set_title(f"t = {t}") | |
| + | ax.set_aspect("equal") | ||
| − | + | # Límites visuales | |
| − | + | ax.set_xlim(-4, 4) | |
| + | ax.set_ylim(-4, 4) | ||
| + | ax.grid(True) | ||
| − | + | fig.suptitle("Dispersión de partículas") | |
| − | + | plt.tight_layout() | |
| + | plt.show() | ||
| − | + | </syntaxhighlight> | |
| − | + | ||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | + | === Trayectorias de movimiento browniano === | |
| − | + | ||
| − | + | <syntaxhighlight lang="python"> | |
| − | + | import numpy as np | |
| + | import matplotlib.pyplot as plt | ||
| − | + | # Parámetros | |
| − | + | np.random.seed(42) | |
| − | + | T = 1 | |
| − | + | n_steps = 300 | |
| − | + | dt = T / n_steps | |
| − | + | t = np.linspace(0, T, n_steps + 1) | |
| − | + | ||
| − | + | plt.figure(figsize=(8, 5)) | |
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| + | # Varias trayectorias | ||
| + | for _ in range(12): | ||
| + | increments = np.random.normal(0, np.sqrt(dt), n_steps) | ||
| + | B = np.concatenate([[0], np.cumsum(increments)]) | ||
| + | plt.plot(t, B) | ||
| + | plt.title("Trayectorias de movimiento browniano") | ||
| + | plt.xlabel("tiempo") | ||
| + | plt.ylabel("posición") | ||
| + | plt.grid(True) | ||
| + | plt.show() | ||
| + | </syntaxhighlight> | ||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | + | === Evolución de la densidad === | |
| − | + | <syntaxhighlight lang="python"> | |
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | import numpy as np | |
| − | + | import matplotlib.pyplot as plt | |
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | # Dominio | |
| − | + | x = np.linspace(-6, 6, 1000) | |
| + | # Distintos tiempos | ||
| + | times = [0.2, 0.8, 1.6, 5,50] | ||
| + | plt.figure(figsize=(8, 5)) | ||
| + | for t in times: | ||
| + | # Solución de la ecuación del calor (gaussiana) | ||
| + | p = 1 / np.sqrt(2 * np.pi * t) * np.exp(-x**2 / (2 * t)) | ||
| + | plt.plot(x, p, label=f"t = {t}") | ||
| + | plt.title("Evolución de la densidad") | ||
| + | plt.xlabel("x") | ||
| + | plt.ylabel("densidad") | ||
| + | plt.legend() | ||
| + | plt.grid(True) | ||
| − | + | plt.show() | |
| + | </syntaxhighlight> | ||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | + | === Evolución de la densidad con ruido blanco === | |
| − | + | ||
| − | + | <syntaxhighlight lang="python"> | |
| + | import numpy as np | ||
| + | import matplotlib.pyplot as plt | ||
| − | + | # Dominio espacial | |
| − | + | x = np.linspace(-6, 6, 500) | |
| − | + | # Parámetro de difusión | |
| − | + | D = 1 | |
| − | + | # Tiempos | |
| − | + | times = [0.2, 0.8, 1.6] | |
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | # Solución del calor | |
| − | + | def u(x, t, D=1): | |
| − | + | return (1 / np.sqrt(4 * np.pi * D * t)) * np.exp(-x**2 / (4 * D * t)) | |
| − | + | ||
| − | + | ||
| + | # Semilla | ||
| + | np.random.seed(4) | ||
| + | plt.figure(figsize=(8,5)) | ||
| − | + | for t in times: | |
| − | + | u_det = u(x, t, D) | |
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | x | + | |
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | # Ruido proporcional | |
| − | + | noise = 0.02 * np.random.randn(len(x)) | |
| + | u_noise = u_det + noise | ||
| − | + | plt.plot(x, u_noise, label=f"t = {t}") | |
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | plot( | + | |
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | x | + | |
| − | + | ||
| − | + | ||
| − | + | ||
| − | f | + | |
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | } | + | |
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | plt.xlabel("x") | |
| − | + | plt.ylabel("densidad") | |
| + | plt.title("Evolución de la densidad con ruido blanco") | ||
| + | plt.legend() | ||
| + | plt.grid(True) | ||
| + | plt.show() | ||
| + | </syntaxhighlight> | ||
[[Categoría:EDP]] | [[Categoría:EDP]] | ||
[[Categoría:EDP25/26]] | [[Categoría:EDP25/26]] | ||
Revisión actual del 11:20 13 abr 2026
| Trabajo realizado por estudiantes | |
|---|---|
| Título | Ecuación del calor. Grupo MMA |
| Asignatura | EDP |
| Curso | 2025-26 |
| Autores | Marta Tejedor
María Romojaro Andrea Sánchez |
| Este artículo ha sido escrito por estudiantes como parte de su evaluación en la asignatura | |
Contenido
1 Dispersión de partículas
import numpy as np
import matplotlib.pyplot as plt
# Parámetros
np.random.seed(42)
n_particles = 400
times = [0.05, 0.4, 1.0]
fig, axes = plt.subplots(1, 3, figsize=(12, 4))
for ax, t in zip(axes, times):
# Movimiento aleatorio (normal)
x = np.random.normal(0, np.sqrt(t), n_particles)
y = np.random.normal(0, np.sqrt(t), n_particles)
ax.scatter(x, y, s=10, alpha=0.7)
ax.set_title(f"t = {t}")
ax.set_aspect("equal")
# Límites visuales
ax.set_xlim(-4, 4)
ax.set_ylim(-4, 4)
ax.grid(True)
fig.suptitle("Dispersión de partículas")
plt.tight_layout()
plt.show()
2 Trayectorias de movimiento browniano
import numpy as np
import matplotlib.pyplot as plt
# Parámetros
np.random.seed(42)
T = 1
n_steps = 300
dt = T / n_steps
t = np.linspace(0, T, n_steps + 1)
plt.figure(figsize=(8, 5))
# Varias trayectorias
for _ in range(12):
increments = np.random.normal(0, np.sqrt(dt), n_steps)
B = np.concatenate([[0], np.cumsum(increments)])
plt.plot(t, B)
plt.title("Trayectorias de movimiento browniano")
plt.xlabel("tiempo")
plt.ylabel("posición")
plt.grid(True)
plt.show()
3 Evolución de la densidad
import numpy as np
import matplotlib.pyplot as plt
# Dominio
x = np.linspace(-6, 6, 1000)
# Distintos tiempos
times = [0.2, 0.8, 1.6, 5,50]
plt.figure(figsize=(8, 5))
for t in times:
# Solución de la ecuación del calor (gaussiana)
p = 1 / np.sqrt(2 * np.pi * t) * np.exp(-x**2 / (2 * t))
plt.plot(x, p, label=f"t = {t}")
plt.title("Evolución de la densidad")
plt.xlabel("x")
plt.ylabel("densidad")
plt.legend()
plt.grid(True)
plt.show()
4 Evolución de la densidad con ruido blanco
import numpy as np
import matplotlib.pyplot as plt
# Dominio espacial
x = np.linspace(-6, 6, 500)
# Parámetro de difusión
D = 1
# Tiempos
times = [0.2, 0.8, 1.6]
# Solución del calor
def u(x, t, D=1):
return (1 / np.sqrt(4 * np.pi * D * t)) * np.exp(-x**2 / (4 * D * t))
# Semilla
np.random.seed(4)
plt.figure(figsize=(8,5))
for t in times:
u_det = u(x, t, D)
# Ruido proporcional
noise = 0.02 * np.random.randn(len(x))
u_noise = u_det + noise
plt.plot(x, u_noise, label=f"t = {t}")
plt.xlabel("x")
plt.ylabel("densidad")
plt.title("Evolución de la densidad con ruido blanco")
plt.legend()
plt.grid(True)
plt.show()