Modeling and simulation of a segmented thermoelectric generator