CHEMICAL_PROPS
Overview
Excel Usage
=CHEMICAL_PROPS(chemical, thermo_prop)
chemical(str, required): Chemical identifier (e.g., ‘Water’, ‘67-56-1’).thermo_prop(str, required): Property attribute name (e.g., ‘MW’, ‘Tb’, ‘Tc’, ‘Pc’, ‘formula’).
Returns (float): Property value (float) or string (e.g. formula).
Examples
Example 1: Water Molecular Weight
Inputs:
| chemical | thermo_prop |
|---|---|
| Water | MW |
Excel formula:
=CHEMICAL_PROPS("Water", "MW")
Expected output:
18.01528
Example 2: Ethanol Critical Temperature
Inputs:
| chemical | thermo_prop |
|---|---|
| Ethanol | Tc |
Excel formula:
=CHEMICAL_PROPS("Ethanol", "Tc")
Expected output:
514.71
Example 3: Methane Formula
Inputs:
| chemical | thermo_prop |
|---|---|
| Methane | formula |
Excel formula:
=CHEMICAL_PROPS("Methane", "formula")
Expected output:
"CH4"
Example 4: Benzene Critical Pressure
Inputs:
| chemical | thermo_prop |
|---|---|
| Benzene | Pc |
Excel formula:
=CHEMICAL_PROPS("Benzene", "Pc")
Expected output:
4907277
Python Code
from thermo import Chemical
def chemical_props(chemical, thermo_prop):
"""
Retrieve physical and thermodynamic properties for a chemical specimen.
See: https://thermo.readthedocs.io/thermo.chemical.html
This example function is provided as-is without any representation of accuracy.
Args:
chemical (str): Chemical identifier (e.g., 'Water', '67-56-1').
thermo_prop (str): Property attribute name (e.g., 'MW', 'Tb', 'Tc', 'Pc', 'formula'). Valid options: Molecular Weight (MW), Normal Boiling Point (Tb), Melting Point (Tm), Critical Temperature (Tc), Critical Pressure (Pc), Critical Volume (Vc), Acentric Factor (omega), Formula, SMILES, PubChem ID.
Returns:
float: Property value (float) or string (e.g. formula).
"""
try:
c = Chemical(chemical)
if hasattr(c, thermo_prop):
return getattr(c, thermo_prop)
else:
return f"Error: Property '{thermo_prop}' not found for '{chemical}'"
except Exception as e:
return f"Error: {str(e)}"