BioSTEAMDevelopmentGroup / thermosteam

BioSTEAM's Premier Thermodynamic Engine
Other
57 stars 12 forks source link

Correct_atomic_balance does not work on methane combustion equation #28

Closed fwitte closed 3 years ago

fwitte commented 3 years ago

Hi Yoel, I always like to try and fiddle with new code/software and wanted to create something I am more familiar with than biodiesel reactions :), a combustion reaction of methane with auto correcting the atomic balance. Unfortunately, I do not really know what I am doing wrong here, can you help me? I would expect, that the atomic balance can be solved here.

import thermosteam as tmo
from thermosteam import reaction as rxn

chemicals = tmo.Chemicals(['Water', 'Methane', 'CO2', 'O2'])
tmo.settings.set_thermo(chemicals)
combustion = rxn.Reaction('Methane + O2 -> Water + CO2',
                                   reactant='Methane', X=1,
                                   correct_atomic_balance=True)

Thanks and best regards Francesco

yoelcortes commented 3 years ago

Thanks so much for testing this out. I enhanced the correct_atomic_balance method to be more flexible (check out the latest git version or "pip install thermosteam==0.21.8). Your test should work now:

>>> import thermosteam as tmo
>>> from thermosteam import reaction as rxn
>>> chemicals = tmo.Chemicals(['Water', 'Methane', 'CO2', 'O2'])
>>> tmo.settings.set_thermo(chemicals)
>>> combustion = rxn.Reaction('Methane + O2 -> Water + CO2',
...                                reactant='Methane', X=1,
...                                correct_atomic_balance=True)
>>> combustion.show()
Reaction (by mol):
 stoichiometry                    reactant    X[%]
 Methane + 2 O2 -> 2 Water + CO2  Methane   100.00

I updated the documentation with more details too: https://thermosteam.readthedocs.io/en/latest/reaction/Reaction.html#thermosteam.reaction.Reaction.correct_atomic_balance

Let me know if you have any further questions!