- #1
yan3220
- 2
- 0
Hello, everyone:
I'm trying to use the PC-SAFT (Perturbed-Chain Statistical Associating Fluid Theory) method to calculate the bubble point and dew point pressures of hydrocarbon mixtures, and subsequently plot the PT phase envelope. My calculations for bubble pressure match the experimental data very well. However, when calculating dew pressure at different temperatures, the program fails to converge. I understand that the difference between calculating bubble pressure and dew pressure lies in how the component compositions are determined through fugacity calculations. Therefore, if the bubble pressure calculations are very accurate, it indicates that the internal parameters of PC-SAFT are correct. So why can't the dew pressure be calculated at all?
I have attached the code for calculating dew pressure below.
I'm really hoping someone can offer me some help and advice. Thank you so much!
I'm trying to use the PC-SAFT (Perturbed-Chain Statistical Associating Fluid Theory) method to calculate the bubble point and dew point pressures of hydrocarbon mixtures, and subsequently plot the PT phase envelope. My calculations for bubble pressure match the experimental data very well. However, when calculating dew pressure at different temperatures, the program fails to converge. I understand that the difference between calculating bubble pressure and dew pressure lies in how the component compositions are determined through fugacity calculations. Therefore, if the bubble pressure calculations are very accurate, it indicates that the internal parameters of PC-SAFT are correct. So why can't the dew pressure be calculated at all?
I have attached the code for calculating dew pressure below.
I'm really hoping someone can offer me some help and advice. Thank you so much!
Code:
def cal_VLE_dew_point(temperature, initial_system_pressure, component_mixture,pc_saft_para_dict,component_name,univeral_model_constant=univeral_model_constant):
composition_liquid = component_mixture.copy()
composition_vapor = component_mixture.copy()
def wrapped_cal_pressure(initial_packing_fraction, temperature, component_mixture, pc_saft_para_dict, target_pressure):
calculated_pressure = cal_pressure(initial_packing_fraction,temperature,univeral_model_constant,component_name, component_mixture, pc_saft_para_dict,boltzmann_constant = 1.3806*10**-23)
return np.array(calculated_pressure, dtype=np.float64) - target_pressure
iteration = 0
error = 100
vapor_packing_fraction = 10**-10
liquid_packing_fraction = 0.5
while (error > 0.00001) and iteration < 300:
result = least_squares(wrapped_cal_pressure, liquid_packing_fraction, args=(temperature, composition_liquid, pc_saft_para_dict, initial_system_pressure), xtol=1e-12,ftol=1e-12,gtol=1e-12,max_nfev=50000)
liquid_packing_fraction = result.x
result = least_squares(wrapped_cal_pressure, vapor_packing_fraction, args=(temperature, composition_vapor, pc_saft_para_dict, initial_system_pressure), xtol=1e-12,ftol=1e-12,gtol=1e-12,max_nfev=50000)
vapor_packing_fraction = result.x
fugacity_coefficient_liquid = cal_fugacity(liquid_packing_fraction, temperature, univeral_model_constant,component_name, composition_liquid, pc_saft_para_dict)
fugacity_coefficient_vapor = cal_fugacity(vapor_packing_fraction, temperature, univeral_model_constant,component_name, composition_vapor, pc_saft_para_dict)
update_liquid_compostion = {}
total_composition_liquid = 0
for i in component_name:
update_liquid_compostion = fugacity_coefficient_vapor*composition_vapor/fugacity_coefficient_liquid
total_composition_liquid += update_liquid_compostion
for k,v in update_liquid_compostion.items():
update_liquid_compostion[k] = update_liquid_compostion[k]/total_composition_liquid
composition_liquid = update_liquid_compostion.copy()
initial_system_pressure = total_composition_liquid * initial_system_pressure
error = np.abs(total_composition_liquid - 1.0)
iteration += 1
dew_point_pressure = cal_pressure(liquid_packing_fraction,temperature, univeral_model_constant,component_name, composition_liquid, pc_saft_para_dict,boltzmann_constant = 1.3806*10**-23)
return composition_liquid, composition_vapor, dew_point_pressure
Last edited by a moderator: