CalebBell / thermo

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

Chemical('CO') returns Methanol instead of Carbon Monoxide #31

Closed danisahni closed 4 years ago

danisahni commented 4 years ago

Hello there, First of all, thanks for your great work, I just stumbled over this great package recently. Unfortunately I observed some strange behaviour, when I tried to create a Chemical object for Carbon Monoxide.

minimal example to reproduce the bug:

from thermo import Chemical

CO = Chemical('CO')
print(CO.name)

From my observations the wrong chemical is picked in the module identifiers.py in the smiles lookup (Line 487):

    # Try the smiles lookup anyway
    # Parsing SMILES is an option, but this is faster
    # Pybel API also prints messages to console on failure
    smiles_lookup = pubchem_db.search_smiles(ID, autoload)
    if smiles_lookup:
        return smiles_lookup.CASs

This returns Methanol instead of Carbon Monoxide.

CalebBell commented 4 years ago

Hi, Chemical identification by formula is not a preferred input because for most organic formulas, there are lots of chemicals with the same formula and different structures. Identifying a chemical by SMILES string however, provides a unique chemical.

No one-string input will ever be perfect and it would be prudent to double check the database selected the correct compound. I agree in the ideal world Carbon Monoxide would have been selected from that input, but not everything can be perfect.

danisahni commented 4 years ago

Hi, Thanks for the fast reply, this is good to know. I will work with a little lookup dictionary then, which gives me the CAS number of the gas species I use in my project (which are not many).