code for modeling the thermal storage battery system