Calculation of sun position: Difference between revisions

From ASCEND
Jump to navigation Jump to search
Line 47: Line 47:
== Grena algorithm ==
== Grena algorithm ==


Code to implement the Grena algorithm 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.</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).


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}}.
This new approach will become available in ASCEND distributions starting June 2011.


== References ==
== References ==

Revision as of 05:22, 11 April 2012

This page describes two different approaches to calculation of sun position that are possible using ASCEND. The first is a pure-ASCEND implementation of the algorithm from the book by Duffie & Beckman. The second is a C-code function implementation of the Roberto Grena algorithm, provided for use in ASCEND as an external relation.

Duffie & Beckman algorithm

The ASCEND model library contains a file models/johnpye/sunpos.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.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.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::specify;
    FREE t;

    FIX t_solar;
END specify;
METHOD values;
    RUN sunpos::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;

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 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).

A sample model showing use of the Grena algorithm is models/johnpye/grena/sunpos_test.a4c.

References

  1. Duffie & Beckman, (2006) Solar Engineering of Thermal Processes, Wiley.
  2. R Grena, 2007. An algorithm for the computation of the solar position. Solar Energy 82, 462-470.

See also

  • The PSA sun position code by Blanco-Muriel et al from Plataforma Solar de Almería, accurate to ±0.0083° for years 1999 to 2015, is more accurate than the Duffie & Beckman method described above. See this paper.
  • The Grena algorithm is more accurate again, accurate to ±0.0027° in the year range 2003 to 2023.
  • The NREL Solar Position Algorithm by Reda & Andreas, 2004, accurate to ±0.003° over the year range -2000 to 6000 AD.