Thermopower in nanowires: A generic model and formula