TTP-Ü 11


In [4]:
import numpy as np
import locale

# Sys: (1) Propanol (2) Wasser

# Antoine
a = np.array([9.003, 8.196])
b  = np.array([2010.33, 1730.63])  # °C
c = np.array([252.636, 233.426])  # °C

# Van Laar
c1 = 2.3405
c2 = 1.1551

x10 = 0.1
t0 = 100
x1 = x10
t = t0
x2 = 1-x1
p = 1000. # mbar
f = np.nan

tol = 1e-10
it = 15

for i in range(it):
    gamma1 = np.exp(c1*c2**2*x2**2/(x1*c1+x2*c2)**2)
    gamma2 = np.exp(c1**2*c2*x1**2/(x1*c1+x2*c2)**2)
    f = -1 + gamma1 * x1 * p1s/p + gamma2 * x2 * p2s/p
    while f > tol:
        print('TL, f: '+str([locale.format('%0.4g', item) 
                              for item in [t, f]]))
        p1s, p2s = 10**(a-b/(c+t))
        f = -1 + gamma1 * x1 * p1s/p + gamma2 * x2 * p2s/p
        df = gamma1 * x1 * p1s/p * b[0]*np.log(10) /(
            (t + c[0])**2
        ) + gamma2 * x2 * p2s/p * b[1]*np.log(10) /(
            (t + c[1])**2
        )
        t = t -1/df * f
    
    y1 = gamma1 * x1 * p1s / p
    y2 = 1-y1
    x1 = y1
    x2 = y2
    print('It.'+locale.format('%2i', i)+'\t'+
          ' x1, y1, x2, y2: '+str([locale.format('%0.4g', item) 
                              for item in [x1,y1,x2,y2]]))


It. 0	 x1, y1, x2, y2: ['0.4346', '0.4346', '0.5654', '0.5654']
It. 1	 x1, y1, x2, y2: ['0.5681', '0.5681', '0.4319', '0.4319']
It. 2	 x1, y1, x2, y2: ['0.618', '0.618', '0.382', '0.382']
It. 3	 x1, y1, x2, y2: ['0.6418', '0.6418', '0.3582', '0.3582']
It. 4	 x1, y1, x2, y2: ['0.6542', '0.6542', '0.3458', '0.3458']
It. 5	 x1, y1, x2, y2: ['0.6609', '0.6609', '0.3391', '0.3391']
It. 6	 x1, y1, x2, y2: ['0.6645', '0.6645', '0.3355', '0.3355']
It. 7	 x1, y1, x2, y2: ['0.6666', '0.6666', '0.3334', '0.3334']
It. 8	 x1, y1, x2, y2: ['0.6677', '0.6677', '0.3323', '0.3323']
It. 9	 x1, y1, x2, y2: ['0.6684', '0.6684', '0.3316', '0.3316']
It.10	 x1, y1, x2, y2: ['0.6687', '0.6687', '0.3313', '0.3313']
It.11	 x1, y1, x2, y2: ['0.6689', '0.6689', '0.3311', '0.3311']
It.12	 x1, y1, x2, y2: ['0.669', '0.669', '0.331', '0.331']
It.13	 x1, y1, x2, y2: ['0.6691', '0.6691', '0.3309', '0.3309']
It.14	 x1, y1, x2, y2: ['0.6691', '0.6691', '0.3309', '0.3309']