# Why does the sun have a convection layer and a radiation layer?

Why is the outer section of the sun convective but the inner section stable and only radiative? They are both made up of the same kind of matter, both heated by the core.

The onset of convection is controlled by temperature gradients (see the famous experiment from Rayleigh & Bénard. When those become too strong, convection sets in.

How strong a temperature gradient gets, depends on the local efficiency of energy transport inside the star. But for the sun (and other lower mass stars), the surface radiates energy away efficiently, dropping the temperature there compared to the rest of the star, making the outer layers convective. Lower temperatures (not gradients) compared to high-mass stars also play a role in controlling the energy transport for lower mass stars. Cool temperatures will allow the formation of $$H^{-}$$ (negatively charged hydrogen ions) that give high opacities and thus prohibit energy transport.

For high-mass stars it is the enormously fast fusion processes in the core that 'overheat' this region, again letting convection take over.

The wikipedia page linked by @pm-2ring in a comment contains a very clear summary of what decides if convection happens in a particular region:

The Schwarzschild criterion expresses the conditions under which a region of a star is unstable to convection. A parcel of gas that rises slightly will find itself in an environment of lower pressure than the one it came from. As a result, the parcel will expand and cool. If the rising parcel cools to a lower temperature than its new surroundings, so that it has a higher density than the surrounding gas, then its lack of buoyancy will cause it to sink back to where it came from. However, if the temperature gradient is steep enough (i. e. the temperature changes rapidly with distance from the center of the star), or if the gas has a very high heat capacity (i. e. its temperature changes relatively slowly as it expands) then the rising parcel of gas will remain warmer and less dense than its new surroundings even after expanding and cooling. Its buoyancy will then cause it to continue to rise. The region of the star in which this happens is the convection zone.

To work out the structure of a particular star (and in particular work out which parts of it are convective and which are not) you then have to solve a set of equations which relate the temperature and density at each radius to the flow of energy from the core to space and the hydrostatic balance within the star.

The interior of a stable star is in a state of hydrostatic equilibrium: the forces on any small volume almost exactly counterbalance each other. The balanced forces are inward gravitational force and an outward force due to the pressure gradient within the star. The pressure gradient is established by the temperature gradient of the plasma; the outer part of the star is cooler than the core. The temperature at the core of a main sequence or giant star is at least on the order of $$10^7$$ K. The resulting temperature and pressure at the hydrogen-burning core of a main sequence star are sufficient for nuclear fusion to occur and for sufficient energy to be produced to prevent further collapse of the star.