-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathsolve_antoine.py
51 lines (38 loc) · 1.01 KB
/
solve_antoine.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
import numpy as np
import csv
import matplotlib.pyplot as plt
"""
Este programa halla las constantes de Antoine A, B, C para el benceno
utilizano mínimos cuadrados
"""
P, T = [], []
with open("datos_antoine.csv", "r") as f:
reader = csv.DictReader(f)
#for line in reader: # Para verificar que esta leyendo los datos en un diccionario
# print(line)
for line in reader:
P.append(float(line["P"].replace(",",".")))
T.append(float(line["T"].replace(",",".")))
presion = np.array(P)
temp = np.array(T)
y = np.log10(presion)
x1 = 1/temp
x2 = y*x1
n = len(T)
N = np.ones(n)
M = np.array([N, x1, x2])
b = np.linalg.pinv(M.T)@y
A = b[0]
C = -b[2]
B = A*C-b[1]
print(A, B, C)
#
data_temp = np.linspace(-60, 100, 100)
data_pres = 10**(A-B/(data_temp+C))
plt.plot(data_temp, data_pres, "-", label ="Regresion")
plt.plot(T, P, "g^", label = "datos exp")
plt.xlabel("Temperatura [°C]")
plt.ylabel("Presión [mmHg]")
plt.title("P vs T (Benceno)", fontsize = 18)
plt.legend(loc=2)
plt.show()