Energy Flow in buildings
Energy flow in buildings is conceptually simple, but complex in detail because the flow varies with the weather (temperature, amount of sun, sun position, clouds, humidity) and user behavior.
GAINS: During the day the sun warms any building surrfaces facing it, while also entering any windows that are exposed and warming the interior. Both day and night, heat comes from fuel, electric uses (appliances, lighting) and body heat, and that heat warms the interior air and interior surfaces.
LOSSES: Heat from the interior moves primarily via conduction thru the walls, ceiling and floor. Once at the exterior it moves into the air via conduction, convection and wind, or thru the ground via conduction. An exterior surface warmed by the sun will lose less heat than one that is at air temperature. The exterior surface may also lose heat via radiation to either a cold sky or cold ground. There is also a loss due to warm air leaking out of the building. Wind will increase conduction losses slightly (by decreasing average R value by approximately .6), but will also increase air leakage, which is the dominant factor changed by wind.
Its important to understand that heat moves from hot to cold, regardless of direction. See heat transmission to understand heat movement.
In general, conduction and air leakage are the dominant heat loss methods, although what we mean by "conduction" is not necessarily exactly what a physicist would call it. In buildings the calculation of heat transfer is a simplification, so we're using the word "conduction" a bit loosely. What we really mean is conduction + radiation when the mean radiant temperature is the same as the air temperature.
When the mean radiant temperature is not the same as the air temperature, there is an additional heat transfer amount that is all radiant. This occurs in three primary situations: when the sun is shining, when the air is dry (especially at high altitudes), and when the ground is colder/warmer than the air. (see "heat transfer by radiation" for how heat transfer by radiation works).
So when the sun shines on a building surfaces it warms because there is a net influx of energy, the surface will then warm, either reducing heat flow from inside to out, or if the surface warms enough, causing heat to flow from outside to in. When the ground is cold, the building will emit more to the ground than it receives back--except that we have to factor in the absorptivity and emissivity of both objects--for example snow is highly reflective so the net transfer of energy is less than to ground of the same temperature. If the air is transparent enough (ie dry and not dense), then radiation will pass long distances thru is, including some that leaves the atmosphere. Since the atmosphere generally gets colder as you get higher, there is almost always less energy coming from the sky than going to it.
Note that infrared radiation comes in two main varieties: shortwave and longwave. The difference is important because, glass for example is transparent to shortwave IR, but not very transparent to longwave IR. The atmosphere is actually fairly transparent to most longwave IR when its dry, but gets more opaque as moisture is added. Solar energy is primarily in the shortwave IR, visible and UV spectrum, and the atmosphere is most transparent around the visible spectrum, although again water vapor makes it more opaque.
Heat loss varies primarily as the outdoor temperature and wind speed vary. Wind speed primarily affects air leakage. The sun will either decrease heat loss, or cause heat gain, while dry cold night sky will increase heat loss, primarily from the roof.