# Module Shading

SolarFarmer has two models for calculating the near shading - a simple sheds model that considers row-to-row shading as if the rows are infinitely long and an advanced model that takes into account all objects that cause near shading, including 3D shading objects.

## Simple model

The model is based on the infinite sheds model in PVsyst. This was adjusted slightly so support system azimuths not pointing directly south/north and sites located in both hemispheres.

### Beam shading

We can compute the projected sun shade angle as:

$$\tan \phi = \frac{\cos\left( \gamma_\text{s} - \gamma \right) \sin \theta_\text{z}}{\cos\theta_\text{z}}$$

The position of the shade line measured from the bottom of the rack relative to the total height of the rack is

$$F_{x} = \max\left( 0, \min \left( 1 - \frac{1}{\GCR \left( \cos\beta - \sin\beta \tan\phi \right)}, 1 \right) \right)$$

This is equivalent to the proportion of the rack that is shaded from the direct irradiance.

The absolute height of the shade line, \(H_\text{s}\) measured from the bottom of the rack is given as follows:

$$H_\text{s} = F_{x} H$$

Where \(H\) is the height of the rack in meters.

### Sky Diffuse Shading

Given *some point located a distance* \(H_x\) from the bottom edge of one row (the "current" row), the angle
to the top of the row immediately ahead of the current row (toward the equator) may be denoted as
\(\psi_\text{t}\). This angle may be computed as (\(P\) is the pitch in the layout region):

$$\tan\psi_\text{t}(H_x) = \frac{ \left(H - H_x \right) \sin \beta}{ \left(H - H_x \right) \cos \beta - P}$$

Integrating a constant (isotropic irradiance) over a slice of a sphere from \(\psi_\text{t} - \beta\) to \(\pi - \beta\), we get a shading factor

$$F_\text{sky,dif,t} \left( H_x \right) = \frac{1 - \cos \left( \psi_\text{t} \left( H_x \right) - \beta \right)} {1 - \cos \left( \pi - \beta \right)}$$

If we consider the \(F_\text{sky,dif,t}\) shading be roughly linear between 0 and \(H_\text{s}\) for the
diffuse-only area, then we can simply take the mean of the shading factors at the top and bottom of the shaded
strip as an estimate for the *shaded strip*:

$$F_\text{sky,dif,s} = \left( F_\text{sky,dif,t} \left( H_\text{s} \right) + F_\text{sky,dif,t} \left( 0 \right) \right) / {2}$$

Similarly, for the unshaded strip from \(H_\text{s}\) and \(H\), we can take the mean of the shading factors
at the top and bottom of the unshaded strip as an estimate for the whole *unshaded strip*:

$$F_\text{sky,dif,u} = \left( 1 + F_\text{sky,dif,t}\left( H_\text{s} \right) \right)/2$$

The overall shading factor for the sky diffuse irradiance is then simply the average of the factors for the shaded and unshaded strip. This is assumed for all the racks in a layout region that are not in a front row.

$$F_\text{sky,dif} = \left( F_\text{sky,dif,u} + F_\text{sky,dif,s} \right)/2$$

### Ground diffuse shading

The irradiance in the plane of array coming reflected from the ground can be simplistically calculated as: $$G_\text{r,poa} = \frac{1}{2} \rho G_\text{h} \left(1 - \cos \left( \beta \right)\right)$$ Shading reduces this irradiance, firstly by reducing the light that reaches the ground from the sky, and secondly through obscuration, blocking the modules from viewing the ground.

#### Ground Shading

Both the beam and the diffuse irradiance from the sky are impacted by shading from the modules.

We include the beam shading by considering the fraction of ground that is illuminated (unshaded). We do not take into account the location of the shaded and unshaded strips and their respective view angles from the module surface. We are applying the effect of beam shading as if it were averaged out over the ground.

The shading factor for the beam shading of the ground is calculated as:

$$F_\text{gnd,illum} = 1 - \min\left( 1, \GCR \ \left| \cos \beta - \sin \beta \tan \phi \right| \ \right)$$

*Note: Left and right vertical bars around \( \left| \cos \beta - \sin \beta \tan \phi \right| \)
indicate the absolute value which is always positive.*

This shading factor is applied to the fraction of \(G_\text{h}\) that is from direct irradiance.

Separately we calculate a shading factor for the diffuse part of the irradiance onto the ground. Again we consider the ground irradiance as an average, without considering how it varies between the racks. The average diffuse irradiance arriving on the ground is simply the total diffuse horizontal irradiance, \(G_{\text{dif}}\), minus the sky diffuse irradiance that lands on the module surfaces.

$$G_\text{gnd,dif} = G_{\text{dif}} - \frac{H}{P} \left(F_\text{sky,dif}G_\text{dif,poa} + F_\text{sky,dif,b}G_\text{dif,poa,b}\right)$$

Where \(\frac{H}{P}\) is included to account for the height of the rows of modules relative to the total irradiance arriving over the pitch between rows, \(F_\text{sky,dif}\) is the shading factor for sky diffuse as described above, and \(G_\text{dif,poa,b}\) is included to account for sky diffuse irradiance that is captured by the back-side of the modules.

We use the simple diffuse transposition model in this case to derive the sky diffuse irradiance in the plane of array. $$G_\text{dif,poa} = \frac{1 - cos \beta}{2}G_\text{dif}$$

So the shade factor for the sky diffuse arriving on the ground is calculated as: $$F_\text{gnd,dif} = 1 - \frac{H}{P} \left(F_\text{sky,dif}\frac{1 - cos \beta}{2} + F_\text{sky,dif,b}\frac{1 - cos\left(\beta + \pi\right))}{2}\right)$$

We combine the two shading factors, for the beam shading and for the diffuse shading, as a weighted average, by using the diffuse fraction, \(\text{df} = \frac{G_\text{dif}}{G_\text{h}}\). The diffuse shading factor is weighted by \(\text{df}\), and the beam shading factor by \(1 - \text{df}\). $$F_\text{gnd} = \text{df} \cdot F_\text{gnd,dif} + \left(1 - \text{df}\right) F_\text{gnd,illum}$$

#### Ground Obscuration

Looking toward the horizon from the top of the row, the row ahead obscures some of the diffuse irradiance reflection of irradiance off the ground. Viewed from the bottom of the row, the rows ahead only affect ground diffuse by shading of the ground as discussed in the previous section (the row ahead only obscures sky irradiance at that point).

At the top edge of the current row, some fraction of the ground is obscured by the row ahead. Returning to the point located a distance of \(H_x\) from the bottom edge of one row (the "current" row), the angle to the bottom of the row immediately ahead of the current row (toward the equator) may be denoted as \(\psi_\text{b}\). This angle may be computed using:

$$\tan\psi_\text{b} \left( H_x \right) = \frac{-H_x \sin \beta}{ - \left( P + H_x \cos \beta \right)}$$

Integrating a constant (isotropic irradiance) resolved by cosine of incidence angle over a slice of a hemisphere of visible directions (the slice from \(\psi_\text{b} - \beta\) to \(\pi\) is not blocked within the slice from \(\pi - \beta\) to \(\pi\)) we get a shading factor for the ground (reflected) diffuse irradiance,

$$F_\text{gnd,dif,b} \left( H_x \right) = \frac{1 + \cos \left( \psi_\text{b} \left( H_x \right) - \beta \right)} {1 + \cos \left( \pi - \beta \right)}$$

The shading factor for the diffuse from the ground reaching the *shaded strip* on the row is:

$$F_\text{gnd,dif,s} = \left( F_\text{gnd,illum} \left( 1 - \delta f \right) + \delta f \right) \left( F_\text{gnd,dif,b} \left( H_\text{s} \right) + 1 \right)/2$$

where \(\delta f\) is the (horizontal) diffuse fraction, \(\delta f = \frac{\DHI}{\GHI}\).

The shading factor for the diffuse from the ground reaching the *unshaded strip* on the row is:

$$F_\text{gnd,dif,u} = \left( F_\text{gnd,illum} \left( 1 - \delta f \right) + \delta f \right) \left( F_\text{gnd,dif,b} \left( H_\text{s} \right) + F_\text{gnd,dif,b} \left( H \right) \right)/2$$

The overall shading factor for the sky diffuse irradiance is then simply the average of the factors for the shaded and unshaded strip. This is assumed for all the racks in a layout region that are not in a front row.

$$F_\text{gnd,dif} = \left( F_\text{gnd,dif,u} + F_\text{gnd,dif,s} \right)/2$$

## Full shading model

The model is based on a hemicube model, where the shading scene (horizon, terrain, racks, shading obstacles) is rendered for each shading target point on the modules.

The sky, horizon, terrain and shading objects (racks or 3D shading obstacles) are rendered to determine beam shading as well as shading for the sky and ground diffuse irradiance. As the hemicube model does not consider how much of the ground is shaded by racks in front, the method from the simple sheds model is used to adjust the ground diffuse shading. Full details, illustrations and validation results of the hemicube model can be found in [27].

### Precalculations

The following are calculated once after any changes to the layout or surroundings:

horizon lines for each target point in the array

% diffuse shading factor for each target point, then average across each submodule.

### At each timestep

For each target point, first check if sun is below horizon, then check if target can see the sun. If the target is shaded, then the beam irradiance incident around the target is zero.

For each submodule SolarFarmer calculates the percent of the area shaded based on number of shaded target points. When positioning target points for the shading calculation, the inactive border of each module should be considered, i.e. position points in the active area only. Then SolarFarmer determines the percent shading of the most shaded cell in each submodule for Module Performance Model.