/[ascend]/trunk/models/johnpye/nrel/spa.h
ViewVC logotype

Contents of /trunk/models/johnpye/nrel/spa.h

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2583 - (show annotations) (download) (as text)
Tue Apr 10 06:02:09 2012 UTC (10 years, 2 months ago) by jpye
File MIME type: text/x-chdr
File size: 9452 byte(s)
Note about code source.
1 /*
2 THIS CODE COMES FROM APPENDIX A.6 OF REPORT NREL/TP-560-34302
3 WHICH WAS OBTAINED FROM
4 http://www.osti.gov/bridge/servlets/purl/15003974-iP3z6k/native/15003974.PDF
5 */
6
7 /////////////////////////////////////////////
8 // HEADER FILE for SPA.C //
9 // //
10 // Solar Position Algorithm (SPA) //
11 // for //
12 // Solar Radiation Application //
13 // //
14 // May 12, 2003 //
15 // //
16 // Filename: SPA.H //
17 // //
18 // Afshin Michael Andreas //
19 // afshin_andreas@nrel.gov (303)384-6383 //
20 // //
21 // Measurement & Instrumentation Team //
22 // Solar Radiation Research Laboratory //
23 // National Renewable Energy Laboratory //
24 // 1617 Cole Blvd, Golden, CO 80401 //
25 /////////////////////////////////////////////
26
27 ////////////////////////////////////////////////////////////////////////
28 // //
29 // Usage: //
30 // //
31 // 1) In calling program, include this header file, //
32 // by adding this line to the top of file: //
33 // #include "spa.h" //
34 // //
35 // 2) In calling program, declare the SPA structure: //
36 // spa_data spa; //
37 // //
38 // 3) Enter the required input values into SPA structure //
39 // (input values listed in comments below) //
40 // //
41 // 4) Call the SPA calculate function and pass the SPA structure //
42 // (prototype is declared at the end of this header file): //
43 // spa_calculate(&spa); //
44 // //
45 // Selected output values (listed in comments below) will be //
46 // computed and returned in the passed SPA structure. Output //
47 // will based on function code selected from enumeration below. //
48 // //
49 // Note: A non-zero return code from spa_calculate() indicates that //
50 // one of the input values did not pass simple bounds tests. //
51 // The valid input ranges and return error codes are also //
52 // listed below. //
53 // //
54 ////////////////////////////////////////////////////////////////////////
55
56 #ifndef __solar_position_algorithm_header
57 #define __solar_position_algorithm_header
58
59
60 //enumeration for function codes to select desired final outputs from SPA
61 enum {
62 SPA_ZA, //calculate zenith and azimuth
63 SPA_ZA_INC, //calculate zenith, azimuth, and incidence
64 SPA_ZA_RTS, //calculate zenith, azimuth, and sun rise/transit/set values
65 SPA_ALL, //calculate all SPA output values
66 };
67
68 typedef struct
69 {
70 //----------------------INPUT VALUES------------------------
71
72 int year; // 4-digit year, valid range: -2000 to 6000, error code: 1
73 int month; // 2-digit month, valid range: 1 to 12, error code: 2
74 int day; // 2-digit day, valid range: 1 to 31, error code: 3
75 int hour; // Observer local hour, valid range: 0 to 24, error code: 4
76 int minute; // Observer local minute, valid range: 0 to 59, error code: 5
77 int second; // Observer local second, valid range: 0 to 59, error code: 6
78
79 double delta_t; // Difference between earth rotation time and terrestrial time
80 // It is derived from observation only and is reported in this
81 // bulletin: http://maia.usno.navy.mil/ser7/ser7.dat,
82 // where delta_t = 32.184 + (TAI-UTC) + DUT1
83 // valid range: -8000 to 8000 seconds, error code: 7
84
85 double timezone; // Observer time zone (negative west of Greenwich)
86 // valid range: -18 to 18 hours, error code: 8
87
88 double longitude; // Observer longitude (negative west of Greenwich)
89 // valid range: -180 to 180 degrees, error code: 9
90
91 double latitude; // Observer latitude (negative south of equator)
92 // valid range: -90 to 90 degrees, error code: 10
93
94 double elevation; // Observer elevation [meters]
95 // valid range: -6500000 or higher meters, error code: 11
96
97 double pressure; // Annual average local pressure [millibars]
98 // valid range: 0 to 5000 millibars, error code: 12
99
100 double temperature; // Annual average local temperature [degrees Celsius]
101 // valid range: -273 to 6000 degrees Celsius, error code; 13
102
103 double slope; // Surface slope (measured from the horizontal plane)
104 // valid range: -360 to 360 degrees, error code: 14
105
106 double azm_rotation; // Surface azimuth rotation (measured from south to projection of
107 // surface normal on horizontal plane, negative west)
108 // valid range: -360 to 360 degrees, error code: 15
109
110 double atmos_refract;// Atmospheric refraction at sunrise and sunset (0.5667 deg is typical)
111 // valid range: -5 to 5 degrees, error code: 16
112
113 int function; // Switch to choose functions for desired output (from enumeration)
114
115 //-----------------Intermediate OUTPUT VALUES--------------------
116
117 double jd; //Julian day
118 double jc; //Julian century
119
120 double jde; //Julian ephemeris day
121 double jce; //Julian ephemeris century
122 double jme; //Julian ephemeris millennium
123
124 double l; //earth heliocentric longitude [degrees]
125 double b; //earth heliocentric latitude [degrees]
126 double r; //earth radius vector [Astronomical Units, AU]
127
128 double theta; //geocentric longitude [degrees]
129 double beta; //geocentric latitude [degrees]
130
131 double x0; //mean elongation (moon-sun) [degrees]
132 double x1; //mean anomaly (sun) [degrees]
133 double x2; //mean anomaly (moon) [degrees]
134 double x3; //argument latitude (moon) [degrees]
135 double x4; //ascending longitude (moon) [degrees]
136
137 double del_psi; //nutation longitude [degrees]
138 double del_epsilon; //nutation obliquity [degrees]
139 double epsilon0; //ecliptic mean obliquity [arc seconds]
140 double epsilon; //ecliptic true obliquity [degrees]
141
142 double del_tau; //aberration correction [degrees]
143 double lamda; //apparent sun longitude [degrees]
144 double nu0; //Greenwich mean sidereal time [degrees]
145 double nu; //Greenwich sidereal time [degrees]
146
147 double alpha; //geocentric sun right ascension [degrees]
148 double delta; //geocentric sun declination [degrees]
149
150 double h; //observer hour angle [degrees]
151 double xi; //sun equatorial horizontal parallax [degrees]
152 double del_alpha; //sun right ascension parallax [degrees]
153 double delta_prime; //topocentric sun declination [degrees]
154 double alpha_prime; //topocentric sun right ascension [degrees]
155 double h_prime; //topocentric local hour angle [degrees]
156
157 double e0; //topocentric elevation angle (uncorrected) [degrees]
158 double del_e; //atmospheric refraction correction [degrees]
159 double e; //topocentric elevation angle (corrected) [degrees]
160
161 double eot; //equation of time [minutes]
162 double srha; //sunrise hour angle [degrees]
163 double ssha; //sunset hour angle [degrees]
164 double sta; //sun transit altitude [degrees]
165
166 //---------------------Final OUTPUT VALUES------------------------
167
168 double zenith; //topocentric zenith angle [degrees]
169 double azimuth180; //topocentric azimuth angle (westward from south) [-180 to 180 degrees]
170 double azimuth; //topocentric azimuth angle (eastward from north) [ 0 to 360 degrees]
171 double incidence; //surface incidence angle [degrees]
172
173 double suntransit; //local sun transit time (or solar noon) [fractional hour]
174 double sunrise; //local sunrise time (+/- 30 seconds) [fractional hour]
175 double sunset; //local sunset time (+/- 30 seconds) [fractional hour]
176
177 } spa_data;
178
179 //Calculate SPA output values (in structure) based on input values passed in structure
180 int spa_calculate(spa_data *spa);
181
182 #endif

john.pye@anu.edu.au
ViewVC Help
Powered by ViewVC 1.1.22