Optimizing Performance Of A Thermal Energy Storage System