0% found this document useful (0 votes)
10 views

An Algorithm For Calculating The Shade Created by

Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
10 views

An Algorithm For Calculating The Shade Created by

Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 28

An Algorithm for Calculating the Shade Created by Greenhouse Integrated

Photovoltaics
Theodoros Petrakis
University of Patras: Panepistemio Patron
Vasileios Thomopoulos
University of Patras Polytechnic School: Panepistemio Patron Polytechnike Schole
Angeliki Kavga (  [email protected] )
University of Patras: Panepistemio Patron https://orcid.org/0000-0002-2914-3713
Athanassios A. Argiriou
University of Patras - Patras Campus: Panepistemio Patron

Research Article

Keywords: Shading, Photovoltaics, Greenhouses, Agrivoltaics, Algorithm

Posted Date: July 12th, 2023

DOI: https://doi.org/10.21203/rs.3.rs-3138189/v1

License:   This work is licensed under a Creative Commons Attribution 4.0 International License. Read Full License

Page 1/28
Abstract
The integration of photovoltaic modules into greenhouse roofs is a novel and intriguing method. Harnessing solar radiation is key to ensuring optimal crop
growth, as photosynthesis relies on it. Furthermore, capturing solar radiation by employing photovoltaic systems allows energy production. Given its
substantial significance in both energy generation and agriculture, this emphasizes the crucial function that solar radiation plays in these two industries.
Greenhouses offer a unique opportunity to optimize both plant growth and energy generation, thereby increasing their overall worth. This approach is
especially beneficial considering the growing need for land and the accompanying spatial and economic complexities. The installation of photovoltaics on the
greenhouse roof has a significant impact on shading, which can be advantageous or disadvantageous, depending on the season, the crop, and the growth
stage. As a result, estimating the shading in the greenhouse is imperative. In this paper, an algorithm for precisely measuring the shadowed surface area
generated by solar panels within a greenhouse was developed and presented. This method also reliably determines the percentage of coverage on the whole
greenhouse unit throughout the year using a time step of 10 minutes. For greenhouse operators wishing to optimize the potential of their solar panel
installations, this streamlined solution provides clear and persuasive statistics.

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℃, 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. Aside from
reducing the temperature, shading has been observed to present 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 Ming 2017; Yano and Cossu 2019).

Semi-transparent photovoltaic (PV) panels can provide shade for crops without negatively affecting their biological requirements. In fact, this 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 coverage 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 greenhouses with the benefits of either reducing the temperature to avoid overheating
especially in the summer months (reducing the temperature by 1℃ to 3℃ (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,
Page 2/28
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, and linear algebra to calculate the amount of shadow cast on a PV array or greenhouse (Arias-Rosales and
LeDuc 2022; 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. 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. 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. 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. 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.

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.

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 three sections 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 minutes
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.

Page 3/28
Table 1
Calendar basis and geographical criteria in the algorithm.
Variable Criterion MATLAB Code

Date/Time Days Day = [1:1:last day of month] if d < 1 || d > eomday(yr,mth)


error();

end

Hours Hour = [0:1:23] if hr < 0 || hr > 23

error();

end

Minutes Minutes = [0:10:50] if mnt~=[0:10:50]

error();

end

Seconds Seconds = 0 if sc ~ = 0
error();

end

Location Longitude Longitude = [0,360] if lon < 0 || lon > 360

error();
end

Latitude Latitude = [-90,90] if lat<-90 || lat > 90

error();

end

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 sections of the algorithm implemented concern the coordinates of the points that correspond to the 4 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 (Section 1), the
binary representation of the surface covered by the greenhouse, and the greenhouse’s ground surface shaded by the photovoltaics (Section 2), and finally the
calculation of the shaded area within the arable area of the greenhouse (Section 3). In Fig. 1, the order in which Functions and Sections appear in the
algorithm is presented.

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 campus of the University of Patras (38°17′27.9′′ N,
21°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.
Into the south-sloped level of the roof of each unit, a total of 12 photovoltaic modules have been integrated. The southern placement has been made for
greater energy production, 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, while 4 of them are on the roof of the unit next to it. 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. 2a), 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. 2b). Table 2 presents the characteristics of the
greenhouse construction units, as well as the dimensions of the photovoltaics. 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.

Page 4/28
Table 2
Greenhouse construction unit and PV modules characteristics.
Greenhouse construction unit characteristics Values

Orientation East – West

Number of construction units – widthwise 2

Number of construction units – lengthwise 0

Width 3.20 m

Length 16.39 m

Gutter height 3.22 m

Ridge height 3.90 m

Photovoltaic modules dimensions

Width 1.033 m

Length 2.048 m

2.1 Calculations for 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 (Marco and Giuseppe 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° to 180°. The angle can range between 90° and − 90° in mid-latitude locations and on
days less than 12 hours. However, on days longer than 12 hours, the angle may be more than 90° or less than − 90°, 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):

−1
SZA = cos [cos (ϕ) ∙ cos (δ) ∙ cos (ω) + sin (ϕ) ∙ sin (δ)]

∣ cos (SZA) ∙ sin (ϕ) − sin (δ) ∣


−1
SAA = sign (ω) ∙ ∣cos [ ]∣
∣ sin (SZA) ∙ cos (ϕ) ∣

where SZA is the solar zenith angle (°), SAA is the solar azimuth angle (°), φ is the latitude of the area under study (°, positive towards the Northern
Hemisphere), δ is the solar declination (rad), and ω is the solar hour angle (°). In this study, the SAA values used are based on the aforementioned second
system, where its zero value is taken to-ward 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° and 360°. The conversion of the SAA from system 1 to system 2 was achieved by adding to the first, value of 180°.

The calculation of the aforementioned angles (SZA & SAA) requires the calculation of additional parameters, such as the solar declination – δ, and the solar
hour angle – ω which are characterized by increased complexity due to the desired short timestep in the present study, which is equal to 10 minutes. Starting
with the calculation of the fractional year – γ – the expression of a given period into decimal format is achieved. The fractional year is calculated by Eq. 3:

2 ∙ π h − 12
γ = ∙ (N − 1 + )
365 24

where γ 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 – Et
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:

Et = 229.2 ∙ [0.000075 + 0.001868 ∙ cos (γ) − 0.032077 ∙ sin (γ) − 0.014615 ∙ cos (2 ∙ γ) − 0.04089 ∙ sin (2 ∙ γ)]

Page 5/28
where Et is the equation of time (min), and γ 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 seconds (Iqbal 1983). The solar declination – δ 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. δ takes values in a range of -23.45° to 23.45° and is calculated by Eq. 5 (Duffie et al. 2020):

δ = 0.006918 − 0.399912 ∙ cos (γ) + 0.070257 ∙ sin (γ) − 0.006758 ∙ cos (2 ∙ γ) + 0.000907 ∙ sin (2 ∙ γ) − 0.002697 ∙ cos (3 ∙ γ) + 0.0014

where δ is the solar declination (rad), and γ 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 minutes. The second adjustment comes from the equation of time. The TST is
given by Eq. 6:

T ST = LST + timeoffset

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

timeoffset = 4 ∙ (Lst − Lloc ) + Et

where Lst is the standard meridian for the local time zone, Lloc is the longitude of the lo-cation under study (both in degrees and positive west of the Prime
Meridian, so that 0⁰ < L < 360⁰), and Et is the equation of time given by Eq. 4. Lst 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 – ω. 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° 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):

T ST

ω = − 180
4

where TST is the true solar time (min).

Function 1 (SunPos) provides the main points of the solar position computation, according to Equations 1–8.

Function 1: Sun Position in Spherical Coordinates

function [SZA,SAA] =…

SunPos(yr,mth,d,hr,mnt,sc,l_loc,lat,timezone)

dt = datetime(yr,mth,d,hr,mnt,sc,l_loc,lat,timezone)

γ← Eq. 3

Et ← Eq. 4

δ← Eq. 5

ω← Equations 6–8

SZA ← Eq. 1

SAA ← Eq. 2

for k = 1:length(SAA)

if ω(k) > 0, SAA(k) = SAA(k);

elseif ω(k) < 0, SAA(k) = -SAA(k); end


end

end

Page 6/28
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,θ,φ), 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, θ is the polar angle or the solar zenith angle – SZA, and φ 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 Equations
9, 10, and 11.

xsun = r ∙ sin (SZA) ∙ cos (SAA)

y = r ∙ sin (SZA) ∙ sin (SAA)


sun

10

zsun = r ∙ sin (SZA)

11

where xsun, ysun, and zsun are the coordinates of the Sun’s position with respect to the x-, y-, and z-axis, respectively.

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 hyperbola), in a three-dimensional space, and is characterized by elements such as
the semimajor axis, α, 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.
Element Value

Eccentricity 0.01671

Perihelion distance 0.983 AU or 147,054,706,898 m

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

p
a =
1 − e

12

c = e ∙ a

13

2 2
b = √a − c

14

where a 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. 3) in a two-dimensional Cartesian coordinate system, and the Sun is on the foci 1 of the ellipse (point F1 in Fig. 3), 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). Eq. 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 Sun. At the same time, in Fig. 3, the position of the perihelion and the aphelion are presented by points P and A, respectively.

2 2
x y
+ = 1
2 2
a b

15
Page 7/28
x = a ∙ cos (t)

16

y = b ∙ sin (t)

17

2 2
r = √(x − c) + y

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 to 360°.

For the estimation of the angle t, it is considered that the Earth requires 365 days for a complete rotation of 360°, therefore for each day of the year, the Earth
traverses an angle equal to 0.986°, while for each 10-minute period, which is the desired time step in this study, this angle takes a value equal to 0.986°/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 F1E in Fig. 3) for every 10 minutes of the year is given by Eq. 18, which by substituting Equations 16 and 17 turns into Eq. 19.

2 2
0.986 0.986
′ ′ ′
r (t ) = √[a ∙ cos ( ∙ t ) − c] + [b ∙ sin ( ∙ t )]
144 144

19

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

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

Function 2: Earth-Sun distance

function r = EarthSunDist(yr,mth,d,hr,mnt,sc)

dt_year = datetime(yr,1,1,0,0,0):minutes(10):…

datetime(yr,12,31,23,50,0);

ten_min_idx =…

(1:1:find(dt_year = = datetime(yr,12,31,23,50,0)))’;

dt_inp = datetime(yr,mth,d,hr,mnt,sc);

ten_min = ten_min_idx(dt_inp = = dt_year);


p = 0.983*149597870700; % Perihelion in meters

a ← Eq. 12

c ← Eq. 13

b ← Eq. 14

r ← Eq. 19

end

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

Function 3: Spherical to Cartesian Coordinates

function [x_sun,y_sun,z_sun] = SunPosCart(r,SZA,SAA)

x_sun ← Eq. 9

y_sun ← Eq. 10

z_sun ← Eq. 11

x_sun((90 - SZA) < 0) = NaN;

y_sun((90 - SZA) < 0) = NaN;

z_sun((90 - SZA) < 0) = NaN;

end

Page 8/28
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.

Table 4
Inputs of greenhouse characteristics in Function 4.
Greenhouse Characteristics Function 4 inputs

Orientation dir

Number of construction units – widthwise numCU_wdwise

Number of construction units – lengthwise numCU_lnwise

Width grh_width

Length grh_length

Gutter height gut_hght

Ridge height ridge_hght

To begin with, it is necessary to define the reference point, based on which the greenhouse will be formed. This is regarded 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 widthwise 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) 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 which involve scenarios for the number of construction units with widthwise or lengthwise repetition.
More specifically, these cases describe:

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. One or more construction units lengthwise and none or one unit widthwise (Sub-case 2)

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

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.

Page 9/28
Table 5
Sub-cases for the number of construction units with widthwise or lengthwise repetition.
Sub-case Definition code “for loops” code

1 numCU_wdwise > 0 && (numCU_lnwise = = 0 || numCU_lnwise = = 1) for k = 0:numCU_wdwise-1

for l = 0

2 numCU_lnwise > 0 && (numCU_wdwise = = 0 || numCU_wdwise = = 1) for k = 0

for l=…

0:numCU_lnwise-1

3 numCU_wdwise > 1 && numCU_lnwise > 1 for k = 0:numCU_wdwise-1

for l=…

90:numCU_lnwise-1

Page 10/28
Function 4: Greenhouse coordinates in the Cartesian coordinate system

function grh_points =…

GreenhousCoord(dir,numCU_wdwise,numCU_lnwise,…

grh_width,grh_length,gut_hght,rigde_hght)

% limitation 1

assert(any(strcmp(dir,{'NS','EW'})),…

'Greenhouse direction must be either North-…

South or East-West')

% limitation 2

function validate_positive_integer_of_CU(direction,…

n9umCU)

if numCU < 0||abs(numCU-round(numCU)) > 0.0001,…


error('%s must be a positive integer',…

direction); end

end

validate_positive_integer_of_CU('Number of…

costrucion units',numCU_wdwise);

validate_positive_integer_of_CU('Number of…

construction units', numCU_lnwise);

if numCU_wdwise = = 0 && numCU_lnwise = = 0,…

error('Must define at least one construction…

unit.'); end

function grh_points = GrhXYZ(dir,k,l,grh_width,…

grh_length,gut_hght,rigde_hght)
grh_z_coord=[0,0,0,0,gut_hght,gut_hght,…

gut_hght,gut_hght,rigde_hght,rigde_hght]';

% Case 1

if dir=='EW'

grh_x_coord=[grh_width*k,grh_width*(k + 1),…

grh_width*k,grh_width*(k + 1),grh_width*k,…

grh_width*(k + 1),grh_width*k,…

grh_width*(k + 1),(grh_width/2)*(2*k + 1),…

(grh_width/2)*(2*k + 1)]';

grh_y_coord=[grh_length*l,grh_length*l,…

grh_length*(l + 1),grh_length*(l + 1),…

grh_length*l,grh_length*l,grh_length*l,…
grh_length*(l + 1),grh_length*(l + 1),…

grh_length*l,grh_length*(l + 1)]';

grh_points=…

table(grh_x_coord,grh_y_coord,grh_z_coord);

end

end

grh_points{l + 1,k + 1} ← Sub-Case 1

grh_points{l + 1,k + 1} ← Sub-Case 2

grh_points{l + 1,k + 1} ← Sub-Case 3

Page 11/28
Function 4: Greenhouse coordinates in the Cartesian coordinate system
end

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 (xPV,yPV,zPV), as well as the corresponding point of the sun's position
(xsun,ysun,zsun), as computed by Functions 1–3. In Section 1 of the algorithm (Calculation of PV Points) the points of the photovoltaic location are calculated
according to the Cartesian coordinate system.

Firstly, in Section 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.

Table 6
Limitations for the possible photovoltaic positions.
Limitation Definition code

1 if PV_width>(sqrt((rigde_hght-ut_hght).^2…
+ (grh_width).^2)) || PV_width < = 0,

error("The width of the PV Unit must be a…


positive integer and not exceed the…

length of the inclined plane of the…


roof"); end

2 if grh_length < numel(pos_PV(n))*PV_length,


error("The PV units exceed the limits of…

the greenhouse roof"); end

At the same time, in Section 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 be-tween 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
remains constant.

In Section 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.

Page 12/28
Section 1: Calculation of PV Points

pos_PV={pos_PV_CU_1,pos_PV_CU_2};
if grh_dir=='EW'

for i = 1:size(CU_tables,2)
for m = 1:size(CU_tables,1)

for j = pos_PV{m,i}
PV_x(:,j,i,m)=…

[(cosd(atand(2*(rigde_hght-gut_hght)/grh_width))*…
(sqrt(((rigde_hght-gut_hght).^2)+…

((grh_width.^2)/4))-PV_width))+(i-1)*grh_width,…
CU_tables{1,i}.x("Point 9"),…

(cosd(atand(2*(rigde_hght-gut_hght)/grh_width))*…
(sqrt(((rigde_hght-gut_hght).^2)+…
((grh_width.^2)/4))-PV_width))+(i-1)*grh_width,…

CU_tables{1,i}.x("Point 9")]’;
PV_y(:,j,i,m)=…

[PV_length*(j-1)+(m-1)*grh_length,…
PV_length*(j-1) + (m-1)*grh_length,…

PV_length*j + (m-1)*grh_length,…
PV_length*j + (m-1)*grh_length]';

PV_z(:,j,i,m)=…
[(sind(atand(2*(rigde_hght-gut_hght)/grh_width))*…

(sqrt(((rigde_hght-gut_hght).^2)+…
((grh_width.^2)/4))-PV_width)) + gut_hght,…

CU_tables{1,i}.z("Point 9"),…
(sind(atand(2*(rigde_hght-gut_hght)/grh_width))*…
(sqrt(((rigde_hght-gut_hght).^2)+…

((grh_width.^2)/4))-PV_width)) + gut_hght,…
CU_tables{1,i}.z("Point 9")]’;

PV_Points{:,j,i,m}=…
[PV_x(:,j,i,m),PV_y(:,j,i,m),PV_z(:,j,i,m)];

PV_Points {m,i}=PV_Points(:,:,i,m);
% PV visualization

X1{m,i}=PV_x_coord(:,:,i,m);
Y1{m,i}=PV_y_coord(:,:,i,m);

Z1{m,i}=PV_z_coord(:,:,i,m);
Xi{m,i}{j}=…
linspace(min(X1{m,i}{:,j}),max(X1{m,i}{:,j}),2);

Yi{m,i}{j}=…
linspace(min(Y1{m,i}{:,j}),max(Y1{m,i}{:,j}),2);

ZiX{m,i}{j}=…
linspace(min(Z1{m,i}{j}),max(Z1{m,i}{j}),2);

ZiY{m,i}{j}=…
linspace(min(Z1{m,i}{j}),max(Z1{m,i}{j}),2)';

[Xii{m,i}{j},Yii{m,i}{j}]=…

Page 13/28
Section 1: Calculation of PV Points
meshgrid(Xi{m,i}{j},Yi{m,i}{j});
Zii{m,i}{j}=meshgrid(ZiX{m,i}{j},ZiY{m,i}{j});
end

end
end

end
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):

−− − −−− → −−
−→ − −→ − −→
r sh.point,n = (xsh,n , y , zsh,n ) = [xn + k ∙ (xs − xn ) , y + k ∙ (y − y ) , zn + k ∙ (zs − zn )]
sh,n n s n

20

−−−−−−→ −−
−→ −−→ −−→
where rsh.point,n is the position vector of the shadow point produced by one of the four points of the PV, xsh,n , ysh,n , zsh,n are the position vectors of the
shadow point with respect to each axis of the three-dimensional coordinate system, xs, ys, and zs are the coordinates that define the position of the sun, xn, yn,
and zn, 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 (Equations 21, 22, and 23).

xsh,n (k) = xn + k ∙ (xs − xn )

21

y (k) = y + k ∙ (y − y )
sh,n n s n

22

zsh,n (k) = zn + k ∙ (zs − zn )

23

Solving the above system of equations and setting the z-coordinate (zsh) 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 (Equations
24 and 25, respectively).

xsh = y − cn ∙ zn
n

24

zn
y = xn −
sh
bn

25

where bn and cn are given by Equations 26 and 27, respectively.

zs − zn
bn = ( )
y − y
s n

26

xs − xn
cn = ( )
zs − zn

27

Function 5 (PVShadowPoint) provides the computations of the shadow points, according to Equations 24–27.

Page 14/28
Function 5: Calculation of the points that form the PV shade.

function [x_shd,y_shd]=…
PVShadowPoint(PV_x,PV_y,PV_z,x_sun,y_sun,z_sun)

b_n ← Eq. 26
c_n ← Eq. 27

x_shd ← Eq. 24
y_shd ← Eq. 25

end

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 greenhouse (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 Section 2 – Part A.

Section 2 – Part A: Binary analysis – Greenhouse representation

binary_array_CU_2 = false(int16(grh_length*100) + 1),…


int16 ((grh_width*numCU_wdwise*100) + 1));

CU_2_limits = [CU_arrays_points {1,2}(CU_bounds_2d,1),…


CU_arrays_points{1,2}(CU_bounds_2d,2)]*100;

CU_2_limits(:) = CU_2_limits(:) + 1;
binary_array_CU_2(CU_2_limits(1,2):CU_2_limits(3,2),…

CU_2_limits(1,1):CU_2_limits(3,1)) = 1;

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 Section 2 – Part B.

Page 15/28
Section 2 – Part B: Binary analysis – Shadow representation

if shading_limits(t,1) < = 0,shading_limits(t,1) = 1; end

if shading_limits(t,2) < = 0,shading_limits(t,2) = 1; end


if shading_limits(t,2) > = int16((grh_length*100) + 1),…

shading_limits(t,2) = int16((grh_length*100) + 1); end


if shading_corners(t,1)>=…
int16((grh_width*numCU_wdwise*100) + 1),…

shading_corners(t,1)=…
int16((grh_width*numCU_wdwise*100) + 1); end

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 Section 3 of the
code.

Section 3: Greenhouse-shaded surface

CU_2_grh_surface=…

length(find(binary_array_CU_2(:,:) = = 1));
shaded_surface = length(find(binary_array_CU_2(:,:) = = 1 &…
binary_array_shade(:,:) = = 1))/10.^4;

shaded_surface_perc=…
(shaded_surface.*10.^4/CU_2_grh_surface)*100;

*The multiplication by 104 is for the conversion of cm2 to m2.


2.7 Complete algorithm
As mentioned above, the algorithm consists of five distinct functions and three individual sections. To derive the result from the algorithm, as input values for
each sub-sequent function or section, 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 geo-graphical 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 (m2) that is covered by the shade of the photovoltaics within the greenhouse cultivation unit with a precision of two decimal points, the per-centage 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 below.

Page 16/28
Algorithm – PVShading

Data: yr, mth, d, hr, mnt, sc, timezone, dir, numCU_wdwise, numCU_lnwise, grh_width, grh_length, gut_hght, rigde_hght, l_loc, lat, PV_width, PV_length,
pos_PV_CU_1, pos_PV_CU_2

function [shaded_surface,shaded_surface_perc]=…

PVShading(data)
Function 1

Function 2
Function 3

Function 4
Section 1

Function 5
Section 2

Section 3
end

3 Results
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. Below, 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. The days chosen 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 time based on which the results are extracted is the local wintertime (UTC +
2).

Figures 4a and 4b 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 minutes. In Figs. 5a, 5b, and 5c, 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. 6.

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 minutes. These 144 positions for each of the aforementioned days are presented in Fig. 7, 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. 8a and 8b, 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 9, 10, and 11 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. 7 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. 11, 12, and 13, 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 Section 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.

Page 17/28
Table 7
Shadow area within the greenhouse northern construction unit and
percentage coverage for December 21, March 20, and June 21.
Case at 12:00:00 Shadow Area (m2) Percentage Coverage (%)

December 21 0 0

March 20 10.27 19.50

June 21 16.78 31.87

Figure 15 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. 11
and 14), 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. 10 and 13) 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. 4a) 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.

Finally, Fig. 16 shows the results of the algorithm throughout the days of the year 2022 with a time step of 10 minutes. The plot in Fig. 16 consists of 52,560
values (e.g., 365 days ∙ 24 hours ∙ 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. 16, 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.

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. 15 and 16, 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.

Page 18/28
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.

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 three sections. 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.

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 the three sections into functions for easier management of the algorithm. Thus, the algorithm will be able to 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.

Declarations
Author Contributions: Conceptualization, T.P.; methodology, T.P..; software, T.P.; validation, V.T. and A.K.; formal analysis, T.P. and V.T.; investigation, T.P., V.T. and
A.A.; resources, T.P.; data curation, T.P.; writing—original draft preparation, T.P. and V.T.; writing—review and editing, T.P., V.T., A.A. and A.K.; visualization, T.P.;
supervision, A.K.; project administration, A.K.; funding acquisition, A.K. All authors have read and agreed to the published version of the manuscript.

Funding: Open access funding provided by HEAL-Link Greece.

Institutional Review Board Statement: Not applicable.

Informed Consent Statement: Not applicable.

Data Availability Statement: The code developed during the study is available from the first author by request.

Acknowledgments: The present work was financially supported by the «Andreas Mentzelopoulos Foundation».

Conflicts of Interest: The authors declare no conflict of interest.

References
1. Aira J-R, Gallardo-Saavedra S, Eugenio-Gozalbo M, Alonso-Gómez V, Muñoz-García M-Á, Hernández-Callejo L (2021) Analysis of the Viability of a
Photovoltaic Greenhouse with Semi-Transparent Amorphous Silicon (a-Si) Glass. Agronomy 11(6):1097. https://doi.org/10.3390/agronomy11061097
2. Angmo P, Phuntsog N, Namgail D, Chaurasia OP, Stobdan T (2021) Effect of shading and high temperature amplitude in greenhouse on growth,
photosynthesis, yield and phenolic contents of tomato (Lycopersicum esculentum Mill). Physiol Mol Biology Plants 27(7):1539–1546.
https://doi.org/10.1007/s12298-021-01032-z
3. Andrés A-R, LeDuc PR (2022) Shadow modeling in urban environments for solar harvesting devices with freely defined positions and orientations.
164:112522–112522. https://doi.org/10.1016/j.rser.2022.112522
4. Barron-Gafford GA, Pavao-Zuckerman MA, Minor RL, Sutter LF, Barnett-Moreno I, Blackett DT, Thompson M, Dimond K, Gerlak AK, Nabhan GP, Macknick
JE (2019) Agrivoltaics provide mutual benefits across the food–energy–water nexus in drylands. Nat Sustain 2(9):848–855.
https://doi.org/10.1038/s41893-019-0364-5
5. Baxevanou C, Fidaros D, Katsoulas N, Mekeridis E, Varlamis C, Zachariadis A, Logothetidis S (2020) Simulation of Radiation and Crop Activity in a
Greenhouse Covered with Semitransparent Organic Photovoltaics. Appl Sci 10(7):2550. https://doi.org/10.3390/app10072550
6. Blando F, Gerardi C, Renna M, Castellano S, Serio F (2018) Characterisation of bioactive compounds in berries from plants grown under innovative
photovoltaic greenhouses. J Berry Res 8(1):55–69. https://doi.org/10.3233/jbr-170258

Page 19/28
7. Carlini M, Castellucci S, Mennuni A, Morelli S (2020) Numerical modeling​and simulation of pitched and curved-roof solar greenhouses provided with
internal heating systems for different ambient conditions. Energy Rep 6:146–154. https://doi.org/10.1016/j.egyr.2019.10.033
8. Cossu M, Ledda L, Urracci G, Sirigu A, Cossu A, Murgia L, Pazzona A, Yano A (2017) An algorithm for the calculation of the light distribution in
photovoltaic greenhouses. Sol Energy 141:38–48. https://doi.org/10.1016/j.solener.2016.11.024
9. Cossu M, Cossu A, Deligios PA, Ledda L, Li Z, Fatnassi H, Poncet C, Yano A (2018) Assessment and comparison of the solar radiation distribution inside
the main commercial photovoltaic greenhouse types in Europe. Renew Sustain Energy Rev 94:822–834. https://doi.org/10.1016/j.rser.2018.06.001
10. Cossu M, Yano A, Solinas S, Deligios PA, Tiloca MT, Cossu A, Ledda L (2020) Agricultural sustainability estimation of the European photovoltaic
greenhouses. Eur J Agron 118:126074. https://doi.org/10.1016/j.eja.2020.126074
11. ‌de Sá BA, Dezuo T, Ohf D (2022) Shadow Modelling Algorithm for Photovoltaic Systems: Extended Analysis and Simulation. J Control Autom Electr Syst
33:1507–1518. https://doi.org/10.1007/s40313-022-00905-2
12. Duffie JA, Beckman WA, Blair N (2020) Solar Radiation. In: Duffie JA, Beckman WA, Blair N (eds) Solar Engineering of Thermal Processes, Photovoltaics
and Wind, 5th edn. John Wiley & Sons, Inc, Hoboken, New Jersey, pp 3–44. https://doi.org/10.1002/9781118671603.ch1
13. Ezzaeri K, Fatnassi H, Wifaya A, Bazgaou A, Aharoune A, Poncet C, Bekkaoui A, Bouirden L (2020) Performance of Photovoltaic Canarian Greenhouse: A
Comparison Study between Summer and Winter Seasons. Sol Energy 198:275–282. https://doi.org/10.1016/j.solener.2020.01.057
14. Fernández-Ahumada LM, Ramírez-Faz J, López-Luque R, Varo-Martínez M, Moreno-García IM, de la Casares F (2020) A novel backtracking approach for
two-axis solar PV tracking plants. Renewable Energy 145:1214–1221. https://doi.org/10.1016/j.renene.2019.06.062
15. Hassanien RHE, Ming L (2017) Influences of greenhouse-integrated semi-transparent photovoltaics on microclimate and lettuce growth. Int J Agricultural
Biol Eng 10(6):11–22. https://doi.org/10.25165/j.ijabe.20171006.3407
16. Hassanien RHE, Li M, Yin F (2018) The integration of semi-transparent photovoltaics on greenhouse roof for energy and plant production. Renewable
Energy 121:377–388. https://doi.org/10.1016/j.renene.2018.01.044
17. Hemming S, de Zwart F, Elings A, Righini I, Petropoulou A (2019) Remote Control of Greenhouse Vegetable Production with Artificial Intelligence—
Greenhouse Climate, Irrigation, and Crop Production. Sensors 19(8):1807. https://doi.org/10.3390/s19081807
18. Isied RS, Mengi E, Zohdi TI (2022) A digital-twin framework for genomic-based optimization of an agrophotovoltaic greenhouse system. Proceedings of
the Royal Society A: Mathematical, Physical and Engineering Sciences, 478(2267). https://doi.org/10.1098/rspa.2022.0414
19. KAVGA A, TRYPANAGNOSTOPOULOS G, ZERVOUDAKIS, G., TRIPANAGNOSTOPOULOS Y (2018) Growth and Physiological Characteristics of Lettuce
(Lactuca sativa L.) and Rocket (Eruca sativa Mill.) Plants Cultivated under Photovoltaic Panels. Notulae Botanicae Horti Agrobotanici Cluj-Napoca
46(1):206–212. https://doi.org/10.15835/nbha46110846
20. Kim H-K, Lee S-Y, Kwon J-K, Kim Y-H (2022) Evaluating the Effect of Cover Materials on Greenhouse Microclimates and Thermal Performance. Agronomy
12(1):143. https://doi.org/10.3390/agronomy12010143
21. Kitta E, Katsoulas N (2020) Effect of shading on photosynthesis of greenhouse hydroponic cucumber crops. Italian J Agrometeorology 141–48.
https://doi.org/10.13128/ijam-871
22. ‌Krüger H, Grün E (2014) Dust in the Solar System. 657–682. https://doi.org/10.1016/b978-0-12-415845-0.00029-3
23. López-Díaz G, Carreño-Ortega Ángel, Fatnassi H, Poncet C, Díaz-Pérez M (2020) The Effect of Different Levels of Shading in a Photovoltaic Greenhouse
with a North–South Orientation. 10(3):882–882. https://doi.org/10.3390/app10030882
24. Ma D-D, Carpenter NR, Maki H, Rehman TU, Tuinstra MR, Jin J (2019) Greenhouse environment modeling and simulation for microclimate control.
Comput Electron Agric 162:134–142. https://doi.org/10.1016/j.compag.2019.04.013
25. Moretti S, Marucci A (2019) A Photovoltaic Greenhouse with Variable Shading for the Optimization of Agricultural and Energy Production. Energies
12(13):2589. https://doi.org/10.3390/en12132589
26. Pälike H (2005) EARTH | Orbital Variation (Including Milankovitch Cycles). In: Selley RC, Cocks R, Plmer IR (eds) Encyclopedia of Geology. Elsevier,
Amsterdam, Netherlands, pp 410–421. https://doi.org/10.1016/b0-12-369396-9/00123-4
27. Rosa-Clot M, Tina GM (2018) Photovoltaic Electricity. Submerged and Floating Photovoltaic Systems, 13–32. https://doi.org/10.1016/b978-0-12-812149-
8.00002-8
28. Salgado-Conrado L, Lopez-Montelongo A, Álvarez-Macías C, Hernández I (2022) Review of Heliodon Developments and Computational Tools for Building
Shadow Analysis. 12(5), 627–627. https://doi.org/10.3390/buildings12050627
29. Shin J, Hwang I, Kim D, Moon T, Kim J, Kang WH, Son JE (2021) Evaluation of the light profile and carbon assimilation of tomato plants in greenhouses
with respect to film diffuseness and regional solar radiation using ray-tracing simulation. Agric For Meteorol 296:108219.
https://doi.org/10.1016/j.agrformet.2020.108219
30. Spencer JW (1971) Fourier series representation of the position of the sun. Search 2:162–172
31. Sun W, Wei X, Zhou B, Lu C, Guo W (2022) Greenhouse heating by energy transfer between greenhouses: System design and implementation. Appl Energy
325:119815. https://doi.org/10.1016/j.apenergy.2022.119815
32. Tang Y, Ma X, Li M, Wang Y (2020) The effect of temperature and light on strawberry production in a solar greenhouse. Sol Energy 195:318–328.
https://doi.org/10.1016/j.solener.2019.11.070
33. Trommsdorff M, Kang J, Reise C, Schindele S, Bopp G, Ehmann A, Weselek A, Högy P, Obergfell T (2021) Combining food and energy production: Design
of an agrivoltaic system applied in arable and vegetable farming in Germany. Renew Sustain Energy Rev 140:110694.
https://doi.org/10.1016/j.rser.2020.110694

Page 20/28
34. Waller R, Kacira M, Magadley E, Teitel M, Yehia I (2021) Semi-Transparent Organic Photovoltaics Applied as Greenhouse Shade for Spring and Summer
Tomato Production in Arid Climate. Agronomy 11(6):1152. https://doi.org/10.3390/agronomy11061152
35. Waller R, Kacira M, Magadley E, Teitel M, Yehia I (2022) Evaluating the Performance of Flexible, Semi-Transparent Large-Area Organic Photovoltaic Arrays
Deployed on a Greenhouse. AgriEngineering 4(4):969–992. https://doi.org/10.3390/agriengineering4040062
36. Wang Z (2019) The Solar Resource and Meteorological Parameters. Design of Solar Thermal Power Plants. Academic Press, London, England, pp 47–
115. https://doi.org/10.1016/B978-0-12-815613-1.00002-X
37. ‌Xu G, Xu J (2013) Keplerian Orbits. In: Orbits, 2nd ed. Springer, Berlin, Heidelberg 2013; pp. 27–38. https://doi.org/10.1007/978-3-642-32793-3_3
38. ‌Yano A, Cossu M (2019) Energy sustainable greenhouse crop cultivation using photovoltaic technologies. Renew Sustain Energy Rev 109:116–137.
https://doi.org/10.1016/j.rser.2019.04.026

Figures

Figure 1

The sequence of functions and modules on which the algorithm is executed.

Page 21/28
Figure 2

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.

Figure 3

Earth's elliptical orbit around the Sun.

Page 22/28
Figure 4

Sun position in spherical coordinates for December 21, March 20, and June 21: (a) Solar Zenith Angle (°), and (b) Solar Azimuth Angle (°).

Figure 5

Earth-Sun distance: (a) for December 21, (b) for March 20, and (c) for June 21.

Page 23/28
Figure 6

Earth-Sun distance for the entire year of 2022.

Figure 7

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

Page 24/28
Figure 8

Greenhouse points for (a) the southern and (b) the northern construction unit.

Figure 9

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

Page 25/28
Figure 10

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

Figure 11

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

Figure 12

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

Page 26/28
Figure 13

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

Figure 14

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

Figure 15

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

Page 27/28
Figure 16

Annual percentage of shade coverage.

Page 28/28

You might also like