Interplay of beryllium segregation and diffusion in heavily doped GaAs and AlGaAs grown by molecular beam epitaxy (thermodynamic analysis)