PRES22_0231.docx DOI: 10.3303/CET2294142 Paper Received: 15 April 2022; Revised: 15 June 2022; Accepted: 20 June 2022 Please cite this article as: Knolmajer A., Vathy-Fogarassy Á., Fodor A., 2022, Quaternion based solar irradiance forecast, Chemical Engineering Transactions, 94, 853-858 DOI:10.3303/CET2294142 CHEMICAL ENGINEERING TRANSACTIONS VOL. 94, 2022 A publication of The Italian Association of Chemical Engineering Online at www.cetjournal.it Guest Editors: Petar S. Varbanov, Yee Van Fan, Jiří J. Klemeš, Sandro Nižetić Copyright © 2022, AIDIC Servizi S.r.l. ISBN 978-88-95608-93-8; ISSN 2283-9216 Quaternion-Based Solar Irradiance Forecast Attila Knolmajera, Ágnes Vathy-Fogarassyb, Attila Fodora aUniversity of Pannonia, Department of Electrical Engineering and Information Systems, Hungary bUniversity of Pannonia, Department of Computer Science and Systems Technology, Hungary knolmajer.attila@virt.uni-pannon.hu This research proposes a new method based on quaternion rotations to calculate the expected irradiance from the Sun to a given surface. The method uses quaternion rotations and translation vectors to model the motions of objects, both proper and relative to each other, that are relevant for irradiance. Using quaternion rotations, objects can be rotated along arbitrary axes in their coordinate system while preserving the orientation of the base coordinate system, and the origin of the base coordinate systems can be rotated relative to each other so that the transition between them can be solved by simple translation vectors. An additional goal of the method is to be able to replace the equatorial coordinate system, which is currently widely used, and provide easy scalability to add additional quaternion rotation. The generated irradiance values were compared with data measured by a meteorological station during the validation process. In the case of clear skies, the comparison resulted in a high degree of correlation, which shows usually above 0.95 correlation factor, between the data. Based on the correlation, the generated expected irradiance data can be used as a reference for teaching neural networks that can discriminate weather-induced variations in the data measured by solar power inverters. As a result, it can increase the efficiency of fault detection algorithms that enable more stable energy production and indirectly reduce the necessity of fossil fuel use. 1. Introduction Countries around the world are increasingly focusing on the Earth's renewable energy resources to reduce greenhouse gas emissions. Much of this renewable energy use is also driven by the widespread deployment of solar energy. This technology has developed significantly over the decades, but further efficiency improvements can make the sector even more economical and help accelerate environmental efforts. To integrate renewables into the electricity grid, it is essential to forecast the energy produced as accurately as possible and ensure its stability. In most cases, the data series measured during the operation of a solar power plant can already predict the occurrence of failure events during its operation. Detecting these events before they occur can greatly contribute to more efficient operation, helping to reduce fossil fuel-based energy production. Since a key factor in fault detection is the identification of deviations from expectations, this work focuses on the generation of expected irradiance data, the availability of which will allow the development of even more efficient fault detection algorithms and aims to provide a scalable alternative to the equatorial coordinate system for a wide range of applications. Work on irradiance computation generally uses the equatorial coordinate system, which represents the celestial bodies seen by an observer on Earth on a spherical surface. For example, e.g. Yilmaz et al. (2015) use the equatorial coordinate system to determine irradiation data on the tilted surface. In this coordinate system, geometric relationships can be used to calculate the angle of incidence of the Sun, from which the amount of irradiance reaching the Earth's atmosphere can be determined. Iqbal (2012) provides a comprehensive overview of a solar geometry calculation. However, it ignores the effects of motions with longer time scales, such as the motion of the stars themselves, the precessional and nutational motions of the Earth, and the elliptical orbit and variable orbital velocity. The introduction of correction factors is required for instance the equation of time to improve the accuracy. In addition, the equatorial one can calculate irradiation data for one geolocation point during one calculation process. 853 The quaternion is a powerful and common tool to handle rotation as an alternative to Euler angles and rotation matrix. There are many works on its application or their 3D rotational properties in different fields. Nekoo et al. (2022) use it for regulation control problem in aerobatic flight to make a quaternion based dynamic model for controlling rotators of the quadrocopter. Klak and Jarzębowska (2021) also use quaternion in modeling of a space manipulator robots and describe dynamics and attitude with it to avoid Euler angles’ drawbacks. Conord and Peaucelle (2021) use quaternion for global attitude tracking and based on it build continuous nonlinear state feedback that reaches an almost global asymptotical stability. The method presented in this paper offers an alternative to the use of the equatorial coordinate system based on quaternion rotations that can account for slower changes over time and provides the possibility to calculate irradiance data reaching the surface of an object orbiting a planet since it is scalable and can be easily reparametrized using data derived from gravitational force laws. This method can solve the determination of irradiance data in more than one geolocation point in a parallel way and it is also capable of providing the data needed to train neural networks that enable more efficient fault detection in solar inverters by detecting the effects of weather factors. Section 2 introduces the basic concepts of quaternion and its useability for rotation. In Section 3 the developed model is presented the result of which is discussed and verified against the data of the meteorology station measured in Section 4. Finally, some concluding remarks are described. 2. Short introduction of quaternions Quaternions are non-commutative extensions of complex numbers to four dimensions. They can be used to perform 3-dimensional rotations, replacing the use of rotation matrices and fewer data storage is required. Quaternions can be formed from real numbers by assigning 𝐢𝐢, 𝐣𝐣, 𝐤𝐤 as basis vectors where 𝐢𝐢, 𝐣𝐣 and 𝐤𝐤 satisfy 𝒊𝒊𝟐𝟐 = 𝒌𝒌𝟐𝟐 = 𝒋𝒋𝟐𝟐 = 𝒊𝒊𝒋𝒋𝒌𝒌. Formally, they can be written as follows in Equation 1: 𝑞𝑞 = 𝑥𝑥0 + 𝑥𝑥1𝒊𝒊 + 𝑥𝑥2𝒋𝒋 + 𝑥𝑥3𝒌𝒌 , (1) where 𝑥𝑥0 ∈ ℝ is the real part coefficient and 𝑥𝑥1, 𝑥𝑥2, 𝑥𝑥3 ∈ 𝕀𝕀𝕀𝕀 are the imaginary part coefficient of the quaternion. If 𝐢𝐢, 𝐣𝐣, 𝐤𝐤 are introduced as orthonormal vectors for 𝑅𝑅3 and the coefficients of this vector 𝑥𝑥1, 𝑥𝑥2, 𝑥𝑥3 are viewed as a quaternion having only an imaginary part, then they can act on the vectors of 𝑅𝑅3 by operations on the quaternions, and there exists an operation on the set of quaternions that leaves the imaginary part of the other quaternions in place regarding 𝑅𝑅3. The solution is to multiply the calculated one by the unit quaternion q and its conjugate pair. If the quaternion is written in the following trigonometric form like in Equation 2: 𝑞𝑞 = cos(𝛼𝛼) + sin(𝛼𝛼) 𝐮𝐮 (2) then this can be interpreted geometrically as the rotation of a vector of coefficients 𝑥𝑥1, 𝑥𝑥2, 𝑥𝑥3 by an angle 2α around 𝐮𝐮 axis. More detailed information about quaternion is readable in the following articles. More detailed information about quaternion is readable in the following articles. Spring (1986) which makes a comparison between the use of quaternions and Euler angles for rotation and Mukundan (2002) provides a comprehensive overview of quaternion algebra. 3. Implement a quaternion-based model to calculate irradiance First of all, the determination of the used coordinate systems is needed. The strengths of applying quaternions are not necessary to handle complicated connections between coordinate systems because rotations, which describe a motion, omit rotating the coordinate systems themselves. The connections between coordinate systems are determined by using only a translation and a shift method. All used objects get an individual coordinate system anchored to their centre as can be seen in Figure 1. Figure 1: Sample representation of coordinate system assignment to an object 854 After defining the coordinate systems, the next step is to assign the movements used. It can be done in several ways regarding the choice of the main, i.e. reference, coordinate system. In this case, the objective is to calculate the annual irradiance data for a geolocation point on the Earth. It is appropriate to use the coordinate system fixed to the ecliptic plane as a reference in such a way that the z-axis will be perpendicular to it. The relationship between the Earth's axis and the Sun's axis cannot be described using congruence transformations, because the Earth has an axial tilt. It is known as inclination. The solution is to rotate the Earth's axis by a quaternion in its coordinate system. The angle of this rotation can be determined by calculating the angle of deviation from a line perpendicular to the plane of the orbit. This is currently 23.44° in the viewpoint of the Earth's axis. The rotated axis can be used to simulate the rotation of the Earth around its axis, which can also be done using a quaternion. Figure 2: (a) Earth's axis in the anchored coordinate system before applying quaternion rotation; (b) Earth's axis in the anchored coordinate system after applying quaternion rotation As can be observed in Figure 2b, the rotation applied has no effect on the basis vectors of the coordinate system defined in the first step, only the coordinates defining the axis have taken on a new value. To produce sufficiently accurate irradiance data, one more major influencing factor needs to be considered, which is the current orientation of the Earth's axis. The changing of the orientation is called the axial precession, which is caused by gravitational interactions between the Earth and the Sun, the Moon or the planets. It can be determined by a simple daily measurement containing information about the current time and inclination of the sun from the geolocation point. In another way, a well-defined astronomical event like Vernal Equinox can also be used to solve the mentioned problem. If the angle of rotation is available, the Earth's axis is rotated in the direction of the orientation in the coordinate system assigned to it. The tilt, orientation and motion of the Earth's axis relative to the orbital plane are influenced by a number of factors that are the result of gravitational interactions. Precession, wobble and nutation are just a few. In this paper, only the factors that have a major impact on the accuracy of the irradiance data calculated for 1 y have been considered. However, if necessary due to the scalability of the model, additional factors can be constructively added by additional quaternion rotations based on the above examples. Figure 3: After the Earth is positioned in the sufficient orientation with its axis tilt by two quaternions rotation If the rotation model has been created, the next step is to determine the direction and angle of the rotations representing the movements, taking into account the resolution to be used. Since the speed of the Earth's 855 rotation about its axis can be considered constant to a good approximation, the angle required to rotate the Earth in a unit of time is simply obtained using Equation 3. α = 360° 𝑇𝑇𝐸𝐸 (3) where 𝛼𝛼 is the rotation angle, 𝑇𝑇𝐸𝐸 is the periodicity of the Earth’s rotation around its axis. Calculating the angle of rotation around the Sun requires a much more complex operation. Because of the Earth’s elliptical orbit, it is necessary to take into account the varying angular velocity and use astronomical mechanics to provide a solution for the rotation angle. The following relations in Equation 4 and 5 summarize the relevant steps without comprehensive completeness. 𝑀𝑀 − 𝑀𝑀0 = 𝑛𝑛(𝑡𝑡 − 𝑡𝑡0) (4) where 𝑀𝑀 is the mean anomaly at time 𝑡𝑡 and 𝑛𝑛 is the mean motion or the average angular velocity. 𝑀𝑀 = 𝐸𝐸 − 𝑒𝑒 · sin(𝐸𝐸), (5) where 𝐸𝐸 is called the eccentric anomaly for elliptical orbits and 𝑒𝑒 is the eccentricity. Now the model has all the parameter values needed to calculate the angle of incidence of the Sun's rays. Because of the proportions between the Sun and the Earth, the rays of light can be seen as parallel vectors. The angle of incidence of the Sun can be calculated using simple geometric relations. Figure 4 shows the generated data for the GPS coordinates (N 47.094951°; E 17.9040280°) at 5 min resolution. The GPS coordinates refer to the area of the solar power plant in Veszprém, Hungary. Figure 4: Generated Incidence angle of the Sun Several additional factors need to be considered to calculate the irradiance data. The value for the average solar energy can be found in the literature, but for more accurate calculations a correction is needed because the distance between the Earth and the Sun is not the same at different points in the orbit, so the solar constant varies. This can be done using the following equations: E0 = � 𝑟𝑟0 𝑟𝑟 � 2 (6) where E0 is the square of the relative Sun-Earth distance. I𝑛𝑛 = I0 · E0 (7) where 𝐼𝐼0 is the solar constant defined in the literature, with a value of 1367 𝑊𝑊 𝑚𝑚2 . Another factor is the passage of sunlight through the atmosphere. The path of the sun through the atmosphere, the angle of incidence of the sun's rays and the composition of the atmosphere, including weather conditions, must be taken into account. These parameters play an important role in the calculation of irradiance and have a significant influence on the amount that reaches the surface. This is intuitively easy to see when considering 856 the following facts. A part of the Sun's rays reaches the surface of the Earth only as scattered radiation and the rest of it as direct radiation. They can be reflected again and again by the atmosphere. The global horizontal irradiance reaching the surface is determined in Equation 8 using the model proposed by Kasten (1984). The model has the advantage of considering geographic location and weather factors. Gℎ𝑜𝑜𝑜𝑜 = 𝐼𝐼𝑛𝑛 · sin(𝛼𝛼) · 𝐴𝐴𝑑𝑑 · 𝑒𝑒−𝐵𝐵𝑑𝑑𝑇𝑇𝑚𝑚𝑧𝑧 · (1 − 𝑎𝑎𝑑𝑑𝑁𝑁𝑏𝑏𝑑𝑑) (8) It is important to note that in the present research the aim is to produce irradiance data for the ideal case and the weather parameters have been set for clear sky, so that the Equation 8 is simplified to the form in Eq.(9): Gℎ𝑜𝑜𝑜𝑜 = 𝐼𝐼𝑛𝑛 · sin(𝛼𝛼) · 𝐴𝐴𝑑𝑑 · 𝑒𝑒−𝐵𝐵𝑑𝑑𝑇𝑇𝑚𝑚𝑧𝑧 (9) where Gℎ𝑜𝑜𝑜𝑜 is the Global irradiation on the surface, 𝐴𝐴𝑑𝑑, 𝐵𝐵𝑑𝑑 are local constant, 𝑧𝑧 is the relative distance travelled in the atmosphere of the Sun’s rays, 𝛼𝛼 is the inclination angle of the Sun and 𝑇𝑇𝑚𝑚 is the Linke turbidity factor. By applying the method proposed in this paper, the calculated ideal case irradiance data is shown in Figure 5. The validation of the data provided by the method is presented in the next section. Figure 5: Calculated Global irradiation data at the surface using the proposed method in the geolocation point of Veszprém, Hungary 4. Results and discussion The validation of the model was performed using the measured data from a meteorological station located at the GPS coordinate in Veszprém mentioned above. The data are from the year 2021 in 5 min increments. Using the model presented here, data were generated for a given year and also in 5 min increments. The comparison of the measured and model-generated irradiance data was performed for clear sky and the entire data set was used to determine the coincidence of sunrise and sunset times. Figure 6 shows the measured (blue) and generated (red) data. There is a significant correlation coefficient between the two data series which is observed by the Pearson correlation method. For the correlation study, measurements collected under approximately clear skies were used on a day-by-day basis. In this case, an average correlation of 0.9613 was measured on the data sets with a standard deviation of 0.1326. The difference between the measured and calculated data and the standard deviation of the correlation average is shaped by the combined effect of several factors. The factors that have the greatest influence on the difference in variance are the topography of the area surrounding the geolocation point, the shadows caused by smaller clouds passing over shorter time intervals and changes in the composition of the atmosphere. As the variations due to topography are only observed at sunrise and sunset and other factors have only negligible effects on the correlation coefficient between measured and estimated data, the proposed method is considered to be appropriate for the generation of the expected irradiance data. A comparison of the results obtained with the data obtained using the equatorial coordinate system for measurements from an annual interval does not show any appreciable difference, since the aforementioned factors have a greater impact on the accuracy of the results than the application of the two methods. For a meaningful comparison, further data collection with higher resolution is required. In terms of computational demand, however, the proposed method can provide irradiance data at several geolocation points simultaneously without recalculation and is more widely applicable than the equatorial coordinate system. 857 Figure 6: (a) Measured and generated data in March; (b) Measured and generated data in August Conclusion The calculation of irradiance data is important to operate solar power plants as efficiently as possible. In this paper, a new method, which is based on quaternion rotations, is developed that offers the possibility to replace the equatorial coordinate system that is commonly used. A big advantage of the method is its flexibility and scalability, which allows the addition of more factors that influence the Earth's motion, such as the nutation effect of the Moon if it is necessary and it can be easily applied to any object orbiting in the solar system. Since the calculated irradiance is generated in each step by a unique rotation that is independent of the others, the method can also be run on GPUs for faster computation. It can also be used to compute the irradiance data of several geolocation points simultaneously. During validation, the model-generated data were compared with data from a weather station, which showed an average correlation of 0.9613 for approximately clear skies. As for further work and usability, the applied weather model, presented at the end of Section 4, makes the method suitable to provide forecasts in the case of unclear skies also. The difference between the expected and measured values as deviation data are satisfactory to train a fault detection neural network for solar PV systems in cases where several years of incomplete time-series data are available because it contains seasonal trends. Acknowledgements Attila Knolmajer was supported by the MEC_R_21 Mecenatura program of the Ministry for Innovation and Technology. References Conord T., Peaucelle D., 2021. Continuous quaternion based almost global attitude tracking. IEEE Conference on Control Technology and Applications 2021 (CCTA), 487-492, DOI: 10.1109/CCTA48906.2021.9659160. Iqbal M., 2012. An introduction to solar radiation, Academic Press - Elsevier, New York, United States, ISBN: 9780323151818. Kasten F., 1984. Parameterization of the global radiation by degree of coverage and turbidity factor, Annalen der Meteorologie Neue, 20, 49-50. (in German) Spring K.W., 1986. Euler parameters and the use of quaternion algebra in the manipulation of finite rotations: a review. Mechanism and Machine Theory, 21(5), 365-373. Kłak M., Jarzębowska E., 2021. Quaternion-based constrained dynamics modeling of a space manipulator with flexible arms for servicing tasks. Journal of Vibration Engineering & Technologies, 9(3), 381-387. Mukundan R., 2002. Quaternions: From classical mechanics to computer graphics, and beyond, Proceedings of the 7th Asian Technology Conference in Mathematics, 97-105, <citeseerx.ist.psu.edu/viewdoc/summary?doi=10.1.1.106.7361>, accessed 20/06/2022. Nekoo S.R., Acosta J.Á., Ollero A., 2022. Quaternion-based state-dependent differential Riccati equation for quadrotor drones: Regulation control problem in aerobatic flight. Robotica, 1-16. Yilmaz S., Ozcalik H.R., Dogmus O., Dincer F., Akgol O., Karaaslan M., 2015. Design of two axes sun tracking controller with analytically solar radiation calculations. Renewable and Sustainable Energy Reviews, 43, 997-1005. 858 PRES22_0291.pdf Quaternion-Based Solar Irradiance Forecast