Estimating the daily solar irradiation on building roofs and facades using Blender Cycles path tracing algorithm

The paper presents the development of an daily solar irradiation algorithm with application of the free software Blender. Considerable attention was paid to the possibilities of simulation of reflections of direct and diffuse solar radiation. For this purpose, the rendering algorithm "Cycles" was used, based on the principle of bi-directional path tracing – tracing random paths of light beams. The value of global radiation in this study is the sum of four components: direct beam radiation, reflected beam radiation, diffuse radiation and reflected diffuse radiation. The developed algorithm allows calculation of solar irradiation for all elements of the 3D model created in Blender, or imported from an external source. One minute is the highest possible time resolution of the analysis, while the accuracy is dependent on the resolution of textures defined for each element of a 3D object. The analysed data is stored in the form of textures that in the algorithm are converted to the value of solar radiance. The result of the analysis is visualization, which shows the distribution of daily solar irradiation on all defined elements of the


Introduction
When assessing the possibilities of solar energy gain, the most frequently used are the analyses of twodimensional space.Analysis of data in urban areas takes into consideration horizontal and sloping surfaces of roofs.This is due to the easy application of solar cells, and a large amount of energy which can be obtained.Looking at big cities, the surface of walls of tall buildings is much bigger than the roof surface.For this reason, the information about the amount of energy received by the building walls is very valuable.From year to year, the possibility of the non-invasive obtaining energy from the walls of buildings is increasing, through the application of transparent photovoltaic cells [1,2].Identification of the best mounting locations of this type of cells requires knowledge of the distribution of exposure to the solar irradiation on the whole surface of the building.
Performing the solar irradiation analysis for surfaces of a given orientation and inclination is relatively simple.In the three-dimensional environment one must take into account shading of the source of illumination by individual objects of the city infrastructure, which complicates the analysis.Calculations of even greater complexity must be performed if we plan to take into account the effect of sunlight reflections of individual objects.Reflections are of great importance in urban areas with many tall buildings covered with a reflective material (glass, smooth concrete).In this case sun beams (although severely weakened by a small value of reflections) can frequently appear in most unexpected places.This also creates the risk of accumulation of a large amount of solar radiation in one place.Especially dangerous effects can be caused by buildings having the shape which focuses the reflected sun beams.An example of such a threat is the building at 20 Fenchurch Street, "Walkie-Talkie," which led to melting of the plastic body of a Jaguar [3].
In the case of 2D analyses, the analysis is based on the input data in the form of GRID raster.In addition to the x and y data representing the position of the individual elements, we have additional data on the height of the element, stored in the form of pixel values.Analysing the solar irradiation, we can see the result in 3D thanks to the projection, whereas the correct data is only on flat and sloping elements.The increasing gradient of the surface results in inaccuracies, vertical surfaces along their entire length are represented by individual pixels.Raster data analysis can be performed in commercial programmes, e.g.ArcGIS [4] or open source, e.g.GRASS GIS [5].In both cases, the input data is a raster with geographic mapping.
Analyses in 2D have serious limitations.They cannot be used to perform analysis of solar irradiation of vertical walls and surfaces.Therefore, there is a considerable interest in applications which use full 3D data.The most popular include Ecotect Analysis 2011 Daysim and Diva for Rhiano [6,7].All the applications use full 3D data in the form of a mesh.After finishing the analysis, we have access to the results in the form of a 3D model visualization.In addition to commercial solutions, there are also original analyses of the solar irradiation, e.g.SOL algorithm to perform the analysis using data acquired with LIDAR [8].

Methodology
This article presents the method of calculating the solar irradiation in a dense urban area by means of an algorithm called by the author "Blend-Sun".One of the main principles of the algorithm is considering the influence of reflection and diffusing of light by buildings which can be made of different materials.The whole analyses will be carried out in a full threedimensional environment.
Modelling the natural and artificial lighting is one of the main factors shaping the image in computer graphics.In rendering (creating the photorealistic image presenting the projection of a 3D model), advanced algorithms can trace millions of individual light beams in order to determine the colour of a particular pixel in the final image.Since the algorithm can simulate the lighting of the virtual world, it can be used to calculate the solar irradiation of individual parts of a 3D model.
The greatest opportunities useful when developing an algorithm of the sunlight exposure can be provided by the open source Blender, with the integrated rendering algorithm called Cycles.It allows creating own scripts using Python 3.4.The algorithm calculating the light distribution is based on the method of Bi-directional path tracing [9], which analyses random paths of light beams.Path tracing is a computer graphics Monte Carlo method of rendering images of three-dimensional scenes such that the global illumination is faithful to reality.With appropriate number of paths (samples), we receive light distribution pattern comparable to that found in the real world.
The selected software has a great advantage over other applications of this type, allowing easy way to obtain information about render lighting of all objects in the virtual world.In Blender there is an option named "bake", used to store data from the rendering engine directly in the texture maps in the form of images, related to the analysed 3D model.The textures related to the object are realized by means of the UV map [10], through which each pixel of the texture has its own stable position on a 3D object.The use of textures as a container for data on the solar radiation also allows any modification of the resolution analysis without dividing the input shape of objects.We can determine that one pixel of the texture reflect any size unit on the model (e.g.meter, centimetre).
In the analysis of solar irradiation it is necessary to use direct and indirect sunlight.This paper will describe how to obtain the data for the two light sources.The reflected light will be modelled by the program algorithm.
Rendering in Blender allows saving the components of the lighting in empty or defined texture maps laid on the objects.Some of these components are "shadow", direct illumination intensity -"diffuse direct" and reflected -"diffuse indirect".After rendering the image is created with the selected data type in a black-and-white scale.The image can be converted into a matrix representing the pixel value in numerical form, which makes it possible to further analyse the data.
In the presented method of obtaining data on the solar irradiation, the individual components of global radiation were divided into four separate parts: direct beam radiation, reflect beam radiation, diffuse radiation and reflect diffuse radiation.

Materials
For the accurate simulation, on all the objects materials representing the surface properties which they can be produced in the real world.The main materials include light-diffusing (diffuse BSDF (Bidirectional Scattering Distribution Function)), mirror-like light-reflecting (Glossy BSDF) and transparent (Transparent BSDF).In the program there is a possibility of defining other materials, but they will be omitted due to the lack of, or a very little effect on the results of the analysis.
Materials such as Glossy and Diffuse affect the formation of light reflections, Transparent material has an impact on the intensity of the resulting shadows.Each material can be combined with another one.It is thus possible to simulate a glass material which reflects light in a specific quantity, but also allows the sun beams to pass through the material with a reduced energy.An example of how different materials behave can be seen in Figure 1.The information on lighting was collected for the horizontal surface, while the vertical surface has a defined material, the angle of incidence of the light beam is 45' for both surfaces.In parts (A) and (B), we can see two different types of light reflections, diffused and mirror-reflected.In parts (C) and (D), we can see two different types of shadows, complete and partial.
The materials allow the control of the albedo values of individual objects.The perfect white material defines the full, one-hundred-percent reflection of light, whereas the perfect black material simulates the full absorption of light and lack of its reflection

Direct and reflect beam radiation
The value of direct beam radiation for a given moment can be calculated with the method described by [11].The result represents the theoretical value of the energy carried by the direct sun beam, assuming a standard clear sky day at a specific time.To calculate the value of the solar beam radiation, one should take into account the angle of incidence of the beam on the analysed surface, its shading and reflections.These components can be determined using the virtual light source named "Sun", defined in Blender, acting as the natural sun.It sends parallel beams, whose direction is determined by the vector.Knowing the altitude and azimuth of the natural sun, we will automatically have the vector needed to define the correct direction of the beam in the virtual 3D environment.The altitude and azimuth of the sunshine can be calculated using the algorithm specified by [12], along with the correction NOAA atmospheric refraction [13], the input data is the coordinates of the place of the analysis and the date.The algorithm allows calculation of the position of the sun for the set date with a minute accuracy.
The sun vector is needed to determine the angle of incidence of the light beams on the analysed model surface.This angle (in equation used Ai symbol) can be defined as the angle of intersection of the vector of light -"Sun" and the normal vector of the surface (the direction perpendicular to the surface which in Blender is given as the information describing the single surface).With the knowledge of the angle of incidence of sunlight on the surface, we can easily reduce the calculated value of beam radiation (Eqs.1), dbr denotes direct beam radiation calculated with the method described by [11].

direct beam radiation = x*direct beam radiation' (2)
The last part is the analysis of reflections of the direct beam radiation.For this purpose a diffuse indirect texture map generated in Blender function was used.Depending on the location of the adjacent 3D objects and their materials, distribution of light reflections in the form of texture map was obtained (e.g.Fig. 1A and 1B).The pixel values will be from 1 (the maximum intensity reflection) to 0 in the absence of incidence of the reflected light.Several measurements in the application indicate that pixels with a value of 0.6 correspond to the incidence of light of one-hundredpercent intensity (when the beam is perpendicular to the surface).Measurement was made using two parallel planes.One of them pass up the rays of light and was used to retrieve the value of reflection.
The second reflected rays completely.Analysing the individual degrees of reflection of light beam "Sun", it was found that the pixel value and the percentage of reflection do not change linearly (e.g.Fig. 2), but they can be approximately described by a third degree polynomial.It is caused by the properties of the Cycles rendering engine.The texture with the pixel values corresponding to the degree of the light reflection can be converted into the reflected solar beam radiation value using the following equation (Eqs.3), where x is the colour value of the pixel of the image in question, rbr is abbreviation the reflected beam radiation:

Isotropic diffuse radiation
Another component of the global solar radiation is the radiation diffused by the atmosphere.For the horizontal unshaded surface, the theoretical value of clear-sky diffuse radiation can be estimated from the relationship described by [14].The inclusion of shading and different inclination and orientation of the surface can be done with the lighting named "sky" available in Blender.The shades generated by the lighting are soft, the light comes from the virtual sphere surrounding the objects.Shading is stronger when the light source "sky" becomes less visible.As with the direct beam radiation, we can consider not only the direct light but also that reflected.
With direct diffuse radiation we generate the 'bake diffuse direct' texture.Measurements determined that the value of the pixel 0.737 corresponds to 100-percent visibility of the light "sky", while the value of 0 means the total shading.Measurement was made for not shaded plane with light "sky".Multiplying the pixel values by a given value of diffuse radiation, we get the value reduced by the amount of energy that reaches the surface in question (Eqs.4), dr denotes diffuse radiation calculated with the method described by [13], x are pixel value.
diffuse radiation = dr * (x / 0.737) (4) The reflection analysis was performed on the diffuse indirect texture map created after rendering in Blender.Depending on the location of objects and their materials we can obtain the image presenting the distribution of reflections.The same as with direct beam radiation, the value of 0.737 corresponds to the incidence of the reflected light with the 100-percent intensity.The value of reflect diffuse radiation is calculated using the above equation (Eqs.4).In this case, the colour of pixels changes linearly with respect to the value of reflection.
The final value of diffuse radiation is the sum of the direct and reflected diffuse radiation values.

Global solar radiation
In the presented algorithm, the global solar radiation is composed of four values calculated separately and then added up in order to determine the final value.The algorithm flow chart for one point in time is shown in Figure 3.To analyse the solar irradiation for a certain period of time we must choose the step of the calculation.In the above solution, the step of the calculation can be adopted with the accuracy of one minute, which is also the smallest possible step, and the time range of the analysis.
In the presented solution, theoretical calculation of values for beam radiation and clear-sky diffuse radiation was used.They can be replaced by other values, e.g., derived from long-term observations (meteorological year data).

Results
To test the algorithm of the solar irradiation exemplary models representing buildings and a section of terrain were used.They were made by the author.The individual buildings had a material added that simulates the albedo value reflection of 0.35, which roughly corresponds to concrete materials.One model building (number 1 in Figure 5E) was defined with a material imitating glass surfaces with the value of reflectance of 20%.The ground surface was defined with a material with the albedo value of 0.35, corresponding approximately to cobblestones.The location of the analysis was central Warsaw (52.232728N, 21.004202E).The test models can be seen in Figure 5E.Resolution of the analysis was 2 x 2 m.
First tested was the algorithm in the analysis of the total daily solar irradiation for the direct beam radiation value on 1st May without considering reflections.The result of the analysis can be seen on the visualization (e.g.Fig. 4A).For the calculation the time interval was set for 15 minutes.A pixel of the generated textures corresponds to the surface of 2 x 2 m on the model.The maximum total value of direct solar irradiation is 4978 Wh/m2.
Another component is the diffused solar irradiation.The result of the analysis is presented in the Figure 4B.In this case, the maximum total value is 1180 Wh/m2.Visible is the impact of the individual buildings on the level of obstruction, sky dome and thereby reducing the clear sky radiation.
The reflected beam radiation component is a more advanced simulation made on the basis of the Bidirectional path tracing algorithm programmed in Cycles.The result of this analysis can be seen in Figure 4C.
The greatest impact on the accumulation of the reflected energy is from the building with the reflective material (glass).The maximum observed total value of energy is about 710 Wh/m2.
The last considered component is the analysis of diffuse radiation reflection (e. g.Fig. 5D).In this case also the biggest influence on the result of the analysis is from the building with the reflective material (glass).The observed value of the reflected energy has the least impact on the result of the analysis, and it does not exceed 191Wh.By adding up the individual values of solar irradiation we receive the complete finish result (e.g.Fig. 5F).The distinct shadows of the buildings reflect the adopted large time interval of 1 h.The maximum daily solar irradiation value observed was 6223 Wh/m2.There were additional tests done on three days: 21st June -the day of summer solstice, 20th March -the day of spring equinoxes, and 22nd December -the day of winter solstice (e.g.Fig. 6).The values of solar radiation were analysed separately for each surface of the building.On 21st June, the highest values of solar radiation were measured on roof surfaces, the lowest on the surfaces with a northern exposure.On this day, the reflections of solar radiation are also the highest.On 20th March the highest values of solar radiation were on surfaces with a southern exposure and roof surfaces.On 22nd December the highest values of solar radiation were on surfaces with a southern exposure.In all other exposures they stay at a very low level.Reflections of solar radiation are also very low.
In addition to the solar irradiation test conducted for the regular buildings, the author checked the application of the algorithm for buildings focusing the reflected light.Figure 7 presents the analysis of solar energy reflections on the building 'Walkie-Talkie'.The model building was obtained from [15].Due to the fact that the actual reflection factor is unknown, in the example a material reflecting the sun beams in 15 percent was used.During the analysis the geographical location of the building was taken into account (51.511103N, 0.083567W); the analysis was made for the longest day in the year, i.e.June 21st .In the absence of data, the adjacent buildings around were not taken into account.The results indicates there are areas which have a higher energy balance than others.In order to eliminate the problem, the building it can be covered with an anti-reflective coating limiting the reflection of sun beams.No annual analyses of solar irradiation were conducted, as the presented solution is based on the assumption of a clear sky day.

Discussion
Looking at the results it can be seen that the analysis of solar irradiation using Blender has considerable potential.Applying different materials we can freely model the analysed area.The particularly unique option is analysis of the reflections of light beams.It allows finding areas with elevated energy balance, which can be used for various purposes, from the design of solar energy generation systems to forecasting risks arising from the accumulation of energy.The evidence can be the result of the simulation for the building 'Walkie-Talkie', which shows the potential risks generated by the building (e.g.Fig. 7).When reflections are taken into consideration in the analysis, the value of solar irradiation increases on average by 20%, compared to the analysis without taking them into account in case of building facades, but they do not affect the solar radiation on horizontal roofs situated at the same height.In Figure 8 we can see the distribution of the reflected solar radiation calculated with the algorithm on the facades.On the longest day of the year, 21st June, a large amount of reflected radiation can be observed.On the day of the spring equinox, 20th March, reflected beam radiation is visible from the building with a reflective mirror material.On the shortest day of the year a small amount of reflected radiation can be seen.The developed solution also has a downside.One of the weak points is significant lengthening of the analysis duration when analysing reflections.The algorithm Bi-directional path tracing "Cycles" used for the calculation of the reflections and diffusing of light is slow.It can, however, use computers with a number of multi-core processors.In addition, the cycles algorithm is optimized for efficient handling of graphics cards in Nvidia CUDA technology [16], allowing shortening the analysis time with a suitable graphics card several times.
In case of a one-day analysis, its duration depends on: the total number of pixels in textures of the individual elements (analysis resolution), accuracy of the analysis (number of virtual beams), the step of the analysis and the time scope in which the analysis is performed.Table 1 presents the illustrative representation of the efficiency of the calculations on a quad-core i5 3470 processor 3.2 GHz.The analysis time increases linearly with the analysis step, analysis resolution and time scope.The accuracy of the analysis results from the number of random virtual beans (diffuse bounce samples) generated by the algorithm "cycles".With a small number of beams, the reflection analysis will be distorted.By increasing the number of beams we get a better representation of the natural light.In Figure 9 we can see an example of the difference in generating reflections at settings (A) 100, (B) 5,000 beams per pixel of the resulting image.In the case of a small number of beams, we can see artefacts generated during light reflection.
Comparing the presented algorithm with the applications available on the market some similarities can be noticed.Daysim application is based on backward-ray-tracing algorithm.It is also the algorithm used in rendering.However, it does not allow an analysis of mirror reflections.Diva for Rhino is a complete tool for determining the energy balance of buildings.The algorithm is based on a hybrid deterministic/stochastic (Monte Carlo) ray tracing.It allows the use of materials assigned to analysing surfaces making it possible to conduct analyses taking into account the reflections of light.
Autodesk Ecotec has many features for analysing energy performance of buildings.The author has not found documentation specifying what type of algorithm is used.The surfaces to be analysed are split into smaller equal parts of a predetermined size, or the surface is dashed with points in which the solar radiation is calculated.In the program we have the possibility to define sunlight reflection from the model elements.
In the algorithm "Blend-Sun" presented by the author there are further improvements planned, including adding the ability to load year meteorological data.The next step is to develop an effective calculation of solar irradiation for long time scopes (month, year).Due to the possibility of defining different types of surface textures for the sky dome and operation of the standard HDRI [17] it is planned to more accurately determine the value of diffuse radiation, taking into account circumsolar diffuse and horizon brightening.It is also planned to optimize the script code to work with CityGML data [18], the standard defined for the description and exchange of information on urban infrastructure with the geometry of buildings and descriptive data.In the nearest future it is planned to allow the free access to the script in the form of an addition to the application Blender, together with the necessary detailed documentation.

Conclusion
The main aim of the author was to create a flexible application to be used in analysis of the daily solar irradiation in urban areas.The main purposes included providing a simple solution based on open source applications, able to analyse sun exposure, taking into account light reflection and diffusing.Selecting the solution based on application Blender it was possible to create the tool for this purpose.The algorithm "Blend-Sun" has advanced capabilities of conducting analysis of the direct and diffuse radiation reflections.The resolution of the performed analysis is very flexible, and depends on the resolution of the specified textures.The smallest possible time scope of the analysis is one minute.The possibilities of the presented solution can contribute to a greater popularization of advanced solar irradiation analyses by specialists from various areas of science, who will be able to modify the algorithm code to suit their own purposes.These results are useful for the development of solar dissemination policies, architects and urban planning.

Figure 1 .
Figure 1.The result of the light reflection (A and B) and shading (C and D).
direct beam radiation' = dbr*cos (90°-Ai) (1) In order to estimate the final value of the direct beam radiation we can use the shadow map texture created after rendering.It tells us whether at the given moment the light beam falls on the given element of the model or not.The pixels of the generated texture map in Blender function have the value of 1 in the lack of shadows, and the value of 0 at full shading.All intermediate values indicate the passage of light beams through the semitransparent surface (e.g.Fig. 1C and 1D).Multiplying the values of the texture pixel (in equation used x symbol) by the reduced value of direct beam radiation we receive the value corrected by the shading factor (Eqs. 2).

3 )Figure 2 .
Figure 2. Chart of the reflection of the model light according to the colour of the resulting pixels of the image with the thirddegree polynomial approximation

Figure 3 .
Figure 3. Scheme of the algorithm.

Figure 4 .
Figure 4. Steps of calculating solar radiation: (A) direct beam radiation component, (B) diffuse radiation component, (C) reflected beam radiation component for one day (May 1st )

Figure 5 .Figure 6 .
Figure 5. Steps of calculating solar radiation: (D) reflected diffuse radiation component, (E) model with compass rose, (F) the total result of the analysis for one day (May 1st ).

Figure 7 .
Figure 7. Daily solar irradiation analysis for ground around the building "Walkie-Talkie" on 21st June

Figure 8 .
Figure 8. Reflected solar radiation for three specific days

Figure 9 .
Figure 9.The difference in the application of (A) 100 virtual beam samples per pixel and (B) 5,000 beam samples per pixel of the image.Top view of the test scene.The grey colour shows the reflection of light, the red arrow shows direction of the sunlight

Table 1 .
The analysis of time of the solar irradiation for one day at different algorithm settings