CalebBell / thermo

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

Phase diagrams? #69

Closed infinity77 closed 3 years ago

infinity77 commented 3 years ago

Hi Caleb,

First of all, thank you for making your code available, it’s an amazing library full of possibilities. I am no expert and maybe I am asking very stupid questions, so please bear with me.

I deal with multi-components gas mixtures (with generally 8-10 components) and I would like to generate phase diagrams (pressure and temperature on x and y axes) for the mixtures. Do you know how I can go about leveraging your work to achieve that?

thank you in advance.

CalebBell commented 3 years ago

Hi Andrea, The development version of thermo has a function I wrote for debug purposes which would be your best bet today. It does repeated flash calculations on a grid, and plots the identified phase. This is not a specialized algorithm so it will not be particularly fast. Note that you should provide your own kijs, the sample databank shown below is from ChemSep and is very small.


from thermo import ChemicalConstantsPackage, CEOSGas, CEOSLiquid, PRMIX, FlashVL
from thermo.interaction_parameters import IPDB
constants, properties = ChemicalConstantsPackage.from_IDs(['methane', 'ethane', 'nitrogen'])
kijs = IPDB.get_ip_asymmetric_matrix('ChemSep PR', constants.CASs, 'kij')
kijs

eos_kwargs = {'Pcs': constants.Pcs, 'Tcs': constants.Tcs, 'omegas': constants.omegas, 'kijs': kijs}
gas = CEOSGas(PRMIX, eos_kwargs=eos_kwargs, HeatCapacityGases=properties.HeatCapacityGases)
liquid = CEOSLiquid(PRMIX, eos_kwargs=eos_kwargs, HeatCapacityGases=properties.HeatCapacityGases)
flasher = FlashVL(constants, properties, liquid=liquid, gas=gas)
zs = [0.965, 0.018, 0.017]
flasher.debug_PT(zs=zs, Tmin=100, Tmax=300, Pmin=1e5, Pmax=1e6, pts=50)
infinity77 commented 3 years ago

Hi Caleb,

Thank you for your super fast answer! I’ll take a look as soon as I can.

infinity77 commented 3 years ago

Hi Caleb,

I think I can see what your debug function is doing: it’s kind of close to what I would need, although what I am really after is something like this:

maybe I can derive something similar from your code, but I don’t know yet...