SolTrack home page
SolTrack is a free, fast and accurate C/C++, Python and Arduino routine to compute the position of the Sun. In addition, SolTrack computes
rise and set times and azimuths, and transit times and altitudes.
The code can be used to track the Sun on a low-specs machine, such as a microcontroller or PLC, and can be used for e.g.
(highly) concentrated (photovoltaic) solar power or accurate solar-energy modelling.
SolTrack has been developed by Marc van der Sluys,
Paul van Kan and Jurgen Reintjes, at the
Lectorate of Sustainable Energy
at the HAN University of Applied Sciences
in Arnhem, the Netherlands.
The code is based on the astronomical Fortran library
libTheSky
and can be used, modified and distributed under the conditions of version 3 of the
GNU Lesser General Public Licence.
Description, speed and accuracy
A detailed description of SolTrack can be found in
Van der Sluys & Van Kan (2022) (open access).
SolTrack is a simple C/C++, Python and Arduino routine that can compute the position of the Sun in topocentric
coordinates, both in a horizontal
and in an equatorial
system. The code is based on the Fortran library libTheSky
and includes corrections for aberration
and parallax, and a
simple routine
to correct for atmospheric refraction,
taking into account local atmospheric conditions.
We compared the performance of SolTrack to detailed calculations using the planetary theories
VSOP 87
and an accurate model for atmospheric refraction.
We tested SolTrack for 100,000 random moments in the next 100 years (between 2017 and 2116) when
the Sun is above the horizon in the Netherlands (latitude ∼52°N). We find that the mean
error in position is 0.0030 ± 0.0016°, which is sufficient for solar tracking of CPV
systems under all conditions. The C/C++ code can compute ten million positions in 6.47 ± 0.03s
on a single 2.67 GHz CPU core when only horizontal coordinates (azimuth and altitude) are
computed, and takes 8.16 ± 0.02s (26% slower) if refraction-corrected parallactic coordinates
are also calculated. The Python version does around 12340 position calculations per second on a
single 3.6 GHz laptop core. The Arduino version has been adapted to 32-bit systems and can
perform about 95 calculations per second on an Arduino UNO. In addition to positions, SolTrack
can also compute the distance to the Sun, its rise, transit and set times, and its rise and set
azimuth and transit altitude.
When compared to the PSA SunPos routine, which is
also light-weight and freely available, SolTrack is 24 times more accurate (0.073°) and 2%
faster. When computing additional refraction-corrected equatorial coordinates, SolTrack is 23%
slower than SunPos. We also compared the performance of SolTrack to the
NREL SPA routine, which is more elaborate and
has a more restricted licence. SPA is 24% more accurate than SolTrack (0.0023°),
but also 20 times slower, where we computed only the Sun's position in SPA (not its rise and set times or
incident radiation) and included the additional refraction-corrected equatorial coordinates in SolTrack.
A paper describing more details is forthcoming.
C/C++ version
Code download and documentation
Installing SolTrack
The C/C++ SolTrack tarball contains CMake installer files for (semi)automatic compilation and
installation of the shared (and if desired static) library. See doc/INSTALL for more information.
SolTrack has
an ebuild
for easy installation in Gentoo Linux and has been included in Arch
Linux's AUR. Binary packages
(.deb and
.rpm) are available for e.g. Debian, (*)Ubuntu,
Red Hat, Fedora, CentOS, Scientific Linux, SUSE and many others.
Examples
The examples/ directory lists two example C/C++ programs that can be linked against the SolTrack
library, and which compute either data for a single instance, or read dates from a file and
compute the corresponding positions. Example output is provided to verify the results.
Release history
- 2017-09-09: v2.2 released: bugfix; minor updates
- 2017-04-15: v2.1 released: added rise and set times and positions
- 2017-02-22: v2.0 released: updated licence; faster and more accurate code;
added optional use of degrees, N=0 and distance computation
- 2015-04-11: v1.1 released: added second implementation test
- 2014-11-10: v1.0 released: first stable release of C/C++ code
Python version
Installing SolTrack
SolTrack is available in PyPi, and can be installed using
pip install soltrack .
Code examples
A simple but complete example Python script using SolTrack can be found at the
PyPi
and GitHub pages. Note that the
Python source code now has a
separate GitHub repository.
Release history
- 2020-03-21: v0.1.2 released: minor updates
- 2020-11-15: v0.1.1 released: minor updates
- 2020-11-15: v0.1.0 released: OOP version
- 2020-03-21: v0.0.2 released: bugfix, add datetime2st()
- 2019-11-03: v0.0.1 released: initial Python code
Arduino version
SolTrack is available for download from GitHub.
SolTrack.ino and SolTrack.h contain the algorithm, and example.ino
and example.h example code to illustrate the usage.
Release history
- 2021-03-18: v1.0 released: initial Arduino code
SolTrack has been used by:
Contact
You can contact the authors (preferably through email) via this page.
|