A thermodynamical derivation of the quantum potential and the temperature of the wave function