Calculating the chemical exergy of materials