import math
class KM2():
def __init__(self):
self.set_params = {}
def _calc_enthalpy(self, P_0):
return 2500 + 100 * math.log(P_0)
def __call__(self, mode):
return self.calculate(mode)
def calculate(self, mode):
u_c_opt = 0.45
G_ref = 100
h0 = self._calc_enthalpy(self.set_params['P_0'])
hkt = self._calc_enthalpy(self.set_params['P_k'])
H0 = h0 - hkt
if mode == 'diameter':
Hi = H0 / self.set_params['z']
c_ad = (2000 * Hi)**0.5
u_opt = u_c_opt * c_ad
D_pre = u_opt * 60 / (3.14 * self.set_params['n'])
D = D_pre * (self.set_params['G'] / G_ref)**0.2
return D
if mode == 'stages':
u = math.pi * self.set_params['D'] * self.set_params['n'] / 60
for z in range(1, self.set_params['z'] + 1):
Hi = H0 / z
c_ad = (2000 * Hi)**0.5
u_c_ratio = u / c_ad
if abs(u_c_ratio - u_c_opt) < 0.1:
break
return z
# Расчет 1
Res1 = KM2()
Res1.set_params = {'G': 100, 'P_0': 14.5, 'T_0': 545, 'P_k': 0.005, 'D': 1.2, 'z': 10, 'n': 3000}
result1 = Res1.calculate(mode='stages')
result2 = Res1.calculate(mode='diameter')
print('stages:', result1, 'diameter:', result2)
# Расчет 2
Res2 = KM2()
Res2.set_params = {'G': 200, 'P_0': 10.5, 'T_0': 545, 'P_k': 0.005, 'D': 1.5, 'z': 10, 'n': 3000}
result3 = Res2(mode='stages')
result4 = Res2(mode='diameter')
print('stages:', result3, 'diameter:', result4)