Optimization of Segmented Thermoelectric Generator and Calculation of Performance