# 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. Sep 27, 2019 at 11:57
• en.wikipedia.org/wiki/Stellar_structure Sep 27, 2019 at 12:04
• do not forget there is a lot of convection too
– user65081
Sep 27, 2019 at 12:33

Thus outside the 20% core of the Sun, and interior to the convection zone, you can write that the net outward flux $$l \frac{d}{dr} \sigma T^4 = {\rm constant}\ ,$$ where $$l$$ is the photon mean free path and the constant is $$L/4\pi r^2$$, with $$L$$ the solar luminosity.