Umasoft
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Groups Pages
SPA.h
1 //-------------------------------------------
2 // For convenient integration into the VTP
3 // the altitude variable and SunAltAzi prototype
4 // were added this file.
5 //
6 // See SPA.cpp for other chages
7 //
8 // -Kevin Behilo 1/9/04
9 //-------------------------------------------
10 
12 // HEADER FILE for SPA.C //
13 // //
14 // Solar Position Algorithm (SPA) //
15 // for //
16 // Solar Radiation Application //
17 // //
18 // May 12, 2003 //
19 // //
20 // Filename: SPA.H //
21 // //
22 // Afshin Michael Andreas //
23 // afshin_andreas@nrel.gov (303)384-6383 //
24 // //
25 // Measurement & Instrumentation Team //
26 // Solar Radiation Research Laboratory //
27 // National Renewable Energy Laboratory //
28 // 1617 Cole Blvd, Golden, CO 80401 //
30 
32 // //
33 // Usage: //
34 // //
35 // 1) In calling program, include this header file, //
36 // by adding this line to the top of file: //
37 // #include "spa.h" //
38 // //
39 // 2) In calling program, declare the SPA structure: //
40 // spa_data spa; //
41 // //
42 // 3) Enter the required input values into SPA structure //
43 // (input values listed in comments below) //
44 // //
45 // 4) Call the SPA calculate function and pass the SPA structure //
46 // (prototype is declared at the end of this header file): //
47 // spa_calculate(&spa); //
48 // //
49 // All output values (listed in comments below) will be //
50 // computed and returned in the passed SPA structure. //
51 // //
53 
54 
55 #ifndef SPA_H_INCLUDED
56 #define SPA_H_INCLUDED
57 
58 class spa_data
59 {
60 public:
61  //----------------------INPUT VALUES------------------------
62 
63  int year; //4-digit year
64  int month; //2-digit month (1-12)
65  int day; //2-digit day (1-31)
66  int hour; //observer local hour
67  int minute; //observer local minute
68  int second; //observer local second
69 
70  float delta_t; //difference between earth rotation time and terrestrial time
71  //(from observation) [seconds]
72  float timezone; //observer timezone (negative west of greenwich) [hours]
73  float longitude; //observer longitude (negative west of greenwich) [degrees]
74  float latitude; //observer latitude (negative south of equator) [degrees]
75  float elevation; //observer elevation [meters]
76  float pressure; //annual average local pressure [millibars]
77  float temperature; //annual average local temperature [degrees celcius]
78 
79  float slope; //surface slope (measured from the horizontal plane) [degrees]
80  float azm_rotation; //surface azimuth rotation (measured from south to projection of
81  //surface normal on horizontal plane, negative west) [degrees]
82 
83  float atmos_refract; //atmospheric refraction at sunrise and sunset [degrees]
84  //0.5667 degrees is typical
85 
86  //-----------------Intermediate OUTPUT VALUES--------------------
87 
88  double jd; //julian day
89  double jc; //julian century;
90 
91  double jde; //julian ephemeris day
92  double jce; //julian ephemeris century
93  double jme; //julian ephemeris millennium
94 
95  double l; //earth heliocentric longitude [degrees]
96  double b; //earth heliocentric latitude [degrees]
97  double r; //earth radius vector [Astronomical Units, AU]
98 
99  double theta; //geocentric longitude [degrees]
100  double beta; //geocentric latitude [degrees]
101 
102  double x0; //mean elongation (moon-sun) [degrees]
103  double x1; //mean anomaly (sun) [degrees]
104  double x2; //mean anomaly (moon) [degrees]
105  double x3; //argument latitude (moon) [degrees]
106  double x4; //ascending longitude (moon) [degrees]
107 
108  double del_psi; //nutation longitude [degrees]
109  double del_epsilon; //nutation obliquity [degrees]
110  double epsilon0; //ecliptic mean obliquity [arc seconds]
111  double epsilon; //ecliptic true obliquity [degrees]
112 
113  double del_tau; //aberration correction [degrees]
114  double lamda; //apparent sun longitude [degrees]
115  double nu0; //greenwich mean sidereal time [degrees]
116  double nu; //greenwich sidereal time [degrees]
117 
118  double alpha; //geocentric sun right ascension [degrees]
119  double delta; //geocentric sun declination [degrees]
120 
121  double h; //observer hour angle [degrees]
122  double xi; //sun equatorial horizontal parallax [degrees]
123  double del_alpha; //sun right ascension parallax [degrees]
124  double delta_prime; //topocentric sun declination [degrees]
125  double alpha_prime; //topocentric sun right ascension [degrees]
126  double h_prime; //topocentric local hour angle [degrees]
127 
128  double e0; //topocentric elevation angle (uncorrected) [degrees]
129  double del_e; //atmospheric refraction correction [degrees]
130  double e; //topocentric elevation angle (corrected) [degrees]
131 
132  //---------------------Final OUTPUT VALUES------------------------
133 
134  double zenith; //topocentric zenith angle [degrees]
135  double azimuth180; //topocentric azimuth angle (westward from south) [-180 to 180 degrees]
136  double azimuth; //topocentric azimuth angle (eastward from north) [0 to 360 degrees]
137  double incidence; //surface incidence angle [degrees]
138  double altitude; //***KMB topocentric altitude angle of the sun
139 
140  double eot; //equation of time [degrees]
141  double suntransit; //local sun transit time (or solar noon) [fractional hour]
142  double sunrise; //local sunrise time [fractional hour]
143  double sunset; //local sunset time [fracitonal hour]
144 };
145 
146 //Calculate all SPA output values (in structure) based on input values passed in structure
147 void SetCommonValues(spa_data &spa, float longitude, float latitude,
148  int year, int month, int day, int hour, int minute, int second,
149  float timezone, float elevation);
150 void spa_calculate(spa_data *spa);
151 
152 #endif // SPA_H_INCLUDED
153