Мне нужна помощь в получении темпов с помощью Antoine Eq с использованием классов.
Мое действие root не выполняется, и я не знаю почему.
Мой код:
from __future__ import division, print_function
%matplotlib inline
import numpy as np
import matplotlib.pyplot as plt
from scipy.optimize import root
class Chemical(object):
def __init__(self, name_1, balance_1, name_2, balance_2):
self.name = name_1 + ' ' + '+' + ' ' + name_2
self.data_1 = []
self.data_2 = []
self.data_1 = balance_1
self.data_2 = balance_2
def __str__(self):
if (self.name):
return "Mixture: %s" % (self.name)
else:
return None
def bubble_solve(self,a,P = 1.01,T = 300):
A1,B1,C1 = self.data_1
A2,B2,C2 = self.data_2
PA = 10**(A1 - B1/(C1+T))
PB = 10**(A2 - B2/(C2+T))
sol = root(lambda T: P - (a*PA + (1-a)*PB),T)
return sol.x[0]
def dew_solve(self, b, P = 1.01, T = 300):
A1,B1,C1 = self.data_1
A2,B2,C2 = self.data_2
PA = 10**(A1 - B1/(C1+T))
PB = 10**(A2 - B2/(C2+T))
sol = root(lambda T: 1 - (b*P/PA + (1-b)*P/PB), T)
return sol.x[0]
mixture = Chemical('benzene', [ 3.98523 , 1184.24 , -55.578], 'toulene',
[4.05043 , 1327.62 , -55.528])
print(mixture)
print()
print(mixture.bubble_solve(0.5)) #at a = 0.5
print(mixture.bubble_solve(0.5,2)) #at a = 0.5 and P = 2
print(mixture.dew_solve(0.5)) #at b = 0.5
print(mixture.dew_solve(0.5,2)) #at b = 0.5 and P = 2
Это то, что печатает мой код:
Mixture: benzene + toulene
300.0
300.0
300.0
300.0
Однако ответы должны быть: 365,087, 390,14188, 371,7743, 396,688.
Почему действие rootпотерпеть неудачу?