1 |
|
2 |
/* WARNING: this is a FIRST DRAFT of the code and HAS NOT BEEN CHECKED yet. */ |
3 |
|
4 |
/** @FILE |
5 |
Code reproduced with minor cosmetic changes from: |
6 |
R Grena (2008), An algorithm for the computation of the solar position, |
7 |
Solar Energy (82), pp 462-470. |
8 |
|
9 |
This header file contains the declaration of a class which includes all the |
10 |
input and output data, and the function that performs the calculation. |
11 |
|
12 |
To calculate the sun position, follow these steps: |
13 |
|
14 |
1. include this file. |
15 |
2. declare a variable of type SunCoord. |
16 |
3. Initialise the variable given the 9 input quantities required. |
17 |
This can be done in the declaration, listing the quantities between |
18 |
commas, or calling the function SetCoord(). In both cases, only the first |
19 |
four quantities are required; the others default to standard values |
20 |
(pressure = 1 atm, T = 20 째C, 0 for all the other quantities) if omitted. |
21 |
Longitude and latitude must be given in RADIANS, pressure in ATM, |
22 |
temperature in 째C. |
23 |
Day, Month and Year are integer, UT in decimal hour from 0 to 24 (e.g. |
24 |
3:30 pm becomes 15.5). |
25 |
4. Call the Calculate() method of the SunCoord object. |
26 |
|
27 |
Example: |
28 |
(see the original publication) |
29 |
|
30 |
Warning: in order to improve accessibility and efficiency, there is not |
31 |
access control in the class. The user is free to directly access and |
32 |
modify all the data and there is not any control of consistency. Some |
33 |
caution in the use of the class is advisable. |
34 |
*/ |
35 |
#ifndef SUNPOS_GRENA_H |
36 |
#define SUNPOS_GRENA_H |
37 |
|
38 |
#include <iostream> |
39 |
#include <cmath> |
40 |
|
41 |
#ifndef PI |
42 |
# define PI 3.14159265358979 |
43 |
#endif |
44 |
|
45 |
|
46 |
class SunCoord{ |
47 |
public: |
48 |
// input data |
49 |
double UT; |
50 |
int Day, Month, Year; |
51 |
double Delta_t; |
52 |
double ObserverLatitude; |
53 |
double ObserverLongitude; |
54 |
double Pressure; |
55 |
double Temperature; |
56 |
|
57 |
// output data |
58 |
double HourAngle; |
59 |
double TopocRightAscension; |
60 |
double TopocDeclination; |
61 |
double TopocHourAngle; |
62 |
double Elevation_no_refrac; |
63 |
double RefractionCorrection; |
64 |
double Zenith; |
65 |
double Azimuth; |
66 |
|
67 |
// functions |
68 |
/** set the input data quickly */ |
69 |
void SetCoord(double UT, int Day, int Month, int Year, double Delta_t |
70 |
, double ObserverLatitude, double ObserverLongitude, double Pressure |
71 |
, double Temperature |
72 |
) : UT(UT), Day(Day), Month(Month), Year(Year), Delta_t(Delta_t) |
73 |
, ObserverLatitude(ObserverLatitude) |
74 |
, ObserverLongitude(ObserverLongitude), Pressure(Pressure) |
75 |
, Temperature(Temperature){} |
76 |
|
77 |
void Calculate(); |
78 |
} |
79 |
|
80 |
|
81 |
|
82 |
|
83 |
|