Calculation of sun position: Difference between revisions
| (22 intermediate revisions by the same user not shown) | |||
| Line 1: | Line 1: | ||
This page describes | This page describes several different approaches to calculation of sun position that are available using ASCEND. The first is a pure-ASCEND implementation of the algorithm from the book by Duffie & Beckman. Several other more accurate sun position algorithms such as the Grena algorithm are described further on, and work is underway to implement these algorithms as [[external relations]] and to tie them to our [[data reader]] for weather data. | ||
== Duffie & Beckman algorithm == | == Duffie & Beckman algorithm == | ||
The ASCEND [[ModelLibrary|model library]] contains a file {{src|models/johnpye/ | The ASCEND [[ModelLibrary|model library]] contains a file {{src|models/johnpye/sunpos_db.a4c}} that can be loaded in ASCEND and used to calculate the position of the sun at any location on earth and at any time of day or day of the year. It uses the method of Duffie and Beckman<ref>Duffie & Beckman, (2006) ''Solar Engineering of Thermal Processes'', Wiley.</ref>, which is accurate to the extent required for solar thermal energy calculations, but probably unsuitable for use in astronomy. Some more recent and more accurate correlations are given in the links at the bottom of this page. | ||
The following is a code snippet, taken from the {{src|models/johnpye/ | The following is a code snippet, taken from the {{src|models/johnpye/sunpos_db.a4c}} file, that solves Example 1.6.1 from that book. It can be run and solved using [[Main_Page|ASCEND]] with the command <tt>ascend johnpye/sunpos_db.a4c</tt>. | ||
<source lang="a4c">(* | <source lang="a4c">(* | ||
For Madison (Wisconsin), calculate the angle of incidence of beam radiation | For Madison (Wisconsin), calculate the angle of incidence of beam radiation | ||
on a surface at 10:30 AM solar time on February 13, if the surface is | on a surface at 10:30 AM solar time on February 13, if the surface is | ||
tilted 45 from the horizontal and pointed 15 degrees west of south. | tilted 45 from the horizontal and pointed 15 degrees west of south. | ||
| Line 17: | Line 16: | ||
METHOD specify; | METHOD specify; | ||
RUN | RUN sunpos_db::specify; | ||
FREE t; | FREE t; | ||
FIX t_solar; | FIX t_solar; | ||
END specify; | END specify; | ||
METHOD values; | METHOD values; | ||
RUN | RUN sunpos_db::values; | ||
t_solar := 43{d} + 10{h} + 30{min}; | t_solar := 43{d} + 10{h} + 30{min}; | ||
beta := 45 {deg}; | beta := 45 {deg}; | ||
gamma := 15 {deg}; | gamma := 15 {deg}; | ||
L_st := -90{deg}; (* USA Central time*) | L_st := -90{deg}; (* USA Central time*) | ||
L_loc := -89.4{deg}; | L_loc := -89.4{deg}; | ||
phi := +43{deg}; | phi := +43{deg}; | ||
END values; | END values; | ||
METHOD self_test; | METHOD self_test; | ||
ASSERT abs(theta-35.0{deg}) < 0.15{deg}; | ASSERT abs(theta-35.0{deg}) < 0.15{deg}; | ||
ASSERT abs(delta-(-13.80{deg})) < 0.02{deg}; | ASSERT abs(delta-(-13.80{deg})) < 0.02{deg}; | ||
END self_test; | END self_test; | ||
END example_1_6_1;</source> | |||
Note that Duffie & Beckman define solar azimuth <math>\gamma_s</math> (<tt>gamma_s</tt> in our model) as measured westward from south (i.e., 0°=south, 90°=west, -90°=east). | |||
It is intended that this sun position calculation would be linked together with the experimental [[Data reader]] component to allow solar energy engineering problems to be solved over the course of days, weeks or years, along the lines of the [[Other_modelling_tools|TRNSYS]] simulation tool. | It is intended that this sun position calculation would be linked together with the experimental [[Data reader]] component to allow solar energy engineering problems to be solved over the course of days, weeks or years, along the lines of the [[Other_modelling_tools|TRNSYS]] simulation tool. | ||
| Line 47: | Line 41: | ||
== Grena algorithm == | == Grena algorithm == | ||
Code to implement the Grena algorithm<ref>R Grena, 2007. An algorithm for the computation of the solar position, ''Solar Energy'' '''82''', 462-470. {{doi|10.1016/j.solener.2007.10.001}}</ref> is given in {{srcdir|models/johnpye/grena}}. This algorithm is most accurate in the range 2003-2023, although it will return results for a much wider range of dates. Be particularly careful if using it for dates before 2000, as it will make leap-day errors (we could easily modify Grena's code to correct that but as yet have not done so). | Code to implement the Grena algorithm<ref>R Grena, 2007. An algorithm for the computation of the solar position, ''Solar Energy'' '''82''', 462-470. {{doi|10.1016/j.solener.2007.10.001}}</ref> is given in {{srcdir|models/johnpye/grena}}. This algorithm is most accurate (±0.0027°) in the range 2003-2023, although it will return results for a much wider range of dates. Be particularly careful if using it for dates before 2000, as it will make leap-day errors (we could easily modify Grena's code to correct that but as yet have not done so). | ||
Grena defines solar azimuth <math>\Gamma</math> as measured westward from south. | |||
A sample model showing use of the Grena algorithm is {{src|models/johnpye/grena/sunpos_test.a4c}}. | A sample model showing use of the Grena algorithm is {{src|models/johnpye/grena/sunpos_test.a4c}}. | ||
| Line 53: | Line 49: | ||
== NREL Sun Position Algorithm == | == NREL Sun Position Algorithm == | ||
The NREL | [[Image:Greenwich-analemma.png|thumb|250px|Solar [http://en.wikipedia.org/wiki/Analemma analemma] at Greenwich, calculated using the [[study]] function with the model {{src|models/johnpye/nrel/sunpos_nrel.a4c}} calculated every noon in the year 2000.]]The NREL sun position code of Reda & Andreas<ref>I Reda and A Andreas, 2008. ''Solar Position Algorithm for Solar Radiation Applications (Revised)'', National Renewable Energy Laboratory, Golden, Colorado, USA. Technical report NREL/TP-560-34302. {{doi|10.2172/15003974}}.</ref> is an implementation of an algorithm by Meeus<ref>J Meeus, 1999. ''Astronomical Algorithms'' (2nd Ed), Willmann-Bell, Virginia, USA. ISBN 0943396352</ref> and calculates accurate sun azimuth and zenith angles from 2000 BC to AD 6000, with claimed accuracy of ±0.0003° for that period. It makes use of atmospheric pressure, temperature and elevation to aid in accurate calculation including atmospheric refraction effects. It is more computationally expensive than other other (Grena, Duffie & Beckman) approaches (but not particularly expensive in comparison with calculation of accurate thermodynamic properties). | ||
Connection of the NREL SPA to ASCEND is in progress. The code is at {{srcdir|models/johnpye/nrel}}. | |||
Reda and Andreas define solar azimuth <math>\Gamma</math> ('topocentric astronomers azimuth angle') as measured westward from south. Note that they also define the 'topocentric azimuth angle' <math>\Phi</math> as measured eastward from north, but since this conflicts with both Grena and Duffie & Beckman, we will adopt the <math>\Gamma</math> measure. | |||
== PSA sun position code == | |||
The sun position [http://www.psa.es/sdg/sunpos.htm code] from the Plataforma Solar de Almería (PSA) by Blanco et al<ref>M Blanco Muriel, D C Alarcón Padilla, T López Moratalla and M Lara Coira, 2001. Computing the solar vector, ''Solar Energy'' '''70''', 431-441. {{doi|10.1016/S0038-092X(00)00156-0}}</ref> is accurate to ±0.0083° for years 1999 to 2015. | |||
< | |||
There are Python bindings to the PSA sun position code via the package [https://pypi.python.org/pypi/sunpos/1.1 sunpos] available from PyPI. Install it using <tt>pip install sunpos</tt>. | |||
We have not yet implemented the PSA code in ASCEND, but plan to do so for comparison purposes. | |||
== References == | |||
<references/> | |||
[[Category:Examples]] | [[Category:Examples]] | ||
[[Category:Documentation]] | [[Category:Documentation]] | ||
[[Category:Energy systems]] | [[Category:Energy systems]] | ||
Latest revision as of 06:29, 6 March 2018
This page describes several different approaches to calculation of sun position that are available using ASCEND. The first is a pure-ASCEND implementation of the algorithm from the book by Duffie & Beckman. Several other more accurate sun position algorithms such as the Grena algorithm are described further on, and work is underway to implement these algorithms as external relations and to tie them to our data reader for weather data.
Duffie & Beckman algorithm
The ASCEND model library contains a file models/johnpye/sunpos_db.a4c that can be loaded in ASCEND and used to calculate the position of the sun at any location on earth and at any time of day or day of the year. It uses the method of Duffie and Beckman[1], which is accurate to the extent required for solar thermal energy calculations, but probably unsuitable for use in astronomy. Some more recent and more accurate correlations are given in the links at the bottom of this page.
The following is a code snippet, taken from the models/johnpye/sunpos_db.a4c file, that solves Example 1.6.1 from that book. It can be run and solved using ASCEND with the command ascend johnpye/sunpos_db.a4c.
(* For Madison (Wisconsin), calculate the angle of incidence of beam radiation on a surface at 10:30 AM solar time on February 13, if the surface is tilted 45 from the horizontal and pointed 15 degrees west of south. *) MODEL example_1_6_1 REFINES sunpos; METHODS METHOD specify; RUN sunpos_db::specify; FREE t; FIX t_solar; END specify; METHOD values; RUN sunpos_db::values; t_solar := 43{d} + 10{h} + 30{min}; beta := 45 {deg}; gamma := 15 {deg}; L_st := -90{deg}; (* USA Central time*) L_loc := -89.4{deg}; phi := +43{deg}; END values; METHOD self_test; ASSERT abs(theta-35.0{deg}) < 0.15{deg}; ASSERT abs(delta-(-13.80{deg})) < 0.02{deg}; END self_test; END example_1_6_1;
Note that Duffie & Beckman define solar azimuth <math>\gamma_s</math> (gamma_s in our model) as measured westward from south (i.e., 0°=south, 90°=west, -90°=east).
It is intended that this sun position calculation would be linked together with the experimental Data reader component to allow solar energy engineering problems to be solved over the course of days, weeks or years, along the lines of the TRNSYS simulation tool.
Grena algorithm
Code to implement the Grena algorithm[2] is given in models/johnpye/grena. This algorithm is most accurate (±0.0027°) in the range 2003-2023, although it will return results for a much wider range of dates. Be particularly careful if using it for dates before 2000, as it will make leap-day errors (we could easily modify Grena's code to correct that but as yet have not done so).
Grena defines solar azimuth <math>\Gamma</math> as measured westward from south.
A sample model showing use of the Grena algorithm is models/johnpye/grena/sunpos_test.a4c.
NREL Sun Position Algorithm
The NREL sun position code of Reda & Andreas[3] is an implementation of an algorithm by Meeus[4] and calculates accurate sun azimuth and zenith angles from 2000 BC to AD 6000, with claimed accuracy of ±0.0003° for that period. It makes use of atmospheric pressure, temperature and elevation to aid in accurate calculation including atmospheric refraction effects. It is more computationally expensive than other other (Grena, Duffie & Beckman) approaches (but not particularly expensive in comparison with calculation of accurate thermodynamic properties).
Connection of the NREL SPA to ASCEND is in progress. The code is at models/johnpye/nrel.
Reda and Andreas define solar azimuth <math>\Gamma</math> ('topocentric astronomers azimuth angle') as measured westward from south. Note that they also define the 'topocentric azimuth angle' <math>\Phi</math> as measured eastward from north, but since this conflicts with both Grena and Duffie & Beckman, we will adopt the <math>\Gamma</math> measure.
PSA sun position code
The sun position code from the Plataforma Solar de Almería (PSA) by Blanco et al[5] is accurate to ±0.0083° for years 1999 to 2015.
There are Python bindings to the PSA sun position code via the package sunpos available from PyPI. Install it using pip install sunpos.
We have not yet implemented the PSA code in ASCEND, but plan to do so for comparison purposes.
References
- ↑ Duffie & Beckman, (2006) Solar Engineering of Thermal Processes, Wiley.
- ↑ R Grena, 2007. An algorithm for the computation of the solar position, Solar Energy 82, 462-470. doi:10.1016/j.solener.2007.10.001
- ↑ I Reda and A Andreas, 2008. Solar Position Algorithm for Solar Radiation Applications (Revised), National Renewable Energy Laboratory, Golden, Colorado, USA. Technical report NREL/TP-560-34302. doi:10.2172/15003974.
- ↑ J Meeus, 1999. Astronomical Algorithms (2nd Ed), Willmann-Bell, Virginia, USA. ISBN 0943396352
- ↑ M Blanco Muriel, D C Alarcón Padilla, T López Moratalla and M Lara Coira, 2001. Computing the solar vector, Solar Energy 70, 431-441. doi:10.1016/S0038-092X(00)00156-0