There is a general model of stellar structure (stellar structure model or stellar model) consisting of a hot region in the center where fusion is releasing energy (the stellar core), a region near the apparent surface of the star that generates the light that escapes (the photosphere), and regions in between that transfer the energy from core to photosphere via electromagnetic radiation (i.e., radiative transfer) and/or convection (transfer of heat by movement of bulk amounts the material holding the heat) with conduction (transfer of heat by collision of particles) generally only a minor factor. The structural details depend nearly entirely on the mass and age of the star, the smaller or rarer factors including the initial chemical composition (characterized by its metallicity), the degree of rotation, and nearby companions.
Large mass stars have CNO cycle fusion in the core, with a region surrounding it conveying energy via radiative transfer, the inner part of which also has some proton-proton chain fusion, which can be triggered by somewhat lower temperatures.
Small mass stars such as red dwarves have only proton-proton chain fusion in the core, and transfer energy through convection.
Between are stars like the Sun, which have an inner portion much like a large star, with a convection layer surrounding it.
The most basic mathematical model includes four differential equations (stellar structure equations) relating changes in mass, temperature, luminosity, and pressure to the distance from the center of the star. They presume local thermodynamic equilibrium and hydrostatic equilibrium.
dm —— = 4πr²ρ dr
(The mass continuity equation aka mass conservation equation: density is assumed constant at distance r from the center)
dP Gmρ —— = - ——— dr r²
(pressure counteracts gravity at distance r from the center)
dL —— = 4πr²ε dr
(The luminosity equation: energy is conserved, any addition is from fusion at that level)
dT 3κρL —— = ———————— dr 64πr²σT³
(Opacity directly affects the rate at which temperature changes with radius, i.e., the temperature gradient. This is the equation for radiative transfer, i.e., energy transfer via EMR; Other equations are needed if heat conduction is significant or if there is convection, which can happen if the temperature gradient is sufficiently high.)
Opacity, density, and energy generation are functions of temperature and pressure and it is key that simple-but-effective approximate models have been developed (equations of state).
Among approximations used to make the behavior of a star's atmosphere (stellar atmosphere) more tractable are the plane-parallel atmosphere approximation (ignoring the curvature of its layers) and the gray atmosphere approximation (ignoring the wavelength-dependence by using values averaged over wavelength). Also used is the Eddington approximation.
To model a star, these are generally solved using difference equations, approximating the differential equations by calculating differences over a small value. A star with these equations, a set of consistent boundary conditions needs to be determined/selected. Some are clear: m, L must be zero at the center (where r = 0), while ρ, P, and T must be (essentially) zero at the surface (the maximum value of r). Since any numerical calculations must begin at a point with values for all the variables, guessing is required and multiple calculation attempts are likely needed to satisfy the above five constraints.
Codes using this approach are called Eulerian codes: an alternative is Lagrangian codes, that specify (changes in) values in relation to dm rather than dr, i.e., mass rather than radius.