CalebBell / thermo

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

errors when using calcium in mixtures #116

Closed CoolFact closed 2 years ago

CoolFact commented 2 years ago

I have trouble getting calcium based components to work in the mixture library, here is the Traceback for milk of lime:

Traceback (most recent call last):
  File "path\VLE\chemprop.py", line 49, in <module>
    mix = Mixture(['water', 'Ca(OH)2'], Vfls=[.6, .4], T=300, P=1E5)
  File "path\Python\Python39\lib\site-packages\thermo\mixture.py", line 608, in __init__
    self.zs = Vfs_to_zs(Vfs, Vms_TP)
  File "path\Python\Python39\lib\site-packages\chemicals\utils.py", line 1519, in Vfs_to_zs
    v = Vfs[i]/Vms[i]
TypeError: unsupported operand type(s) for /: 'float' and 'NoneType'
CalebBell commented 2 years ago

Hi, There isn't enough data to work with that compound in Thermo, unfortunately.

CoolFact commented 2 years ago

I see,

is there a way to add the missing data manually?

CalebBell commented 2 years ago

Hi,

Kind of, now. I added an importer to pull data from Wikidata. As that is publicly editable, that means you can add the critical temperature, critical pressure, and boiling point to it. I can then re-run the importer, and make a new release of Chemicals, with the missing data.

A larger issue is that no one knows what the right numbers are, however.

CalebBell commented 2 years ago

I should also clarify that this is a limitation of the legacy Mixture interface. The newer interface that uses the ChemicalConstantsPackage object was designed specifically to let anything be input.

For example, adding (randomly guessed) properties of 1000 K boiling point, 1 MPa critical point pressure, 3000 K critical temperature, and -0.3 acentric factor, and using the peng robinson EOS, flash calculations can be performed easily.

chemicals = ['water', 'calcium hydroxide']
constants, properties = ChemicalConstantsPackage.from_IDs(chemicals)
constants = constants.with_new_constants(Tbs=[constants.Tbs[0], 1000], Pcs=[constants.Pcs[0], 1e6],
                             Tcs=[constants.Tcs[0], 3000], omegas=[constants.omegas[0], -.3])
eos_kwargs = {'Pcs': constants.Pcs, 'Tcs': constants.Tcs, 'omegas': constants.omegas}
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)
res = flasher.flash(T=300, P=1e5, zs=[.5, .5])