thermal energy calculation