# Temperature function for stars?

I was thinking that for a star to be stable, the rate of energy emittance through a shell of radius r is constant, otherwise there would be a buildup of energy which would change the temperature and hence the radius of the star. So I get $$r^2 T^4 = R_{surface}^2T_{surface}^4$$ using the Stefan Boltzmann law. But it gives the wrong results when I check for the temperature near the core of the Sun. But why? If this model is wrong, how would I get Temperature as a function of distance from centre for a star?

• The Sun is a complicated thing - it doesn't emit only from the centre. In reality the Sun is completely opaque to EM waves at the centre and the light we measure is only emitted from the surface. – Akerai Sep 27 '19 at 11:57
• en.wikipedia.org/wiki/Stellar_structure – Kyle Kanos Sep 27 '19 at 12:04
• do not forget there is a lot of convection too – Wolphram jonny Sep 27 '19 at 12:33