| wiki.naturalfrequency.com | ECOTECT COMMUNITY WIKI!

Archive site for Autodesk Ecotect Analysis educational resources, notes and tutorials

Solar Position: Calculator

Below is an interactive tool for calculating the azimuth and altitude of the Sun at any date and time. Your first step in the use of this tool is to set the Latitude and Longitude of the desired location - making sure to first set the TimeZone value as this will make entering the longitude easier. In addition to the current Sun position, it also calculates Sunrise / Sunset times, the Declination and Equation of Time as well as the relative shadow length. To enter a value manually, remember to hit the Enter key.

It seems you are missing out on our interactive content. Please visit macromedia.com and update your browser with the latest flash plugin... or if you think your version of Flash should be okay, then click here to bypass this Flash detection.

Figure 1 - An interactive solar position calculator with additional information such as the Declination and Equation of Time as well as the relative shadow length for a vertical element of height h.
You can actually download this as a stand-alone Windows application as part of the Teaching_Tools package.

Manual Calculation Method

The algorith used in the interactive tool above to determine the position of the Sun from any location on Earth is outlined below. The azimuth and altitude of the Sun are calculated using formulae first proposed by Spencer (Spencer, 1965), then refined by Szokolay (Szokolay, 1996). Values for solar declination and the equation of time are determined using formulae proposed by Carruthers, et al [1990], as shown in the following pseudo-code.

Please Note: All angles are in radians, a common requirement of most implementations of trigonometric functions in programming languages and spreadsheets. Hence the (PI/180) conversion factors seen within the code.

Declination

Solar declination as per Carruthers et al:

$\large t = 2 \pi \times \frac{JulianDate}{366}$

$\large \begin{eqnarray} Declination & = & 0.322003\\ & - & 22.971 \times \cos(t)\\ & - & 0.357898 \times \cos(2t)\\ & - & 0.14398 \times \cos(3t)\\ & + & 3.94638 \times \sin(t)\\ & + & 0.019334 \times \sin(2t)\\ & + & 0.05928 \times \sin(3t) \end{eqnarray}$

Equation of Time

Equation of time as per Carruthers et al:

$\large t = [279.134 + (0.985647 \times JulianDate)] \times (\frac{\pi}{180})$

$\large \begin{eqnarray} Equation & = & 5.0323\\ & - & 100.976 \times \sin(t)\\ & + & 595.275 \times \sin(2t)\\ & + & 3.6858 \times \sin(3t)\\ & - & 12.47 \times \sin(4t)\\ & - & 430.847 \times \cos(t)\\ & + & 12.5024 \times \cos(2t)\\ & + & 18.25 \times \cos(3t) \end{eqnarray}$

Then convert seconds to hours:

$\large Equation = \frac{Equation}{3600.0}$

Solar Altitude

$\large HourAngle = [15 \times (LocalTime - 12)] \times (\frac{\pi}{180})$

Then calculate current altitude (in radians):

$\large t = \sin(Declination) \times \sin(Latitude)\\ u = \cos(Declination) \times \cos(Latitude) \times \cos(HourAngle)\\ Altitude = arcsin(t + u)$

Solar Azimuth

The calculation of azimuth (in radians):

$\large t = cos(Latitude) \times \sin(Declination)\\ u = \cos(Declination) \times \sin(Latitude) \times \cos(HourAngle)\\ ts = -\cos(Declination) \times \sin(HourAngle)$

Now, it would be great if all math libraries worked the same, because then the calculation of azimuth would be quite simple, as shown below.

HOWEVER THE FOLLOWING LINE IN SOME MATH LIBRARIES - INCLUDING JAVASCRIPT - GIVES AN INCORRECT ANSWER !!!

$\large Azimuth = \arccos \left(\frac{\displaystyle t - u}{\displaystyle \cos(Altitude)}\right)$

Unfortunately life is a bit more complex so we have to do some quadrant checking. For this we will need the sin and cos values from which to work out which quadrant we are in.

NOTE: To avoid division by zero errors, first check:

if (Altitude < (p/2.0)) {
sin1 = ts / cos(Altitude)
cos2 = (t - u) / cos(Altitude)
}

else {
sin1 = cos2 = 0.0
}

Then do some more range checking, just for safety sake:

if (sin1 > 1.0) sin1 = 1.0;
if (sin1 < -1.0) sin1 = -1.0;
if (cos2 < -1.0) cos2 = -1.0;
if (cos2 > 1.0) cos2 = 1.0;

The next big issue is to check the quadrants:

if (sin1 < -0.99999) {
Azimuth = asin(sin1);
}

else if (sin1 > 0.0) and (cos2 < 0.0) {

if (sin1 >= 1.0) {
Azimuth = -(PI/2.0);
}

else {
Azimuth = (PI/2.0) + ((PI/2.0) - asin(sin1));
}

}

else if (sin1 < 0.0) and (cos2 < 0.0) {
if (sin1 <= -1.0) {
Azimuth = (PI/2.0);
}

else {
Azimuth = -(PI/2.0) - ((PI/2.0) + asin(sin1));
}
}

else {
Azimuth = asin(sin1);
}

Then a final last-ditch range check:

if (Azimuth < 0.0) and (LocalTime < 10.0) {
Azimuth = -Azimuth
}

Simple, huh...

Javascript Solar Position Calculator

If you are unsure of the exact meaning of any of these formula, simply check the source of this page for a fully functional JavaScript implementation of it. The following HTML form uses the mathematical method described above to calculate a range of solar data at a particular date and time. Simply enter the latitude, longitude and time-zone of the desired location, set the required date and time, and then select the Calculate button.

NOTE: You must be careful to select the correct time zone to match the longitude of the site.

INPUT PARAMETERS
Latitude:  °
Longitude: °
Time Zone:
Required Date:
Local Time (24hr):

OUTPUT RESULTS
Declination: °
Equation of Time: minutes
Solar Altitude: °
Solar Azimuth: °
Solar Time: Hrs
Sunrise: Hrs
Sunset: Hrs

1/2 Hourly Solar Positions

This same method can be used to generate a list of solar positions over a particular day. The 1/2 Hourly Solar Position Calculator can be used for this purpose.

References

1. Carruthers D, Uloth C and Roy G. G., 1990, An Evaluation of Formulae for Solar Declination and the Equation of Time, Research Report No RR17, School of Architecture, the University of Western Australia, Jan.

Approximate Solar Coordinates - U.S. Naval Observatory
http://aa.usno.navy.mil/faq/docs/SunApprox.html
Other Solar Position Calculators
http://www.cs.ucla.edu/~simonw/sunpos/
http://susdesign.com/sunangle/
NASA Information on Sundials
Solar Position
Solar Position: 1/2 Hourly