I'm currently learning about thermoelectric generators and I learned about the two p and n semiconductors. I understand how the n-type semiconductors works which is that when one side gets heated then the other side will have more electrons giving it a negative charge, since the more heated side will have more excited electrons and they will move to the colder side faster than the colder side can get to the hot side. What I don't comprehend is how the p type semiconductor will do the exact opposite which is that the negative side will be on the hot side and the positive will be on the cold side. I know that p-type semiconductors are doped with elements for one less silicon atom in the lattice so that it can accept electrons, and I've heard it conducts positive charges but that's essentially it. If someone could give a clear explanation why that would be great thanks!
It is because the electron mobility is fundamentally different in the two types.
An n-type material has free electrons. This can for instance be achieved via doping with an element of higher atomic number - if the dopant atom matches the source material structure, its extra electrons that aren't needed for bonding to neighbours within this structure are shielded strongly and are thus more easily ripped free.
They can thus move around fairly easy as excited "excess" electrons from atom to atom. If they gain further thermal energy, their excitation increases, they are even more easily ripped free and their subatomic vibrations will make them move about further and more "violently". They "fill" more and "push" each other away more than colder electrons do. Thus they are eventually "pushed" to areas with colder electrons more than colder electrons are pushed towards them - giving the overall electron drift from hot to cold.
A p-type material does not carry free electrons. Such material is made via the opposite type of doping, for instance with a dopant atom of lower atomic number. If this dopant matches the source material structure, it still cannot easily fit in since it is missing an electron - it thus has to "steal" or "take over" electrons from neighbour atoms. The neighbour is now missing an electron. This neighbour still fits in the structure so it has a hole where the missing electron should have been. It must then steal an electron from another neighbour, so that this neighbour now has the hole. In this way the hole can move from atom to atom. This hole is fairly easily stealable, since the atom with the hole attracts electrons with close to the same force with which another atoms holds on to its electron.
By adding thermal energy, the excitation of electrons as usual makes them more loosely bound. But this means that it is easier for hot atoms to steal electrons - less additional force is required. It is easier for a hot atom to steal an electron from a colder atom, and with a heat gradient across the material you have hot atoms close to gradually colder atoms continuously throughout. Thus electrons are being stolen in larger numbers by the hot side. The hole moves to where the electron came from, so towards the colder side.
And this is how it works. Overall, the majority charge-carrier always moves away from the heat source regardless of whether it is an electron of a hole. But a hole moving away corresponds to electrons moving towards. By putting a p-type and n-type together and setting up such an electric path, then when heating that junction you have electrons flowing in the same direction along this path. Which is a requirement if we ever want to make a closed circuit to retrieve electric energy from.