1 Introduction

Greenhouses are structures used for growing plants in controlled environments. They are commonly built with transparent materials like glass, polycarbonate, or plastic film to enable sunlight to enter and provide the essential energy required for plant growth (Kim et al 2022). However, this also means greenhouses can experience shading from nearby structures, trees, or even the greenhouse structure itself.

As the main source of energy for greenhouses, solar radiation is essential. Utilizing natural heat sources like the Sun is crucial for greenhouse operations since heating costs make up a sizeable share (30 to 70%) of total production costs, especially during frigid winter months (Sun et al 2022). However, in regions such as Greece, where temperatures tend to rise significantly for extended periods, often spanning from May to October, the temperature inside the greenhouse can exceed 60\(^\circ \) C, leading to severe issues for the crops. To address this problem, various methods have been developed to lower the temperature, including the deployment of nets and screens, which help create an appropriate microclimate inside the greenhouse, especially during the summer season (Kitta and Katsoulas 2020). The shadowing of the crop and the greenhouse area, in general, is utilized as a tool in most approaches used to cool a greenhouse in the summer. More specifically, in Ahemd et al (2016), it is stated that combining a shading and a cooling method of the greenhouse can create a temperature difference of 5–10 \(^\circ \) C between the indoors and outdoors, with respect to a greenhouse in which only a cooling system is applied. The reduction in temperature due to shading can in some cases lead to a reduction in ventilation requirements. Besides reducing the temperature, shading presents other important benefits for the crop. These benefits are related to the increase in the quality and quantity of production, the decrease of disease and pest activity, the better management of natural resources such as water, due to the lower evaporation under the shade, while at the same time, the reduced evaporation leads to the better assimilation of CO2, due to the increased stomatal resistance (Angmo et al 2021).

Aside from the conventional means of shading the greenhouse, one approach that is employed and is still of scientific interest is the integration of photovoltaics (PVs) into the greenhouse’s roof. Solar radiation, on the one hand, is the most crucial element for achieving a satisfactory production practice, since photosynthesis is a biological process that relies heavily on sunlight. On the other hand, an energy production system using solar radiation such as a photovoltaic system is essentially based on the intensity of the radiation incident on the system. The necessity for both cultivation and a photovoltaic system in sunlight adds value to greenhouses, which are installed in areas without, or with reduced existence of obstacles. Simultaneously, due to increased demand for accessible land, substantial difficulties are addressed, both spatially and economically. Hence, utilizing the same plot of land for both food and energy production emerges as an ideal solution (Hassanien and Li 2017; Yano and Cossu 2019). Semi-transparent photovoltaic (PV) panels can provide shade for crops without negatively affecting their biological requirements. More specifically, the necessary for plants’ photosynthesis (Liu and van Iersel 2021), requires solar radiation within the 400–700 nm range of the spectrum (Roxani et al 2023; Jin et al 2023). At the same time, as indicated in Dean et al (2014), exposure to a specific spectrum range, such as to UV-B, can have severe impacts on the plant’s DNA, adversely altering the plant’s structure and development. Finally, excessive solar radiation has a deleterious impact on transpiration and blooming, in addition to photosynthesis.

The PV shading feature could offer numerous benefits for both the crops and the microclimate. These panels can be installed on the roof (Waller et al 2022) or the walls (Aira et al 2021) of the greenhouse, allowing most of the impacting sunlight to penetrate while simultaneously generating electricity. Moreover, researchers have conducted experiments to modify shading by rotating the photovoltaics on the greenhouse roof, considering how shading affects plants differently throughout various growing seasons (Moretti and Marucci 2019).

Numerous studies have investigated the effects of semi-transparent PV panels on light transmission and plant growth in greenhouse environments. These investigations have revealed that shading affects different plant species in distinct ways. Following a thorough literature review, we found that research focused on tomatoes (Ezzaeri et al 2020; Barron-Gafford et al 2019), lettuce (Kavga et al 2018), strawberries (Tang et al 2020; Blando et al 2018), potatoes (Trommsdorff et al 2021), and more, have demonstrated varying outcomes. In a specific study (Cossu et al 2020), it was observed that plants like tomatoes and cucumbers experienced reduced yields when subjected to shading from photovoltaic panels with a coverage rate of 25% or more. Conversely, low-light crops exhibited the potential to thrive under conditions with up to 60% coverage of the greenhouse roof by photovoltaics. Additionally, another study (López-Díaz et al 2020) explored the impact of different shading levels (0%, 15%, 30%, and 50% PV cover-age rates) on tomato cultivation in a North-South-oriented greenhouse, focusing on radiation propagation and overall production performance. The results indicated that as the percentage of PV coverage increased, resulting in reduced radiation levels, both the yield and fruit quality were negatively affected. Furthermore, the distribution of light within the greenhouse was investigated in a separate study (Cossu et al 2018). This research considered three key factors: the percentage of roof coverage by photovoltaic panels, the height and orientation of the greenhouse, and the arrangement of the panels. The findings revealed that a North–South orientation of the greenhouse, along with a chessboard arrangement of the photovoltaic panels promoted uniformity in light distribution inside the greenhouse.

Semi-transparent PV panels offer a potential solution for shading in green-houses with the benefits of either reducing the temperature to avoid overheating especially in the summer months (reducing the temperature by 1\(^\circ \)C to 3\(^\circ \)C (Hassanien et al 2018) or increasing the yield of certain crops that benefit from low lighting, while at the same time providing energy production. However, the presence of these panels can also lead to reduced light transmission and negative effects on plant growth. Algorithms for modeling shading and optimizing panel placement, as well as algorithms for calculating light distribution, can help address these issues and maximize the benefits of semi-transparent PV panels in greenhouses and potentially selection of proper plant species for cultivation.

Shadow modeling algorithms are critical in predicting the performance of semi-transparent PVs in greenhouses. Accurate predictions of shading patterns can help optimize PV array positioning and orientation, allowing for maximum light exposure to the crops. Additionally, these algorithms can provide insight into the effects of shading on different crop species and growth stages, aiding in decision-making for greenhouse management.

There are several diverse types of shadow modeling algorithms, including analytical, numerical, and hybrid approaches. Analytical methods use mathematical equations, based on trigonometry, vector analysis (Arias-Rosales and LeDuc 2022), and linear algebra to calculate the amount of shadow cast on a PV array or greenhouse (Fernández-Ahumada et al 2020), while numerical methods (Salgado-Conrado et al 2022) use simulations and computational models to predict shadow patterns and intensity. Hybrid methods combine analytical and numerical methods to provide accurate and efficient shadow modeling.

The main algorithms used to model shading effects from semi-transparent PVs in greenhouses are:

  1. 1.

    Ray-tracing algorithms: These algorithms are based on simulating the behavior of light rays and their interactions with the surfaces of the greenhouse and PV panels. They can provide accurate predictions of the shading effects under different conditions (Shin et al 2021; Isied et al 2022).

  2. 2.

    Finite Element Method (FEM) algorithms: Finite Element Method (FEM) algorithms: FEM is a numerical method used to solve differential equations. In the case of PV greenhouses, FEM algorithms can be used to model the interaction between light and the greenhouse structure, including the semi-transparent PV panels (Baxevanou et al 2020; Ma et al 2019; Carlini et al 2020).

  3. 3.

    Shadow modeling algorithms: These algorithms are based on calculating the solar position in the sky for any given instant to obtain the shadow projection for any object point. They use a rasterization process to evaluate the shadowed area of the array and can provide shading patterns for a desired range of time (de Sá et al 2022; Waller et al 2021).

  4. 4.

    Light distribution algorithms: These algorithms are used to estimate the cumulated global radiation inside PV greenhouses at a desired time interval. They calculate the direct and scatter radiation on several observation points inside the PV greenhouse and can provide maps of the light distribution on different canopy heights (Cossu et al 2017; Hemming et al 2019).

These algorithms have different strengths and weaknesses and can be applied to several types of PV greenhouses depending on the specific requirements of the project.

Several studies have proposed algorithms to estimate the shading effect of PV panels on crops inside greenhouses. In de Sá et al (2022), a shadow modeling algorithm based on the calculation of solar position in the sky and a rasterization process to evaluate the shadowed area of the PV array is proposed. The algorithm can provide shading patterns for a desired range of time and calculate the efficiency rate of the irradiation power incident on the array in comparison with the non-shadowed case. The algorithm has interesting applications, such as optimizing array positioning and orientation, evaluating the impact of new obstructions on pre-existing array installations, allowing precise and practical data for control strategies and MPPT techniques for partially shaded systems, calculating more realistically constrained payback scenarios and finding the optimal PV array interconnection.

Table 1 Calendar basis and geographical criteria in the algorithm

In Cossu et al (2017), an algorithm to estimate the cumulated global radiation inside PV greenhouses at the desired time interval has been developed. The algorithm considers the direct and scatter radiation on several observation points inside the PV greenhouse and the PV panels are assimilated to polygons that can overlap the sun path seen from a specific observation point. The algorithm was tested in a greenhouse with a 50% PV cover ratio on the roof, and the results were used to draw maps of the light distribution on different canopy heights. The algorithm may provide a decision support tool for the identification of the most suitable plant species based on their light requirements.

In this study, an algorithm developed to calculate the shaded area of the greenhouse by photovoltaics is presented. The algorithm was based on an already existing installation of a photovoltaic system in a greenhouse, with the margin to be extended to different units. Graphical representations that the algorithm outputs in parallel can be used to make the results easier to understand.

Despite the fact that models have already been developed to find shading from various objects, as well as to study the radiation distribution inside a greenhouse and under the influence of photovoltaic panels, there is a gap in the literature regarding modeling in detail the shaded area inside a greenhouse due to photovoltaics. The calculation and visualization of the shaded area for even-span-type greenhouses and Agri-PVs of any size is an important tool for producers and users of such systems, while the combination of this algorithm with existing models can lead to the complete recording of shading from photovoltaic modules in greenhouses. At the same time, using the algorithm before installing photovoltaics, or even before building the full greenhouse unit, would provide another benefit to customers by generating the ideal circumstances for the intended cultivation. Finally, the endeavor to provide simple and unambiguous results allows the method to be utilized by anybody, without the requirement for extra knowledge on scientific frameworks relating to radiation and its propagation, or the geometry of related systems.

2 Materials and methods

In this study, an algorithm, based on which it is possible to estimate the total shading caused by photovoltaic modules placed on the roof of an even-span greenhouse is presented. The algorithm is essentially a parent function, consisting of five nested functions, as well as four parts of individual commands for the number and position of photovoltaics on the roof. The final extracted results of the algorithm concern the calculation of the shaded surface by the photovoltaics within the desired construction unit of the greenhouse, the percentage of shading on the total surface of the construction unit, as well as two graphs, the first with the 3D visualization of the greenhouse, the photovoltaics and of the formed shadow in a Cartesian coordinate system and the second with the top view of all of the above in a 2D Cartesian coordinate system. The estimation of the shadow may be done up to a time step, t, equal to 10 min at any time of year, with the algorithm incorporating criteria that prohibit it from operating for intermediate time intervals or circumstances where it does not exist on a calendar basis, but also geographically. The above criteria are presented in Table 1. All the procedures used for the functions are outlined below, along with the functions as they were implemented using the MATLAB programming language.

The nested functions implemented, concern the Sun’s position, as it can be calculated in a spherical coordinate system (Function 1), the distance between the Earth and the Sun (Function 2), the results of which are used to transform the Sun’s position from spherical to Cartesian coordinates (Function 3). Then, the coordinates of the points that form the greenhouse are found in a Cartesian coordinate system (Function 4) based on greenhouse basic characteristics, such as the number of construction units, which are repeated either widthwise or lengthwise, the length of the construction unit, its width, the gutter, and ridge height. The last nested function created and used is finding the shadow formed by the photovoltaics (Function 5).

The individual parts of the algorithm implemented concern the coordinates of the points that correspond to the four corners of each photovoltaic unit, depending on their position on the roof of the greenhouse, both for the first and the second unit in which they have placed the photovoltaics (Part 1), the binary representation of the surface covered by the greenhouse, and the greenhouse’s ground surface shaded by the photovoltaics (Part 2), and the calculation of the shaded area within the arable area of the greenhouse (Part 3). Finally, a part of the code has been implemented, which has the ability to extract results regarding whether a point is inside or outside the shading of the photovoltaics for the given time (Part 4). This part of the code works optionally, depending on whether or not input values are entered in the algorithm. The flowchart below presents the order in which Functions and Parts appear in the algorithm.

figure a
Fig. 1
figure 1

Photovoltaic modules integrated into the south-sloped level of the roof of the greenhouse: a Greenhouse construction unit available for cultivation b Greenhouse construction unit next to the first

Although Functions 4 and 5 can be used for any case of a greenhouse and the location of photovoltaics on its roof, their use in this research concerns a specific case of a greenhouse and photovoltaics. The greenhouse used in the research is located on the premises of the Plant Physiology Laboratory of the Department of Biology of the University of Patras. (38\(^\circ \) 17’ 27,9” N, 21\(^\circ \) 47’ 23,9” E). It is a real-scale, even-span greenhouse with an East-West ridge. The East–West orientation of the greenhouse is intended to be physically identical to that of productive greenhouses. The greenhouse consists of four different units, of which only two are considered in this work, the unit north of the greenhouse (northern construction unit) and the unit next to it (southern construction unit). The northern construction unit is also one available for cultivation. On the south-sloped level of the roof of each unit and at an angle of \(\sim \)24\(^\circ \), which is the same as the angle of inclination of the roof, a total of 12 photovoltaic modules have been integrated. The southern part has been installed to increase the energy production by PV, especially in winter, when the sun is at a low altitude. More specifically, 8 of the 12 photovoltaic modules have been integrated into the roof of the northern construction unit, with their long side parallel to the roof (east–west direction), covering the \(\sim \)67% of the south side of the roof. The rest 4 of them are on the roof of the unit next to it, covering the \(\sim \)34% of the south side of the roof. Assuming that 8 positions are available for the photovoltaics on the roof of the greenhouse, the positions covered in the northern construction unit are 1 to 8 (Fig. 1a), while for the southern greenhouse unit, the positions covered are 3, 4 (near the west side of the greenhouse) and 7, 8 (near the east side of the greenhouse) (Fig. 1b). The photovoltaics have been connected in such a way that they form three quads, with each quad connected in series. These three quads are then connected in parallel to a smart solar charger present in the system. Table 2 presents the characteristics of the greenhouse construction units, as well as the dimensions of the photovoltaics.

The integrated photovoltaics are semi-transparent, with high solar transmittance but also a significant degree of light dispersion, having the advantage of impeding severe shadowing from the greenhouse frame elements positioned below them. The integration of photovoltaics on the greenhouse roof that replaces the conventional cover is consistent with the concept of agrivoltaics, based on which the same land area is exploited twofold, for simultaneous energy and food production. This can contribute to the reduction of the greenhouse production cost, since all or part of the greenhouse energy needs of the greenhouse will be covered by the photovoltaics, serving simultaneously as cover material.

The dimensions of each photovoltaic module are 2.089 m long and 1.033 m wide, their thickness equal to 5.5 mm and their weight equal to 28.6 kg. However, their arrangement on the greenhouse roof needed them to overlap, therefore their length in the algorithm was adjusted to 2.048 m, as shown in Table 2. The cells have dimensions of 166 mm long and 83 mm wide, while they are of the bifacial type, increasing energy production since current production is based on light falling on both sides of the unit. The number of solar cells contained in each glass is equal to 80 and therefore, the active surface of the solar cells is equal to \(1.102\,{\hbox {m}}^2\). Regarding the electrical characteristics, these were calculated under Standard Testing Conditions (STC). More specifically, the Short Circuit Current—\(I_{{sc}}\)—was measured equal to 11.38 A, the Open Circuit Voltage—\(V_{{oc}}\)—equal to 27.32 V, the current at the point of maximum power—\(I_{{mpp}}\)—equal to 10.81 A and the voltage at the point of maximum power—\(V_{{mpp}}\)—equal to 23.13 V. Finally, the maximum rated power of each unit is equal to 250 Wp. It should be mentioned that although the photovoltaics that have been integrated into the greenhouse roof are semi-transparent, in the context of this study they have been considered as completely opaque.

Table 2 Greenhouse construction unit and PV modules characteristics

2.1 Calculations of the position of the sun

Starting with one of the most fundamental factors, the location of the sun in the sky can be defined by two separate angles in a spherical coordinate system, the solar zenith angle—SZA, and the solar azimuth angle—SAA (Rosa-Clot and Tina 2018). The SZA is defined as the angle formed by the line passing between the sun and the study area on Earth, and the perpendicular line to the same area (the z-axis in a Cartesian coordinate system). It can also be defined as the angle at which the beam radiation strikes the earth. The SAA is defined as the angle formed by the location of the meridian and the line projecting the sun to the observer on the horizontal plane and can range from −180\(^\circ \) to 180\(^\circ \). The angle can range between 90\(^\circ \) and -90\(^\circ \) in mid-latitude locations and on days less than 12 h. However, on days longer than 12 h, the angle may be more than 90\(^\circ \) or less than −90\(^\circ \), depending on whether it is approaching sunset or sunrise. The SAA can be calculated based on two different systems, depending on the position that takes its zero value. In the first system, where its zero value is taken towards the South, the value of the azimuth angle becomes increasingly negative as the observer approaches the East, while its value becomes increasingly positive approaching the West. A more practical method is to base the angle’s sign on the sign of the solar hour angle, with the azimuth angle being positive when the hour angle is positive and negative when the hour angle is negative. The calculation of the solar zenith angle is presented in Eq. (1), and according to the above solar azimuth angle is calculated by Eq. (2) (Duffie et al 2020):

$$\begin{aligned} SZA= & {} \cos ^{-1} \left[ \cos (\varphi ) \cdot \cos (\delta ) \cdot \cos (\omega ) + \sin (\varphi ) \cdot \sin (\delta ) \right] \nonumber \\ \end{aligned}$$
(1)
$$\begin{aligned} SAA= & {} \text {sign}(\omega ) \cdot \left| \cos ^{-1} \left[ \frac{\cos (\text {SZA}) \cdot \sin (\varphi ) - \sin (\delta )}{\sin (\text {SZA}) \cdot \cos (\varphi )} \right] \right| \nonumber \\ \end{aligned}$$
(2)

where SZA is the solar zenith angle (\(^\circ \)), SAA is the solar azimuth angle (\(^\circ \)), \(\phi \) is the latitude of the area under study (\(^\circ \), positive towards the Northern Hemisphere), \(\delta \) is the solar declination (rad), and \(\omega \) is the solar hour angle (\(^\circ \)). In this study, the SAA values used are based on the aforementioned second system, where its zero value is taken toward the North and increases as we move to the East. In such a system, the SAA takes only positive values in a range between 0\(^\circ \) and 360\(^\circ \). The conversion of the SAA from system 1 to system 2 was achieved by adding to the first, value of 180\(^\circ \).

The calculation of the aforementioned angles (SZA & SAA) requires the calculation of additional parameters, such as the solar declination—\(\delta \), and the solar hour angle—\(\omega \) which are characterized by increased complexity due to the desired short timestep in the present study, which is equal to 10 min. Starting with the calculation of the fractional year—\(\gamma \)—the expression of a given period into decimal format is achieved. The fractional year is calculated by Eq. (3) (Duffie et al 2020):

$$\begin{aligned} \gamma = \frac{2\pi }{365} \left( N - 1 + \frac{h - 12}{24} \right) \end{aligned}$$
(3)

where \(\gamma \) is the fractional year (rad), N is the day of the year, which ranges between 1 and 365 or 366 (for leap years), and h is the needed hour of the day. Through the fractional year, it is possible to calculate both the equation of time and the solar declination with a 10-minute timestep. The equation of time – \(E_t\) considers the perturbations in the earth’s rotation rate to determine when the sun crosses the observer’s meridian (Duffie et al 2020). For the calculation of the equation of time, Eq. (4) (Duffie et al 2020) was used:

$$\begin{aligned} E_t= & {} 229.2 \cdot [ 0.000075 + 0.001868 \cdot \cos (\gamma ) \nonumber \\{} & {} -0.032077 \cdot \sin (\gamma ) - 0.014615 \cdot \cos (2\gamma ) \nonumber \\{} & {} -0.04089 \cdot \sin (2\gamma ) ] \end{aligned}$$
(4)

where \(E_t\) is the equation of time (min), and \(\gamma \) is the fractional year (rad). In Eq. (4), the equation of time is represented by the term in square brackets on the right-hand side of the equation, while the multiplier value 229.2 converts it into minutes. The results obtained using Eq. (4) are accurate to within 0.0025 rad, which is approximately equivalent to 35 s (Iqbal 1983). The solar declination—\(\delta \) refers to the sun’s angle with respect to the equator during solar noon, when it is in the north positive direction and is on the local meridian. \(\delta \) takes values in a range of \(-\)23.45\(^\circ \) to 23.45\(^\circ \) and is calculated by Eq. (5) (Duffie et al 2020):

$$\begin{aligned} \delta= & {} 0.006918 - 0.399912 \cdot \cos (\gamma ) + 0.070257 \cdot \sin (\gamma ) \nonumber \\{} & {} - 0.006758 \cdot \cos (2\gamma )+ 0.000907 \cdot \sin (2\gamma ) \nonumber \\{} & {} - 0.002697 \cdot \cos (3\gamma ) + 0.00148 \cdot \sin (3\gamma ) \end{aligned}$$
(5)

where \(\delta \) is the solar declination (rad), and \(\gamma \) is the fractional year (rad). The results obtained by Eq. (5) are accurate to within 0.0006 rad (Spencer 1971).

Another important parameter that needs to be calculated is the true solar time—TST. The time employed in all sun-angle connections is known as solar time, which is different from local clock time. Standard time must be converted into true solar time, which can be accomplished by applying two modifications. The first modification concerns the difference that is presented in the longitude between the observer’s meridian and the meridian that serves as the foundation for local standard time—LST. One degree of longitude is traversed by the sun in 4 min. The second adjustment comes from the equation of time. The TST is given by Eq. (6) (Duffie et al 2020):

$$\begin{aligned} \text {TST} = \text {LST} + \text {time offset} \end{aligned}$$
(6)

where TST is the true solar time (min), LST is the local solar time (min), and time offset is the Coordinated Universal Time (UTC) offset, which represents the difference in time, measured in minutes, between a location’s LST and UTC. The time offset is calculated by Eq. (7) (Duffie et al 2020):

$$\begin{aligned} \text {time offset} = 4 \cdot (L_{\text {st}} - L_{\text {loc}}) + E_t \end{aligned}$$
(7)

where \(L_{{st}}\) is the standard meridian for the local time zone, \(L_{{loc}}\) is the longitude of the location under study (both in degrees and positive west of the Prime Meridian, so that 0\(^\circ \) < L < 360\(^\circ \)), and \(E_t\) is the equation of time given by Eq. (4). \(L_{{st}}\) can be calculated by multiplying the time zone of the study area by 15 degrees. This is because the solar hour angle varies at a rate of 15 degrees every hour (Wang 2019).

The final parameter that must be calculated is the solar hour angle – \(\omega \). The solar hour angle is the sun’s angular displacement from the local meridian east or west, as a result of the earth’s 15\(^\circ \) per hour rotation on its axis. Hour angle can have negative and positive values in the morning and the afternoon, respectively, and can be calculated by Eq. (8) (Duffie et al 2020):

$$\begin{aligned} \omega = \frac{\text {TST}}{4} - 180^\circ \end{aligned}$$
(8)

TST is the true solar time (min).

Function 1 (SunPos) in Appendix A, provides the main points of the solar position computation, according to Eq. (1) to (8). All programming codes, such as Function 1, are included in Appendix A.

2.2 Transformation from spherical to cartesian coordinate system

To identify the lines on which both the boundary points of the photovoltaics and the position of the sun will correspond, it is necessary that the second one, which is calculated in a spherical coordinate system S(r,\(\theta \),\(\phi \)), must be transformed into a Cartesian coordinate system C(x,y,z), where r is the radial distance, or in this case the distance between the point (0,0,0) on Earth and the Sun’s position, \(\theta \) is the polar angle or the solar zenith angle—SZA, and \(\phi \) is the azimuthal angle or the solar azimuth angle—SAA. The variables x, y, and z are defined as the coordinates of any point on the Cartesian coordinate system, with respect to the x-, y-, and z-axis, respectively.

The system of the equations used to implement the above transformation of the sun’s position into the Cartesian coordinate system is presented by Eq. (9), (10), and (11) (Anderson and Mikofski 2020).

$$\begin{aligned} x_{\text {sun}}= & {} r \cdot \sin (\text {SZA}) \cdot \cos (\text {SAA}) \end{aligned}$$
(9)
$$\begin{aligned} y_{\text {sun}}= & {} r \cdot \sin (\text {SZA}) \cdot \sin (\text {SAA}) \end{aligned}$$
(10)
$$\begin{aligned} z_{\text {sun}}= & {} r \cdot \sin (\text {SZA}) \end{aligned}$$
(11)

where \(x_{\text {sun}}\), \(y_{\text {sun}}\), and \(z_{\text {sun}}\) are the coordinates of the Sun’s position with respect to the x-, y-, and z-axis, respectively.

Fig. 2
figure 2

Earth’s elliptical orbit around the Sun

One parameter from the above, which also shows a dependence on time, albeit with relatively minor variation in such a small timestep, is the Earth-Sun’s distance, r. For the calculation of the Earth-Sun distance, the Kepler orbit theory was used. A Kepler orbit can be described as the motion of a body in relation to another. Such an orbit forms a two-dimensional curve (ellipse, parabola, or hyper-bola), in a three-dimensional space, and is characterized by elements such as the semimajor axis, \(\alpha \), eccentricity, e, and the inclination, i. In the Earth-Sun system, the Earth moves in an elliptical orbit (0 < e < 1) around the Sun, while there are distances, such as aphelion and perihelion, which correspond to the shortest and the greatest distance of the Earth from the Sun, respectively, and their values have been identified. Taking into consideration the above information, the Earth-Sun distance calculation is feasible by using specific equations, even for very short periods (Krüger and Grün 2014; Pälike 2005). In Table 3, the characteristics of Earth’s elliptical orbit that were used for the calculation of r, are presented.

Table 3 Characteristics of Earth’s elliptical orbit around the Sun

Based on the relation, which connects the Earth-Sun’s distance at the perihelion to the semimajor axis, \(\alpha \), and the eccentricity, and basic general equations for each curve in the form of an ellipse, the parameters \(\alpha \) (Eq. (12)), c (Eq. (13)) and b (Eq. (14)) are calculated (Krüger and Grün 2014).

$$\begin{aligned} a= & {} \frac{p}{1 - e} \end{aligned}$$
(12)
$$\begin{aligned} c= & {} e \cdot a \end{aligned}$$
(13)
$$\begin{aligned} b= & {} \sqrt{a^2 - c^2} \end{aligned}$$
(14)

where \(\alpha \) is the semimajor axis (m), p is the Earth-Sun’s distance at the perihelion (m), e is the eccentricity (-), c is the linear eccentricity or the distance between the center of the ellipse and the focal (m), and b is the semi-minor axis of the ellipse (m). Assuming that the above ellipse is centered at the point C(0,0) (Fig. 2) in a two-dimensional Cartesian coordinate system, and the Sun is on the foci 1 of the ellipse (point F1 in Fig. 2), the parametric equation that gives the earth’s orbit around the sun is given by Eq. (15), with the orbital coordinates given by Eq. (16) for the x-component and from Eq. (17) for y-component (Krüger and Grün 2014; Xu and Xu 2013). Equation (18) presents the parametric equation of the distance between foci 1 and the point (x,y), or in the Earth-Sun system, the distance between Earth and the Sun. At the same time, in Fig. 2, the position of the perihelion and the aphelion are presented by points P and A, respectively.

$$\begin{aligned}{} & {} \frac{x^2}{a^2} + \frac{y^2}{b^2} = 1 \end{aligned}$$
(15)
$$\begin{aligned}{} & {} x = a \cdot \cos (t) \end{aligned}$$
(16)
$$\begin{aligned}{} & {} y = b \cdot \sin (t) \end{aligned}$$
(17)
$$\begin{aligned}{} & {} r = \sqrt{(x - c)^2 + y^2} \end{aligned}$$
(18)

where a is the semi-major axis of the ellipse, b is the semi-minor axis of the ellipse, and t is an angle that varies in a range from 0\(^\circ \) to 360\(^\circ \).

Table 4 Inputs of greenhouse characteristics in Function 4

For the estimation of the angle t, it is considered that the Earth requires 365 days for a complete rotation of 360\(^\circ \), therefore for each day of the year, the Earth traverses an angle equal to 0.986\(^\circ \), while for each 10-minute period, which is the desired time step in this study, this angle takes a value equal to 0.986\(^\circ \)/144, as one day corresponds to 144 10-minute time intervals. Finally, the parametric equation resulting from the above and used to calculate the Earth-Sun distance (distance \(F_1E\) in Fig. 2) for every 10 min of the year is given by Eq. (18), which by substituting Eqs. (16) and (17) turns into Eq. (19).

$$\begin{aligned} r(t') = \sqrt{\left[ a \cdot \cos \left( \frac{0.986}{144} \cdot t'\right) - c\right] ^2 + \left[ b \cdot \sin \left( \frac{0.986}{144} \cdot t'\right) \right] ^2} \nonumber \\ \end{aligned}$$
(19)

where r is the Earth-Sun distance for 10 min around the year (m), and \(t'\) is the index of the 10-minute period (-) throughout the year.

In Function 2 (EarthSunDist) of Appendix A the main points of the Earth-Sun distance computation are presented, according to Eqs. (12) to (14) and (19).

The calculated Earth-Sun distance by Function 2 is used in conjunction with the SZA and SAA angles calculated from Function 1 to transform the spherical coordinates of the Sun’s position to Cartesian, which is presented by Function 3 (SunPosCart) of Appendix A. For the times when the solar altitude angle, which is referred to as the complementary of the SZA, is less than zero, thus describing the nighttime hours, the coordinates for the position of the sun do not exist.

Table 5 Sub-cases for the number of construction units with widthwise or lengthwise repetition

2.3 Greenhouse coordinates in the Cartesian coordinate system

The fourth function (Function 4) concerns the basis of the whole study, the greenhouse. This specific function gives the possibility to map an even-span greenhouse and find the points that form it in a three-dimensional Cartesian coordinate system. The orientation of the system (East–West-North–South) was determined based on the results of Function 1, where the position of the Sun is estimated. As a result, the North–South and the East–West direction, are represented by the x-axis and the y-axis, respectively, while the altitude from the surface is represented by the z-axis. Function 4 receives as inputs, basic parameters concerning a basic greenhouse construction unit, such as the orientation (ridge direction), the width (short-side length), the length (long-side length), and the gutter and ridge heights from the ground surface. Simultaneously, the repeatability of the basic construction unit to create the overall greenhouse, either lengthwise or widthwise, is considered. All the inputs of Function 4 are presented in Table 4.

To begin with, it is necessary to define the reference point, based on which the greenhouse will be formed. This is regarded as the origin of the axes (x,y,z) = (0,0,0) in this function, which corresponds to the bottom southwest corner of the greenhouse. Based on this point, all the other points that represent the edges of the frame of the first construction unit of the greenhouse are defined. Once these points have been calculated, they are stored in a two-line cell-type variable in MATLAB, the first one corresponds to the greenhouse units in the case of width-wise repentance, while the second one is to the greenhouse units in the case of lengthwise repentance. The size of the cell varies according to the number of construction units. Finally, each element of the cell consists of an array of three columns, one for each direction (x,y,z), and ten rows, one for each point of the greenhouse.

Function 4 (GreenhouseCoord) of Appendix A contains two limitations, the first concerns the ridge orientation, for which there are only two options, that of the East–West direction (Case 1) and that of the North–South direction (Case 2). The second limitation concerns the fact that the number of construction units should be a positive integer number, but also the definition of at least one construction unit. For the detection of the greenhouse frame points, except for the two previously stated cases, it was essential for additional sub-cases that involve scenarios for the number of construction units with widthwise or lengthwise repetition. More specifically, these cases describe:

  1. 1.

    One or more construction units widthwise and none or one unit lengthwise (Sub-case 1). The situation of one unit in length is identical to the first unit in width, but it must be defined due to a different variable in the Function’s input.

  2. 2.

    One or more construction units lengthwise and none or one unit widthwise (Sub-case 2).

  3. 3.

    More than one construction unit both widthwise and lengthwise (Sub-case 3).

Table 6 Limitations for the possible photovoltaic positions

Finally, three different arrays are created for the points, one for each coordinate based on the characteristic parameters of the greenhouse. Each of them consists of ten lines, one for each point and they are the output of the nested function “GrhXYZ”. The use of this nested function shortens and speeds up the code. The repeatability of units for the widthwise and lengthwise cases is achieved through a “for loop” for the x- and y-coordinate, respectively for each sub-case. The “for loops” for each sub-case are presented in Table 5. In contrast, in the case of the North–South direction of the ridge, the widthwise repetition concerns the y-coordinate, while the lengthwise repetition concerns the x-coordinate. Function 4 is presented only as the case for an East–West oriented greenhouse.

2.4 Calculation of shadow coordinates

The points that form the shaded surface by the photovoltaics are located by Function 5. To find this surface on the ground, it is necessary to find the points that form the photovoltaics in the three-dimensional Cartesian coordinate system (\(x_{{PV}}\),\(y_{{PV}}\),\(z_{{PV}}\)), as well as the corresponding point of the sun’s position (\(x_{{sun}}\),\(y_{{sun}}\),\(z_{{sun}}\)), as computed by Functions 1-3. In Part 1 of the algorithm (Calculation of PV Points), which is contained in Appendix A, the points of the photovoltaic location are calculated according to the Cartesian coordinate system.

Firstly, in Part 1, the positions of the photovoltaics installed in each construction unit are defined. Based on the length of the photovoltaics and the length of the greenhouse, the total available positions that the photovoltaics can take on the greenhouse roof are eight. However, some limitations have been set, based on which the algorithm stops, giving the corresponding error messages. These limitations correspond to cases where the total length of the photovoltaic array exceeds the total length of the greenhouse roof (Limitation 1), as well as cases where the width of the photovoltaics exceeds the length of the inclined plane of the roof (Limitation 2). The definition codes of these limitations are presented in Table 6.

At the same time, in Part 1 two more cases are distinguished, one for the placement of the photovoltaics in a greenhouse with an East–West direction and the other for the placement of the photovoltaics in a greenhouse with a North–South direction. These cases are separated due to the repetition required to find the coordinates of the PVs. In the first case, a repetition is required for the x-coordinate, as it differs between the construction units since they are repeated parallel to the x-axis. Simultaneously, with the placement of the photovoltaics done with their long side parallel to the ridge, the y-coordinate changes, with its value being calculated through repetition based on the length of the photovoltaic and the position where each element is placed. The y-coordinate for the case of the different units in the case of the East–West direction remains constant. For the second case, where the greenhouse has a North–South direction, the y-coordinate performs like the x-coordinate of the previous case, with it differing between construction units, since now the greenhouse units are repeated parallel to the y-axis. Accordingly, the value of the x-coordinate is calculated through a repetition based on the length and position of the photovoltaic.

With the photovoltaics on the roof of the greenhouse placed so that their long side is the same as the ridge, some of their points are identical to the already calculated points of the greenhouse. The coordinates of the remaining points have been found based on simple geometric relationships and the characteristics of the greenhouse. Finally, the z-coordinate appears the same for both the first and the second case, as both the gutter and ridge height remain constant.

In Part 1, the code is presented only for the case of a greenhouse with an East–West orientation. For the 3D visualization of the photovoltaics on the roof of the greenhouse, it is necessary to create data grids based on the corner points for each photovoltaic. The main commands used are "linspace" and "meshgrid", while the "CU_tables" is a cell-array that contains the greenhouse points that have been extracted by Function 4.

Based on the points related to the four corners of the photovoltaic module and the point related to the sun’s position, four lines are formed for each photovoltaic module. Each of these lines that are formed for each desired time t corresponds to one of the four photovoltaic points, while a common point is the position of the sun. For each of these four lines, there is a three-dimensional vector of the form (Eq. (20)):

$$\begin{aligned} \textbf{r}_{\text {sh.point},n}= & {} \left( \textbf{x}_{\text {sh},n}, \textbf{y}_{\text {sh},n}, \textbf{z}_{\text {sh},n} \right) \nonumber \\= & {} \left[ x_n + k \cdot (x_s - x_n), y_n + k \cdot (y_s - y_n), z_n \right. \nonumber \\{} & {} \left. + k \cdot (z_s - z_n) \right] \end{aligned}$$
(20)

where \(\textbf{r}_{{sh.point},n}\) is the position vector of the shadow point produced by one of the four points of the PV, \(\textbf{x}_{{sh},n}\), \(\textbf{y}_{{sh},n}\), \(\textbf{z}_{{sh},n}\) are the position vectors of the shadow point with respect to each axis of the three-dimensional coordinate system, \(x_{{s}}\), \(y_{{s}}\), and \(z_{{s}}\) are the coordinates that define the position of the sun, \(x_{{n}}\), \(y_{{s}}\), and \(z_{{s}}\), are the coordinates defining each point of the photovoltaic, with n = 1, 2, 3, 4, and k is a constant.

From Eq. (20), a system of three partial equations that represent the coordinates of the points that form the shadow, is obtained (Eqs. (21), (22), and (23)).

$$\begin{aligned} x_{\text {sh},n}(k)= & {} x_n + k \cdot (x_s - x_n) \end{aligned}$$
(21)
$$\begin{aligned} y_{\text {sh},n}(k)= & {} y_n + k \cdot (y_s - y_n) \end{aligned}$$
(22)
$$\begin{aligned} z_{\text {sh},n}(k)= & {} z_n + k \cdot (z_s - z_n) \end{aligned}$$
(23)

Solving the above system of equations and setting the z-coordinate (\(z_{{sh}}\)) equal to 0, since the shadow is on the ground (xy-plane on the three-dimensional coordinate system), two equations are obtained, one for the values of the x-coordinate of the shadow and one for the values of the y-coordinates (Eqs. (24) and (25), respectively).

$$\begin{aligned} x_{\text {sh}}= & {} x_n - c_n \cdot z_n \end{aligned}$$
(24)
$$\begin{aligned} y_{\text {sh}}= & {} y_n - \frac{z_n}{b_n} \end{aligned}$$
(25)

where \(b_{{n}}\) and \(c_{{n}}\) are given by Eq. (26) and (27), respectively.

$$\begin{aligned} b_n= & {} \frac{z_s - z_n}{y_s - y_n} \end{aligned}$$
(26)
$$\begin{aligned} c_n= & {} \frac{x_s - x_n}{z_s - z_n} \end{aligned}$$
(27)

Function 5 (PVShadowPoint) in Appendix A provides the computations of the shadow points, according to Eq. (24) to (27).

2.5 Binary analysis

To represent the area covered by the greenhouse and determine the portion shaded by the photovoltaics, arrays with logical values (0 and 1) have been created. In terms of the greenhouse, the value 0 (false) corresponds to an area that is not covered by a greenhouse, while the value 1 (true) refers to an area that is enclosed by the greenhouse’s limits. Because of the nature of the issue, this array will always be the same for each time of year. Regarding the shade formed by the photovoltaics, the corresponding array will have the same dimensions as the corresponding one of the greenhouse. This is because the algorithm requests the shadow on the ground inside the greenhouse to the total ground covered by the greenhouse, rather than the entire ground. As before, values of 0 and 1 represent the unshaded and shaded areas, respectively.

An array of zero values (false) is initially created based on the dimensions entered for the greenhouse. More specifically, it is assumed that the rows of the array created are the values corresponding to the y-components of the greenhouse coordinates, while the columns of the array correspond to the x-components. Due to the need for integer values of the dimensions of the green-house (since each row-column corresponds to a specific point of the x-y plane of the Cartesian coordinate system), and since the accuracy of the entered values (length of the greenhouse, width of the greenhouse, etc.) is of the order of centimeters (up to two decimal places), all dimensions, both for the greenhouse and for the shadows, are converted from meters to centimeters. Another transformation of the actual points of the greenhouse, but also the shade, is the additional increase of each value by 1 cm since there is no zero columns or row in the created array. Finally, after the greenhouse limits have been calculated by Function 4, the array cells corresponding to values within the greenhouse limits are replaced with the value 1 (true). At the same time, it should be noted that value 1 concerns only the cultivable unit of the greenhouse (Construction unit 2 – CU 2) and not the entire greenhouse. The code implemented for the above is presented in Part 2A of Appendix A.

As for the shade formed by the photovoltaics, the same strategy is followed with some additional necessary points. The first point concerns the conversion of all the coordinates of the shadow boundaries into positive quantities. Considered a coordinate system in which the coordinates of the sun’s position take either positive or negative values, the coordinates of each shadow point can be either positive or negative, respectively. However, an array where each row-column corresponds to a point on the x-y plane requires that each value be positive and non-zero. Thus, every non-positive coordinate of the shadow is converted into 1. The shadow boundaries may become narrower, without affecting the final desired result as the boundaries of the greenhouse consist of positive values and the purpose of the algorithm is to calculate the shading within it. Finally, for the best performance of the algorithm, the limits of the shadow that present positive values and are greater than the limits of the greenhouse are equated with those of the greenhouse limits without again affecting the final result which, as mentioned above, is the estimation of the shadow inside the greenhouse and in relation to the total surface thereof. The additional necessary points of the code implemented for the above are presented in Part 2B of Appendix A.

2.6 Calculation of the greenhouse shaded surface

As mentioned above, the final desired result extracted by the algorithm concerns the surface of the greenhouse’s cultivable unit that is covered by the shadow of photovoltaics. By creating arrays of logical values from the previous steps, there is the possibility of knowing if every square centimeter of the greenhouse’s surface is also covered by the shadow. The basic idea is that since the number of cells of the "binary_array_CU_2" and "binary_array_shade" is the same and each cell represents the same square centimeter of land, then the number of cells of the "binary_array_CU_2" that are in the same position as the cells of the "binary_array_shade" and both contain the logical value 1 (true), represents the size of the shaded area of the greenhouse in cm2. Finally, dividing by the total number of cells of the "binary_array_CU_2" containing the value 1, the percentage of the shaded area is calculated. The above is described in Part 3 of the code, which is contained in Appendix A, where the multiplication by 104 is for the conversion of cm2 to m2.

2.7 Shaded point investigation

In order to check whether a point inside the greenhouse is shaded by the photovoltaics or not, its coordinates are used as input to the algorithm. Thus, it is possible to produce an analytical mapping of the shading for each time. Coordinate values must be entered in (x,y) pairs, as no point is defined by adding only the x- or y-coordinate, while in case of entering only the x- or y-coordinate, the algorithm stops with the corresponding error indication. However, if the above operation is not desired by the user, the algorithm stops by first retrieving all previous results.

The output of this function is an array for each point, with values 0 and 1 for the unshaded and shaded point cases, respectively. Each array consists of a variable number of rows depending on the times for which the algorithm is executed, and a variable number of columns, depending on the number of photovoltaic arrays. For nighttime periods, the output receives NaN (non-available) values. The above is described in Part 4 of the code, which is contained in Appendix A.

2.8 Complete Algorithm

As mentioned above, the algorithm consists of five distinct functions and four individual parts. To derive the result from the algorithm, as input values for each subsequent function or part, the output values of the previous function are used. By entering the desired values for the time (year, month, day, hour, minutes, seconds, time zone), for the greenhouse (orientation, number of construction units in width and length, width and length of construction unit, gutter, and ridge height), for the geographical coordinates (latitude and longitude of the location of the greenhouse), for the dimensions of the photovoltaics (length and width), and finally, for the position of the photovoltaics on the roof, there is the possibility, based on the way the algorithm is configured, to extract the surface \(m^2\) that is covered by the shade of the photovoltaics within the greenhouse cultivation unit with a precision of two decimal points, the percentage of the shaded surface in relation to the total area of the unit (%), and finally two representative two- and three-dimensional graphics. The complete algorithm (PVShading) is presented in Appendix A.

2.9 Validation

As already mentioned, the photovoltaic modules integrated into the roof of the experimental greenhouse are semi-transparent, with the shading provided to the ground surface amounting to \(\sim \)51% of their total surface. This fact, in combination with their ability to scatter the incident light, makes studying penetrating radiation and, by implication, shading particularly challenging.

In order to validate the algorithm, and at the same time considering that the operation of the algorithm is based on the fact that the photovoltaics integrated into the greenhouse roof are opaque, it was necessary to add an opaque medium and to cover them. The opaque medium used was cardboard about 4 mm thick, while its placement was done under the surface of the photovoltaics inside the greenhouse, and along their surface, as shown in Fig. 3. The result of the use of this medium is the creation of intense shading, similar to that created by opaque photovoltaics, and therefore, the detection of differences in the radiation recorded by two pyranometers placed inside the greenhouse.

Fig. 3
figure 3

Photovoltaic modules covered by an opaque material

Regarding the measurement of Global Horizontal Irradiance - GHI (\(W/m^2\)), two CMP3 pyranometers from the Kipp & Zonen company were used, which were placed at the height of the surface, as the position of the shading calculated based on the algorithm concerns this specific height. The data used to validate the algorithm concerns the period from 05/08/2023 to 29/08/2023. During this period, the position of the first pyranometer (Pyranometer 1) had coordinates (\(x_{{P,1}}\),\(y_{{P,1}}\)) = (4.81,11.85), while the position of the second (Pyranometer 2) had coordinates (\(x_{{P,2}}\),\(y_{{P,2}}\)) = (4.81,4.55) (Fig. 4). These values refer to distances (m) from the beginning of the axes, as defined based on the algorithm. Finally, the radiation data is obtained with a time step of 10 min, with the value recorded each time being the average of the one-minute data of the interval. In addition to the two pyranometers inside the greenhouse, another CMP3 pyranometer is located outside the greenhouse to monitor the irradiance before it penetrates the greenhouse. The measurements from this pyranometer are taken in the same way as the previous ones.

Fig. 4
figure 4

Positions of the pyranometers inside the greenhouse

The coefficient used in this work is the coefficient of variation—CV. The coefficient of variation is defined both in statistics and in probability theory as the ratio between the standard deviation and the mean value, while it enables the detection of various changes. CV’s value is typically calculated as a percentage, while in comparison to a greater CV (Reed et al 2002), a lower value shows less fluctuation in the data (Snee 1977; Colin Koeniguer and Nicolas 2020).

In this paper, the time periods during which the pyranometer is shaded by the photovoltaics were found, after the algorithm was executed for each 10-minute time interval of the day under study. The irradiance changes for the specified intervals are stored, creating a data set \(S_{{i}}\), where i is the number of the day. Then, for each day and for the daylight hours, fifty separate random sets of irradiance change data (\(U_{{i,1}}\) to \(U_{{i,50}}\)) concerning the pyranometer while it is not shaded and whose size is equal to the size of \(S_{{i}}\), were generated. The large number of random data sets aims to use the values for each moment in time. Finally, the coefficient of variation was calculated, both for \(S_{{i}}\) and for \(U_{{i,1}}\) to \(U_{{i,50}}\). A small value of the CV for the data package S, in comparison to the corresponding values of the coefficient for the \(U_{{i,1}}\) to \(U_{{i,50}}\) data sets, indicates the uniformity of the irradiance change in the area shaded by the PVs, given that a point remains inside it for a longer period of time, in comparison to the shading caused by the greenhouse’s small-section skeletal elements. The above procedure was followed for both pyranometers inside the greenhouse.

3 Results

3.1 Algorithm’s outputs

Fig. 5
figure 5

Sun position in the Cartesian coordinate system for December 21, March 20, and June 21

Fig. 6
figure 6

Greenhouse points for a the southern and b the northern construction unit

Fig. 7
figure 7

3D representation of the result of the algorithm for December 21 at 12:00:00

Fig. 8
figure 8

3D representation of the result of the algorithm for March 20 at 12:00:00

Fig. 9
figure 9

3D representation of the result of the algorithm for June 21 at 12:00:00

The algorithm, as indicated in the preceding paragraph, consists of functions, the output values of which are used as input values for the other functions, allowing each function to work independently. The results of the first three functions for the position of the sun in spherical coordinates, the Earth-Sun distance, and the position of the sun in Cartesian coordinates are presented in Appendix B. The days chosen for the presentation of the graphical results of the algorithm are December 21, March 20, and June 21 of the year 2022. These three days were chosen because they correspond to the winter solstice, spring equinox, and summer solstice, respectively, when there is the biggest variation in the position of the sun, as well as an average state between them. The autumnal equinox on September 23rd of the same year is excluded as the movement and positions of the sun during the day are the same as the vernal equinox on March 20. The time based on which the results are extracted is the local wintertime (UTC+2).

Figure 19a and b in Appendix B show the solar zenith angle and the solar azimuth angle, respectively (Function 1), for the three days above and the period 00:00:00–23:50:00 with a time step of 10 min. In Fig. 20a, b, and c, the Earth-Sun distance (Function 2) for the above three days and the corresponding times, is presented. Each plot corresponds to a different day, due to the small daily variation to the annual variation, which is presented in Fig. 21.

Receiving the results of Functions 1 and 2, Function 3 calculates the three coordinates (x, y, and z) of the sun’s position for a Cartesian coordinate system every 10 min. These 144 positions for each of the aforementioned days are presented in Fig. 5, where at the same time it can be seen how the North-South and East–West directions have been determined in the Cartesian coordinate system. Based on these, the calculations for the points of the greenhouse, the photovoltaics, as well as the final result of the shading have been done.

In Figs. 6a and b, the points (peaks) that form the southern and northern greenhouse units in a Cartesian coordinate system, respectively, as a result of Function 5 and based on the characteristics of the greenhouse (Table 2), are presented. The exact points are then utilized to generate the 2 and 3D visualizations, as well as to locate the shadow within the greenhouse.

The complete algorithm was executed for the aforementioned three days and for the time 12:00:00. Figures 7, 8, and 9 present the three-dimensional graphics consisting of the two greenhouse construction units, the photovoltaics, and the shadow formed by them. The dimensions are real and expressed in meters, while as in Fig. 5 for the position of the sun, the x- and y- axes show the orientation. The height of the greenhouse from the ground is shown on the z-axis of the Figures.

The time constancy of algorithm execution across all three scenarios reveals that the shadow cast by the photovoltaic system predominantly follows a parallel trajectory to the x-axis. Conversely, during the period from December to June, the sun progressively ascends, leading to a steeper angle of solar radiation incidence. Consequently, the shadow progressively shifts to a position directly beneath the photovoltaic system and within the confines of the greenhouse, while its surface decreases over time.

In Figs. 10, 11, and 12, the results of the algorithm for the two-dimensional graphics are presented. In these specific cases, the floor plans of the above situations are presented, with the presence or absence of the shadow (light gray, intense gray, and black for the different photovoltaic arrays) and the presence of the greenhouse construction units (red for the Southern and blue for the northern construction unit). The dimensions on the axes are described in cm, as the specific graphics are a more direct representation of the quantitative results (shadow area) before converting them to m2 in Part 3 of the algorithm. At the same time, the shadows outside the greenhouse are lacking in the specified circumstances since only those inside the greenhouse are considered. Finally, in Table 7, the area of the shadow (m2) located within the northern construction unit and its percentage of the total surface of the unit is presented.

Fig. 10
figure 10

2D representation of the result of the algorithm for December 21 at 12:00:00

Fig. 11
figure 11

2D representation of the result of the algorithm for March 20 at 12:00:00

Fig. 12
figure 12

2D representation of the result of the algorithm for June 21 at 12:00:00

Fig. 13 depicts the percentage of shade coverage over three days. Apart from the day for December 21, where the interior of the northern construction unit is not shaded at all, the other two cases have shadow coverage with a maximum around midday, when the sun is above the greenhouse, with a percentage of 19.94% for March 20 at 12:40:00 and 33.19% for June 21 at 12:30:00. There is also a difference in the pattern of the curve between the two days, with the curve of June 21 appearing more symmetrical in terms of the time point of the maximum, compared to that of March 20. This is due to the fact that for the case of June 21, the shading is formed by photovoltaics located on the roof of the northern unit and covering its entirety in the direction of the y-axis (Figs. 9 and 12), resulting in absolute symmetry around the middle of the greenhouse. In contrast, the shadow for the other case of March 20 is due to the photovoltaics located in the adjacent unit (Figs. 8 and 11), and unlike the first case, they show discontinuity and asymmetry in placement. Therefore, the sharp decrease in shading after noon is explained by the gap in the positions between the two arrays on the roof of the southern construction unit of the greenhouse.

At the same time, for the case of March 20 and for the interval 15:30:00 to 16:30:00, the percentage of shading is observed to show an increase of around 8% in contrast to the broader decline. This fact is due to the position of the sun with a zenith angle of about 55 to 70 (Fig. 19a) is such that, in combination with the geometry, the placement of the photovoltaics, and the high accuracy of the algorithm (of the order of a square centimeter) causes different rate of change of shaded area, with the rate of decrease of the shaded area along the x-axis being less than the rate of increase of the shaded area along the y-axis. These cases cannot be distinguished from the case of June 21, since the zenith angle for which this phenomenon is caused reaches such values (55 to 70) when the shadow has not been created of one of the greenhouse units.

Table 7 Shadow area within the greenhouse northern construction unit and percentage coverage for December 21, March 20, and June 21

Finally, Fig. 14 shows the results of the algorithm throughout the days of the year 2022 with a time step of 10 min. The plot in Fig. 14 consists of 52,560 values (e.g., 365 days \(\cdot \) 24 h \(\cdot \) 6 10-minute periods), of which periods just before sunrise and just after sunset receive NaN values. The daily fluctuations in shade are not noticeable in this case, but rather a larger pattern of shadowing is formed by photovoltaics. More specifically, two local maximums, two global maximums, and three local minimums are observed. The first and second local maximums on February 17 and October 26 with percentage coverage equal to 22.84% and 22.81%, respectively, are related to the shading caused by the photovoltaics installed on the southern construction unit. The reduced values, by about 53% from the global maximums presented on May 5 and August 9, are due to the discontinuity of the arrays and the incomplete coverage of the roof of the southern unit by photovoltaics. On the other hand, the two global maximums of the preceding dates with values equal to approximately 35%, are due to the complete covering of the southern inclined plane of the roof of the northern construction unit. Thus, as the values considered in this Figure are the daily maximums, it is acceptable that the decrease in February should be approximately 50% in relation to May, since in February, the photovoltaics participating in the shading of the greenhouse are four, in contrast to May when the photovoltaics participating in the shading are eight.

The first local minimum, shown in Fig. 14, which lies between the first local maximum and the first global maximum on March 27, as well as the third local minimum, which lies between the second global maximum and the second local maximum on September 19, are because the sun is above the southern construction unit and at a minimum zenith angle. This fact also accounts for the reduction of shading between the two maximums, but in this case, the sun is at such a point that a smaller shadow is caused by the photovoltaics of the northern construction unit.

Fig. 13
figure 13

Diurnal percentage of shade coverage for December 21, March 20, and June 21

Fig. 14
figure 14

Annual percentage of shade coverage

Fig. 15
figure 15

Global Horizontal Irradiance and Shading for Pyranometer 1 on August 7, 2023

Fig. 16
figure 16

Global Horizontal Irradiance and Shading for Pyranometer 1 on August 7, 2023

Fig. 17
figure 17

Coefficients of Variation for irradiance change datasets and their trends for shaded and unshaded points for pyranometer 1

Fig. 18
figure 18

Coefficients of Variation for irradiance change datasets and their trends for shaded and unshaded points for pyranometer 2

3.2 Validation of the algorithm

As described in Sect. 2.9, for the validation of the model, the photovoltaics integrated on the roof of the greenhouse were covered with an opaque medium, in order to generate a strong shadow beneath them. This intense shading would not be possible to be formed by the existing semi-transparent photovoltaics, since the shading offered by each of these modules corresponds to \(\sim \)51% of their total surface. As a result of their design and location in the greenhouse, the shade produced is relatively weak.

The measured Global Horizontal Irradiance from both the pyranometer outside the greenhouse and from the pyranometers 1 and 2 inside the greenhouse, for August 7, 2023, is presented in Figs. 15 and 16, respectively. For both pyranometers, two shaded areas are shown, one during the morning hours, and one in the afternoon, while a distinct drop in irradiance is observed during the period of time when the two pyranometers are inside the shadow formed by the photovoltaics.

The two different shading time intervals are due, on the one hand, to the position of the pyranometers inside the greenhouse ((\(x_{{P,1}}\),\(y_{{P,1}}\)) = (4.81,11.85), (\(x_{{P,2}}\),\(y_{{P,2}}\)) = (4.81,4.55)), which are placed on the straight line that divides the width of the greenhouse unit in half, and on the other hand, to the movement and height of the sun, which for the specific day and as we approach the end of the year becomes continuously smaller, causing the shadow to move to the north, as shown in Figs. 7, 8 and 9. The positions of the pyranometers explain, at the same time, the variation in shade duration during the morning and afternoon hours, respectively. Placing pyranometer 1 (Fig. 15) on the eastern side of the greenhouse casts a longer shadow (80 min) in the afternoon since the sun is to its west and the shadow flows primarily parallel to the x-axis (north–south direction). On the contrary, its shading during the morning hours (30 min) is due to the length of the photovoltaic array. In the case of pyranometer 2 (Fig. 16), which is located on the west side of the greenhouse, the greatest duration in the shadow (80 min) is recorded in the morning, i.e. at sunrise, while the shortest (20 min) is recorded in the afternoon.

Regarding the radiation values at the intervals during which the pyranometers are inside the shaded surface, they present a relative consistency, as shown by the figures, with values ranging between 50 and 100 \(W/m^2\). However, points that are either within the above value range but outside the shading based on the algorithm, or outside the above value range but inside the shaded surface, are noticed. This is because, as stated in Sect. 2.9, the pyranometer values are the average values of the one-minute recorded data every ten minutes, as opposed to the algorithm results, which produce the shading every ten minutes. As a result, inserting the pyranometers into the shadowed surface at the end of the 10-minute time period results in an increased radiation value in the range of 50-100 \(W/m^2\), whereas removing the shadow from the pyranometer at the start of the 10-minute time period results in a decreased radiation value in the above range. In addition, it is probable that the shading from a large number of greenhouse skeletal elements coincides with the shading from the photovoltaics.

The slight change in irradiance, when the two pyranometers are shaded, was utilized to verify the model further. As mentioned in Sect. 2.9, the difference between the external radiation and the radiation recorded by the two pyranometers was determined for the whole period 05/08/2023–29/08/2023, in order to analyze the net radiation within the greenhouse. The Coefficient of Variation was then calculated for both the times when the pyranometers were in the shadow and the remainder of the time. In Figs. 17 and 18, the calculated CVs are presented for each of the fifty random data sets with points outside the shaded region, as well as the data set with points where the relevant pyranometer is shaded. The fifty different data sets for each day contain the same amount of data as the data set for the shaded area. At the same time, trends based on the mean value are provided for both the random and shaded data sets.

As seen in the graphs of Figs. 17 and 18, for both the first and second pyranometers, the trend of the coefficient of variation for time intervals under the shade is consistently lower than the trend for time intervals outside the shadow. This suggests that the change in irradiance is maintained at more stable levels and thus within shading, as opposed to time points where the change in irradiance is due on the one hand to absorption, scattering, or reflection from the greenhouse cover and on the other hand to individual shadings of the greenhouse’s skeletal elements, which are however of short duration.

More specifically, and regarding pyranometer 1, for 11 of the 25 days (44%) the experiment was run, the CV for the data set with shaded values is less than the 100% of the CVs corresponding to the random data sets obtained without shading, while for 19 of the 25 days (76%) the CV for the data set with shaded values is less than the 90% of the CVs corresponding to the random data sets obtained without shading. This percentage becomes minimal and equal to 74%, for just one day, i.e. thirteen of the fifty data sets where there was no shading, show greater uniformity, which is due to the existence of cloud cover on that particular day, but also the shading that came from the greenhouse gutter, as observed.

For pyranometer 2, the CV for the data set with shaded values is less than 100% of the CVs corresponding to the random data sets obtained without shading, for 10 of the 25 days (40%) of the study period, while for 21 of the 25 days (84%) the CV for the data set with shaded values is less than the 90% of the CVs corresponding to the random data sets obtained without shading. The minimum percentage, as in the previous case, corresponds to 82% with the corresponding days in which this occurs being 1 out of 25.

As a result of the foregoing and based on the uniformity of the radiation intensity on a shaded surface, it is determined that the algorithm produces satisfactory results; however, to establish the absolute accuracy of the results, a more extensive study of the radiation through experiments is required, which is also future work.

4 Discussion

Based on the above algorithm, the calculation of the shadow caused by photovoltaic modules, integrated into the south-inclined plane of two different and adjacent greenhouse units, was achieved. Although the PVs are semi-transparent, in this case, they were considered opaque to find the shadow, so the shading on the ground is caused by the whole module based on the algorithm. The relationships used to find the solar position in the sky, in combination with the use of up to two decimal places in the parameters, give the algorithm the possibility of highly accurate results. At the same time, the creation of tables, with rows and columns representing distances of one centimeter provides even greater precision in the results. This accuracy is demonstrated through the graphical representations of Figs. 13 and 14, where small, but at the same time, significant changes in the percentage of coverage of the greenhouse soil are presented, depending on the position of the sun for each different time of the year.

These results are presented the same for each year, since the movement of the sun is calculated from astronomical equations and theories, while the greenhouse unit and the photovoltaics positions are considered unchanged, both spatially and temporally. Therefore, the use of the algorithm could be done before the construction or installation of the photovoltaic modules based on the benefits or effects of shading for the respective crop.

Although the algorithm can be executed only once to produce the desired results, it is limited by some parameters. As mentioned, the creation of the tables is based on centimeters as a unit of measurement of dimensions. Therefore, for a greenhouse unit of large area, the size of the arrays will be extremely large resulting in covering a large amount of computing memory and increasing the execution time. However, the reduction of two decimal places to one or even none has a negative effect on the accuracy of the results, especially for small greenhouse units. At the same time, although the functions that concern the formation of the greenhouse, give the ability to work on any even-span greenhouse, the installation of the photovoltaics is limited to the way the photovoltaics have been placed in the specific greenhouse, i.e., with their long side being identified with the ridge of the greenhouse.

While the algorithm was developed using prior research and models for estimating and calculating shading from different objects, a significant outcome of this research is the calculation of shade caused by photovoltaics integrated into greenhouse roofs. Moreover, this research offers the possibility of determining the optimal placement of photovoltaics to meet the cultivation requirements, which further adds to its importance.

Regarding the validation of the model, due to the partial shade provided by the semi-transparent photovoltaics, an opaque cover was required to generate stronger shading. The specific experimental setup is consistent with the operation of the algorithm, which assumes the photovoltaic panels as opaque units. Because of the heavy shadowing produced, the two pyranometers within the greenhouse recorded a reasonably consistent intensity of radiation during the period that they were inside the surface shadowed by the photovoltaics.

The results of the algorithm were in relative consistency with the radiation values, while measurements that presented relatively small deviations were expected due to the operation of the pyranometers on the one hand, using the average value of the recordings for the 10-minute intervals, and on the other hand due to the operation of the algorithm, by extracting results exclusively for every ten minutes.

Due to the above, the coefficient of variation was calculated based on the fact of relatively constant radiation within the shaded surface, while its calculation for the change of radiation between external and internal, results in the study of the net radiation inside the greenhouse, removing any other influence of external factors. At the same time, generating a large number of data sets (50) for the non-shaded time points covers the entire data set for clearer results.

Finally, based on the trend of the coefficients of variation for the points inside and outside the shadow, it was observed that for the whole range of the time period under study, the time points for which both pyranometer 1 and pyranometer 2 are inside the shadow, give a more uniform distribution of net radiation for the time points that are in shadow based on the algorithm.

5 Conclusions

Greenhouses can be a highly sustainable solution, which is however held back by the high energy consumption that characterizes them. The solution of integrating photovoltaic units into the roof of the greenhouse gives the possibility for dual use of the land, both with the production of energy to cover the energy needs of the greenhouse itself, as well as with food production. The shading, however, caused by the photovoltaic modules has a catalytic effect on the microclimate and the crop, either positively or negatively, depending on the season and the type of crop.

In this study, an algorithm for the calculation of the shaded surface by photovoltaics within a greenhouse is presented. The algorithm is based on astronomical equations and theorems concerning the position and movement of the sun, on vector analysis and geometry to find the shadow, while it consists of five functions and four parts of code. The results extracted by the algorithm are the greenhouse shaded area, the percentage of the ground covered by shade, and two graphical representations of the greenhouse, photovoltaics, and shade, one three-dimensional and one two-dimensional, with the second showing essentially a top view of the first.

Based on the model validation findings, it is shown that the algorithm is able to determine the parts of the greenhouse shaded by the photovoltaics. More specifically, based on experimental radiation data and the use of the coefficient of variation, accurate detection of shading data with respect to pyranometer 1 was observed for 76% of the days from a studied period of 29 days, where the coefficient of variation for the shaded area was smaller than 90% of the coefficients of variation for data sets of the unshaded areas, demonstrating the expected uniformity of the irradiance of the shaded areas. The corresponding minimum rate observed is equal to 74% for a single day. At the same time, regarding pyranometer 2, the corresponding percentage of days for which an accurate detection of shading data was observed reaches 84%, with the minimum percentage observed being equal to 82% for a single day. Overall, and based on the trend of the coefficients of variation for both pyranometers 1 and 2, the coefficients of variation of the radiation change for the shaded areas are smaller for the entire period under study than the corresponding ones for the non-shaded areas, indicating uniformity of radiation under shading and thus its existence.

This algorithm could potentially be utilized in Agri-PV cultivations, as it was implemented based on the same principles, while it covers facts concerning the relationship between the two main pillars that define the concept of Agri-PV, that of photovoltaics and that of the crop affected by them. At the same time, although the algorithm, as originally designed, only concerns greenhouse units, it has the possibility of being extended to open crops as well, a possibility that is consistent with the wider framework of Agri-PV.

Simultaneously, a main point that characterizes the algorithm is the given potential to be a useful tool for the user who wishes to install photovoltaic modules in a greenhouse unit, proposing the optimal placement of the modules based on shading. One important aspect is to further validate and verify the algorithm based on solar radiation measurements and results from other scientific research. Future work concerns the limitations mentioned in the previous paragraph, by converting at least three parts of code (Part 1, 2, and 3) into functions for easier algorithm management, while a more detailed investigation of the radiation through tests is necessary to establish the absolute correctness of the data. Thus, the algorithm can extract results directly for any situation concerning the installation of photovoltaics, providing a strong analysis and decision-making tool for producers and the scientific community.

Editorial Policies for:

Springer journals and proceedings: https://www.springer.com/gp/editorial-policies

Nature Portfolio journals: https://www.nature.com/nature-research/editorial-policies

Scientific Reports: https://www.nature.com/srep/journal-policies/editorial-policies

BMC journals: https://www.biomedcentral.com/getpublished/editorial-policies