Optimization of solar thermophotovoltaic systems including the thermal balance