import numpy as np
import matplotlib.pyplot as plt
import os
import contorno
from constantes import INTERVALOS, PASSOS, TAMANHO_BARRA, DELTA_T, DELTA_X
import time

# y = contorno.p_0
# y = contorno.p_1
# y = contorno.p_2
y = contorno.p_3
TAMANHO_BARRA = 2

x = np.linspace(0.0, TAMANHO_BARRA, INTERVALOS+1)
y_temp = np.copy(y)

for k in range(PASSOS+1):
    y = np.copy(y_temp)
    for i in range(1, INTERVALOS):
        y_temp[i] = y[i] + (DELTA_T/(DELTA_X**2)) * (y[i+1]-2*y[i]+y[i-1])

t = k*DELTA_T

fig = plt.figure()
ax = fig.add_subplot()
fig.suptitle(f't={t:.3f}')
ax.set_ylabel('T(x,t)')
ax.set_xlabel('x')
ax.set_ylim(-0.1, 1.1)
plt.plot(x, y, '.', lw=2)
plt.show()

import numpy as np
import matplotlib.pyplot as plt
import os
import contorno
from constantes import INTERVALOS, PASSOS, TAMANHO_BARRA, DELTA_T, DELTA_X
import time

# y = contorno.p_0
# y = contorno.p_1
# y = contorno.p_2
y = contorno.p_3
TAMANHO_BARRA = 2

x = np.linspace(0.0, TAMANHO_BARRA, INTERVALOS+1)
y_temp = np.copy(y)

for k in range(PASSOS+1):
    y = np.copy(y_temp)
    for i in range(1, INTERVALOS):
        y_temp[i] = y[i] + (DELTA_T/(DELTA_X**2)) * (y[i+1]-2*y[i]+y[i-1])

t = k*DELTA_T

fig = plt.figure()
ax = fig.add_subplot()
fig.suptitle(f't={t:.3f}')
ax.set_ylabel('T(x,t)')
ax.set_xlabel('x')
ax.set_ylim(-0.1, 1.1)
plt.plot(x, y, '.', lw=2)
plt.show()

# y = contorno.p_0 # y = contorno.p_1 # y = contorno.p_2