Example #1
0
def ej2():
    print("Generando Ejercicio 2...")
    os.makedirs('ej2', exist_ok=True)
    os.chdir('ej2')
    file = open('ej2.txt', 'w')

    T0 = 20 + 273
    t0 = 0
    t_fin = NBOL * CADE
    # Optamos por usar los valores de RK

    valores_runge = runge_kutta_4(intercambio_total(TMP1, TMP2), t0, t_fin, T0,
                                  CADE)

    xx = np.linspace(t0, t_fin)
    yy = temperatura_exacta(T0)(xx)
    plt.figure(figsize=(10, 7))
    tiempos_a_minutos(xx)
    temps_a_celsius(yy)
    plt.plot(xx, yy, lw=2, label='Temperatura Exacta')
    plt.plot(valores_runge[1], valores_runge[0], 'b^', label='Runge-Kutta 4')
    plt.legend(loc='lower right')
    plt.xlabel('t [min]')
    plt.ylabel('T(t) [°C]')
    plt.grid(True)
    plt.savefig('ej2.png')

    buscar_intervalo_temperatura(valores_runge, TMP2 - 10 - 273, file)

    os.chdir('../')
    print("")
Example #2
0
def resolver_caso_ej5(sk_obj, tsk_obj, caso, file=sys.stdout):
    j_inv = np.matrix([[0.25, 0.75], [0.75, 0.25]])
    err = 0.1
    t0 = 0
    T0 = 20 + 273
    t_fin = NBOL * CADE

    x, n_iter = punto_fijo_sistema(
        sistema_funciones(tsk_obj, sk_obj),
        sistema_funciones(tsk_obj, sk_obj)(np.matrix([[TMP1], [TMP2]])), err,
        j_inv)
    print('{0:4}\t{1: .14f}\t{2: .14f}\t{3: .14f}\t{4:4}'.format(
        sk_obj, tsk_obj,
        x.item(0) - 273,
        x.item(1) - 273, n_iter),
          file=file)

    valores_runge = runge_kutta_4(intercambio_total(x.item(0), x.item(1)), t0,
                                  t_fin, T0, CADE)

    xx = np.linspace(t0, t_fin)
    yy = temperatura_exacta(T0)(xx)
    plt.figure(figsize=(10, 7))
    tiempos_a_minutos(xx)
    temps_a_celsius(yy)
    plt.plot(xx, yy, lw=2, label='Temperatura Exacta')
    plt.plot(valores_runge[1], valores_runge[0], 'b^', label='Runge-Kutta 4')
    plt.legend(loc='lower right')
    plt.xlabel('t [min]')
    plt.ylabel('T(t) [°C]')
    plt.grid(True)
    plt.savefig('ej5' + caso + '.png')
Example #3
0
def buscar_tk_sk(tmp1, tmp2):
    T0 = 20 + 273
    t0 = 0
    t_fin = NBOL * CADE
    tmp = tmp2 - 10 - 273
    arr = runge_kutta_4(intercambio_total(tmp1, tmp2), t0, t_fin, T0, CADE)

    pos_temp_i = -1
    for i in range(len(arr[0])):
        if arr[0][i] > tmp:
            pos_temp_i = i
            break

    return np.matrix([[sum(arr[0][pos_temp_i:]) / len(arr[0][pos_temp_i:])],
                      [(arr[1][len(arr[1]) - 1]) - (arr[1][pos_temp_i])]])
Example #4
0
def ej3():
    print("Generando Ejercicio 3...")
    os.makedirs('ej3', exist_ok=True)
    os.chdir('ej3')
    file = open('ej3.txt', 'w')

    T0 = 20 + 273
    t0 = 0
    t_fin = NBOL * CADE

    # Valores de temperatura "a mano"
    tmp1 = 1085
    tmp2 = 995
    valores_runge = runge_kutta_4(intercambio_total(tmp1, tmp2), t0, t_fin, T0,
                                  CADE)

    buscar_intervalo_temperatura(valores_runge, tmp2 - 10 - 273, file)

    os.chdir('../')
    file.close()
    print("")
Example #5
0
def ej4():
    print("Generando Ejercicio 4...")
    os.makedirs('ej4', exist_ok=True)
    os.chdir('ej4')
    file = open('ej4.txt', 'w')

    T0 = 20 + 273
    t0 = 0
    t_fin = NBOL * CADE

    # Valores de temperatura "a mano"
    tmp1 = 1100
    tmp2 = 990

    # Es necesario cambiar el valor de la cadencia descomentando una linea en el funciones.py
    valores_runge = runge_kutta_4(intercambio_total(tmp1, tmp2), t0, t_fin, T0,
                                  CADE)

    buscar_intervalo_temperatura(valores_runge, tmp2 - 10 - 273, file)

    os.chdir('../')
    file.close()
    print("")