CalebBell / thermo

Thermodynamics and Phase Equilibrium component of Chemical Engineering Design Library (ChEDL)
MIT License
594 stars 114 forks source link

Is there a function to calculate the fugacity of each component in a multi-component mixture? #92

Closed drLjc closed 2 years ago

drLjc commented 2 years ago

Is there a function to calculate the fugacity of each component in a multi-component mixture?

CalebBell commented 2 years ago

Hi,

This is absolutely possible. Flash calculations use fugacities. The following code shows how to obtain fugacities in a binary mixture with the Peng-Robinson equation of state, for both a liquid and a gas phase.

from thermo import ChemicalConstantsPackage, PRMIX, CEOSLiquid, CEOSGas
constants, correlations = ChemicalConstantsPackage.from_IDs(['water', 'toluene'])
eos_kwargs = dict(Tcs=constants.Tcs, Pcs=constants.Pcs, omegas=constants.omegas)
liquid = CEOSLiquid(PRMIX, HeatCapacityGases=correlations.HeatCapacityGases, eos_kwargs=eos_kwargs)
gas = CEOSGas(PRMIX, HeatCapacityGases=correlations.HeatCapacityGases, eos_kwargs=eos_kwargs)

(liquid.to(T=300, P=1e4, zs=[.2, .8]).fugacities(), gas.to(T=300, P=1e4, zs=[.2, .8]).fugacities())

Sincerely, Caleb

drLjc commented 2 years ago

Thank you very much for your reply. What I need to calculate is the fugacity of a component of a gas mixture. For example, a gas mixture of hydrogen, carbon monoxide, CO2 and water. I would like to obtain the fugacity of hydrogen.

------------------ 原始邮件 ------------------ 发件人: "CalebBell/thermo" @.>; 发送时间: 2021年12月5日(星期天) 上午10:08 @.>; @.**@.>; 主题: Re: [CalebBell/thermo] Is there a function to calculate the fugacity of each component in a multi-component mixture? (Issue #92)

Hi,

This is absolutely possible. Flash calculations use fugacities. The following code shows how to obtain fugacities in a binary mixture with the Peng-Robinson equation of state, for both a liquid and a gas phase. from thermo import ChemicalConstantsPackage, PRMIX, CEOSLiquid, CEOSGas constants, correlations = ChemicalConstantsPackage.from_IDs(['water', 'toluene']) eos_kwargs = dict(Tcs=constants.Tcs, Pcs=constants.Pcs, omegas=constants.omegas) liquid = CEOSLiquid(PRMIX, HeatCapacityGases=correlations.HeatCapacityGases, eos_kwargs=eos_kwargs) gas = CEOSGas(PRMIX, HeatCapacityGases=correlations.HeatCapacityGases, eos_kwargs=eos_kwargs) (liquid.to(T=300, P=1e4, zs=[.2, .8]).fugacities(), gas.to(T=300, P=1e4, zs=[.2, .8]).fugacities())
Sincerely, Caleb

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or unsubscribe. Triage notifications on the go with GitHub Mobile for iOS or Android.

CalebBell commented 2 years ago

Hi, You can change the component names and mole fractions and add more components in the above example. The fugacities returned are ordered in the same way as you enter the component names.