Thermo API¶
Thermodynamic property models and data access.
ThermoProperty¶
ThermoProperty
dataclass
¶
Enhanced thermodynamic property with CHETAH-style breakdown support.
Provides: - Value with uncertainty - Group contribution breakdown (when available) - Literature references - Comparison with database reference values
Backward compatible: all enhanced fields are optional.
deviation_percent
property
¶
Percent deviation from reference value.
format_breakdown ¶
Return CHETAH-style breakdown table.
Parameters¶
property_name : str Name to show in header
Returns¶
str Formatted breakdown table
Example Output¶
ENTHALPY OF FORMATION (GAS) CALCULATION¶
Group Count Contribution Total¶
C-(H)3(C) 2 -10.00 -20.00 C-(H)2(C)2 1 -5.00 -5.00
ESTIMATED VALUE (Benson GA): -25.00 kJ/mol
REFERENCE VALUE (NIST WebBook): -26.50 kJ/mol DEVIATION: +1.50 kJ/mol
References: - Benson, S.W. (1976) - NIST Chemistry WebBook, SRD 69
Attributes¶
| Attribute | Type | Description |
|---|---|---|
value |
float | Property value |
unit |
str | Unit of measurement |
uncertainty |
float | None |
source |
str | None |
phase |
str | Phase ('g', 'l', 's') |
breakdown |
tuple[GroupContribution, ...] | Group contributions |
references |
tuple[Reference, ...] | Literature references |
reference_value |
ThermoValue | None |
estimation_method |
str | Estimation method used |
temperature_K |
float | Temperature in Kelvin |
Properties¶
| Property | Type | Description |
|---|---|---|
deviation |
float | None |
deviation_percent |
float | None |
Methods¶
Check if group contribution breakdown is available. Check if reference value is available. Format CHETAH-style breakdown table.Float Conversion¶
ThermoState¶
ThermoState
dataclass
¶
Immutable thermodynamic state at a specific temperature.
Provides grouped access to all temperature-dependent properties
at a single temperature. Use Compound.thermo_at(T=...) to create.
Attributes¶
temperature : float Temperature in Kelvin
Properties¶
H : ThermoProperty Enthalpy of formation [kJ/mol] S : ThermoProperty Standard entropy [J/(mol·K)] Cp : ThermoProperty Heat capacity at constant pressure [J/(mol·K)] G : ThermoProperty Gibbs free energy of formation [kJ/mol]
Examples¶
from phoenix import Compound ethanol = Compound.from_smiles('CCO') state = ethanol.thermo_at(T=500) print(f"H = {state.H.value:.2f} kJ/mol") print(f"S = {state.S.value:.2f} J/(mol·K)") print(f"G = {state.G.value:.2f} kJ/mol")
G
cached
property
¶
Gibbs free energy of formation at this temperature [kJ/mol].
Calculated as G = H - T*S, with appropriate unit conversion.
Attributes¶
| Attribute | Type | Description |
|---|---|---|
temperature |
float | Temperature in Kelvin |
Properties¶
| Property | Alias | Type | Unit | Description |
|---|---|---|---|---|
H |
enthalpy |
ThermoProperty | kJ/mol | Enthalpy of formation |
S |
entropy |
ThermoProperty | J/(mol·K) | Standard entropy |
Cp |
heat_capacity |
ThermoProperty | J/(mol·K) | Heat capacity |
G |
gibbs_energy |
ThermoProperty | kJ/mol | Gibbs free energy |
Example¶
from phoenix import Compound
compound = Compound.from_smiles("CCO")
state = compound.thermo_at(T=500)
print(f"T = {state.temperature} K")
print(f"H = {state.H.value:.2f} kJ/mol")
print(f"S = {state.S.value:.2f} J/(mol·K)")
print(f"Cp = {state.Cp.value:.2f} J/(mol·K)")
print(f"G = {state.G.value:.2f} kJ/mol")
ThermoPropertyAccessor¶
ThermoPropertyAccessor ¶
Enables dual property/method access for temperature-dependent properties.
When accessed as attribute: returns value at 298.15 K (backward compatible) When called as method: returns value at specified temperature
Examples¶
compound = Compound.from_smiles('CCO')
As property (298.15 K)¶
hf = compound.enthalpy_of_formation print(hf) # Shows value at 298.15 K
As method with temperature¶
hf_500 = compound.enthalpy_of_formation(T=500) print(hf_500) # Shows value at 500 K
Vectorized with NumPy¶
import numpy as np temps = np.linspace(300, 1000, 100) values = compound.enthalpy_of_formation(T=temps) # Returns ndarray
Enables dual property/method access for temperature-dependent properties.
Usage¶
# As property (298.15 K)
hf = compound.enthalpy_of_formation
print(hf.value) # Value at 298.15 K
# As method with temperature
hf_500 = compound.enthalpy_of_formation(T=500)
print(hf_500.value) # Value at 500 K
# Vectorized with NumPy
import numpy as np
temps = np.linspace(300, 1000, 100)
values = compound.enthalpy_of_formation(T=temps) # Returns ndarray
Properties¶
| Property | Type | Description |
|---|---|---|
value |
float | Value at default temperature |
unit |
str | Unit of measurement |
uncertainty |
float | None |
source |
str | None |
temperature_K |
float | Default temperature (298.15) |
GroupContribution¶
GroupContribution
dataclass
¶
Single Benson group contribution to a thermodynamic property.
Attributes¶
group_name : str Group notation (e.g., "C-(H)3(C)", "Cb-H") count : int Number of occurrences in molecule contribution : float Contribution per group (in property units) property_type : str Property type: "Hf", "S", "Cp" source : str Data source (e.g., "Benson 1976", "pgradd")
Attributes¶
| Attribute | Type | Description |
|---|---|---|
group_name |
str | Group notation |
count |
int | Number of occurrences |
contribution |
float | Contribution per group |
property_type |
str | "Hf", "S", or "Cp" |
source |
str | Data source |
Properties¶
| Property | Type | Description |
|---|---|---|
total |
float | count × contribution |
ThermoValue¶
ThermoValue
dataclass
¶
A thermodynamic value with full provenance.
Used for reference values from databases.
Attributes¶
| Attribute | Type | Description |
|---|---|---|
value |
float | Property value |
unit |
str | Unit |
uncertainty |
float | None |
method |
str | Determination method |
references |
tuple[Reference, ...] | Literature references |
Estimation Functions¶
estimate_delta_hf¶
from phoenix.thermo.benson import estimate_delta_hf
def estimate_delta_hf(compound: Compound, T: float = 298.15) -> ThermoProperty
Estimate enthalpy of formation using Benson GA.
estimate_entropy¶
from phoenix.thermo.benson import estimate_entropy
def estimate_entropy(compound: Compound, T: float = 298.15) -> ThermoProperty
Estimate standard entropy using Benson GA.
estimate_heat_capacity¶
from phoenix.thermo.benson import estimate_heat_capacity
def estimate_heat_capacity(compound: Compound, temperature_K: float = 298.15) -> ThermoProperty
Estimate heat capacity using Benson GA.
Data Access¶
get_formation_enthalpy¶
from phoenix.thermo.data import get_formation_enthalpy
def get_formation_enthalpy(formula: str) -> FormationEnthalpyData
Get reference formation enthalpy data.
Temperature Constants¶
from phoenix.thermo.models import (
TEMP_MIN_WARN, # 200.0 K - warn below
TEMP_MAX_WARN, # 6000.0 K - warn above
TEMP_DEFAULT, # 298.15 K - standard state
)
Example: Full Breakdown¶
from phoenix import Compound
compound = Compound.from_smiles("CCC") # Propane
hf = compound.enthalpy_of_formation
# Print CHETAH-style breakdown
if hf.has_breakdown():
print(hf.format_breakdown())
# Access individual contributions
for group in hf.breakdown:
print(f"{group.group_name}: {group.count} × {group.contribution:.2f} = {group.total:.2f}")