How to calculate the expected surface temperature of a planet I'm writing a program to generate solar systems but I'm having trouble calculating the expected temperature of a planet. I have found a formula to calculate this, but I haven't been able to get a remotely correct answer out of it as it doesn't clearly state what units your supposed to use.

This formula I found:

$$4 \pi R ^ 2 ơ T ^ 4 = \frac{\pi  R ^ 2  L_{\odot}(1 - a)}{(4  \pi  d ^ 2)}$$

where $R$ is the planet's radius (not sure what units), $d$ is the distance from the Sun (it mentions AU), $a$ is the albedo, $L_{\odot}$ is the luminosity of the Sun (which I assume can be interchanged with the luminosity of any star), $T$ is the temperature of the planet (kelvin, this is what I'm trying to get), and $ơ$ is the Stefan-Boltzmann constant.

The site I found it on is notes for an astronomy college course. Here is the link:

http://www.astronomynotes.com/solarsys/s3c.htm#

Any help would be very much appreciated.
The formula

$$4 \pi R ^ 2 ơ T ^ 4 = \frac{\pi  R ^ 2  L_{\odot}(1 - a)}{4  \pi  d ^ 2}$$

is correct, if you want to calculate the radiative equilibrium temperature. You only need to use the right units. We can further simplify the formula to

$$T ^ 4 = \frac{ L_{\odot}(1 - a)}{16  \pi  d ^ 2 ơ}\;.$$

You should input the luminosity in watts, the distance to the star in meters and the Stefan-Boltzmann constant as

$$σ = 5.670373 × 10^{−8} \;\mathrm{W}\; \mathrm{m}^{−2}\; \mathrm{K}^{−4}.$$

The albedo is dimensionless. The resulting temperature will be in Kelvins. Let me make an example for Earth:

$d = 149,000,000,000 \;\mathrm{m}$

$L = 3.846×10^{26} \;\mathrm{W}$

Albedo of Earth is 0.29. (The Bond albedo should be used.) You will get

$$
T ^ 4 = \frac{ 3.846×10^{26}(1 - 0.29)}{16  \pi \times  (149,000,000,000) ^ 2 \times (5.670373 × 10^{−8})}=4,315,325,985 \;\mathrm{K}^4\;.
$$

After powering this number to 1/4, we obtain temperature 256 K, which is -17° C. This looks reasonable. The real average temperature on Earth is closer to 15° C, but the greenhouse effect is responsible for the difference.