-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathproptiesmethod.py
More file actions
85 lines (55 loc) · 2.43 KB
/
proptiesmethod.py
File metadata and controls
85 lines (55 loc) · 2.43 KB
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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
from abc import ABC, abstractmethod
import numpy as np
import pcsaft.pcsaft
# from pcsaft.pcsaft import *
class PropertiesMethod(ABC):
@abstractmethod
def calculate_molar_density_mixture(self, *args, **kwargs):
pass
@abstractmethod
def calculate_molar_density_pure(self, *args, **kwargs):
pass
@abstractmethod
def calculate_polymer_density(self, *args, **kwargs):
pass
class UserMethod(PropertiesMethod):
def calculate_molar_density_mixture(self, mole_frac, temperature, pressure, param_list):
R = 8.314
Tr = temperature / param_list["Tc"]
m = 0.37464 + 1.54226 * param_list["Omega"] - 0.26992 * param_list["Omega"] ** 2
alpha = (1 + m * (1 - np.sqrt(Tr))) ** 2
a = 0.45724 * R ** 2 * param_list["Tc"] ** 2 / param_list["Pc"] * alpha
b = 0.07780 * R * param_list["Tc"] / param_list["Pc"]
# 混合规则
a_mix = np.sum(np.outer(mole_frac, mole_frac) * np.sqrt(np.outer(a, a)))
b_mix = np.sum(mole_frac * b)
# 定义Peng-Robinson方程
A = a_mix * pressure / (R * temperature) ** 2
B = b_mix * pressure / (R * temperature)
coeff = [1,
B - 1,
A - 3 * B ** 2 - 2 * B,
B ** 3 + B ** 2 - A * B]
Z_roots = np.roots(coeff)
Z_real = Z_roots[np.isreal(Z_roots)].real
Z_real = np.sort(Z_real)
densities = pressure / (Z_real * R * temperature)
return densities, Z_real
def calculate_molar_density_pure(self, temperature, pressure, params):
pass
def calculate_polymer_density(self, temperature):
pass
class IIR_PCSAFT(PropertiesMethod):
def __init__(self,param):
self.pcsaft = pcsaft.pcsaft.PCSAFT()
self.param = param
def calculate_molar_density_mixture(self, temperature, pressure, param, mole_frac, polymer_mole_frac_zeroth, dpn):
den = self.pcsaft.compute_density(temperature, pressure, mole_frac, 0, param)
return self.pcsaft.compute_den_correction(den, polymer_mole_frac_zeroth, dpn)
def calculate_polymer_density(self, *args, **kwargs):
pass
def calculate_molar_density_pure(self, *args, **kwargs):
pass
class PengRobinsonMethod(PropertiesMethod):
def calculate_molar_density_mixture(self, mole_frac, temperature, pressure):
pass