/[ascend]/trunk/models/johnpye/grena/sunpos_grena.h
ViewVC logotype

Contents of /trunk/models/johnpye/grena/sunpos_grena.h

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2649 - (show annotations) (download) (as text)
Wed Dec 12 12:39:25 2012 UTC (9 years, 7 months ago) by jpye
File MIME type: text/x-chdr
File size: 4264 byte(s)
Fixing GPL header, removing postal address (rpmlint incorrect-fsf-address)
1 /* ASCEND modelling environment
2 Copyright (C) 2011 Carnegie Mellon University
3
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; either version 2, or (at your option)
7 any later version.
8
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
13
14 You should have received a copy of the GNU General Public License
15 along with this program. If not, see <http://www.gnu.org/licenses/>.
16 */
17
18 /* WARNING: this is a FIRST DRAFT of the code and HAS NOT BEEN CHECKED yet. */
19
20 /** @FILE
21 Code reproduced with minor cosmetic changes from:
22 R Grena (2008), An algorithm for the computation of the solar position,
23 Solar Energy (82), pp 462-470.
24
25 This header file contains the declaration of a class which includes all the
26 input and output data, and the function that performs the calculation.
27
28 To calculate the sun position, follow these steps:
29
30 1. include this file.
31 2. declare a variable of type SunCoord.
32 3. Initialise the variable given the 9 input quantities required.
33 This can be done in the declaration, listing the quantities between
34 commas, or calling the function SetCoord(). In both cases, only the first
35 four quantities are required; the others default to standard values
36 (pressure = 1 atm, T = 20 ��C, 0 for all the other quantities) if omitted.
37 Longitude and latitude must be given in RADIANS, pressure in ATM,
38 temperature in ��C.
39 Day, Month and Year are integer, UT in decimal hour from 0 to 24 (e.g.
40 3:30 pm becomes 15.5).
41 4. Call the Calculate() method of the SunCoord object.
42
43 Example:
44 (see the original publication)
45
46 Warning: in order to improve accessibility and efficiency, there is not
47 access control in the class. The user is free to directly access and
48 modify all the data and there is not any control of consistency. Some
49 caution in the use of the class is advisable.
50 */
51 #ifndef SUNPOS_GRENA_H
52 #define SUNPOS_GRENA_H
53
54 #include <math.h>
55 #ifndef PI
56 # define PI 3.14159265358979
57 #endif
58
59 /**
60 Structure to hold location data as well as desird time point.
61
62 FIXME convert fields p, T to base SI units Pa and K.
63 */
64 typedef struct SunPos_struct{
65 // input data
66 double t_G; ///< Julian Day, offset such that 0 = noon 1 Jan 2003.
67 double Delta_t; ///< Difference between UT and Terrestrial Time, in seconds. Zero is probably OK here.
68 double latitude; ///< Latitude (N = positive??), in RADIANS.
69 double longitude; ///< Longitude (E = positive??), in RADIANS.
70 double p; ///< Pressure, in ATM (used for refraction calculation)
71 double T; ///< Temperature, in ��C (used for refraction calculation)
72 } SunPos;
73
74 // functions
75
76 /** Calculate time given the input date fields and store it in the SunPos object.
77 @param UT fractional universal time (GMT) in hours from midnight (or fractional hours as required)
78 @param Day Day of the month, starting at 1??
79 @param Month Month of the year, starting at 1??
80 @param Year Year, eg 2011.
81 @param Delta_t Difference between UT and Terrestrial Time, in seconds.
82 */
83 void SunPos_calc_time(SunPos *S, double UT, int Day, int Month, int Year, double Delta_t);
84
85 /** Set Julian Day time directly in days since noon 1 Jan 2003 UTC.
86 @param t_G Julian Day (offset such that 0 = noon 1 Jan 2003 UTC)
87 @param Delta_t @see SunPos_struct.
88 */
89 void SunPos_set_time(SunPos *S, double t_G, double Delta_t);
90
91 /** Set location of observer on Earth
92 @param latitude latitude in RADIANS!
93 @param longitude longitude in RADIANS!
94 */
95 void SunPos_set_lat_long(SunPos *S, double latitude, double longitude);
96
97 /** Set local atmospheric conditions
98 @param p Pressure in ATM
99 @param T Temperature in ��C
100 */
101 void SunPos_set_press_temp(SunPos *S, double p, double T);
102
103 /**
104 Calculate the sun position in local spherical coordinates.
105 @param S sun position input data object (set using above functions)
106 @param zenith zenith angle in radians (output)
107 @param azimuth azimuth angle in radians (output)
108 */
109 void SunPos_calc_zen_azi(SunPos *S, double *zenith, double *azimuth);
110
111 #endif /* SUNPOS_GRENA_H */
112

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