# Calculation of View Factors for Building Simulations with an Open-Source Raytracing Tool
## 2 RADIANCE: Theoretical Basis and General Calculation Methodology
### Calculating View Factors  
As per its user-manual, _rcontrib_ computes \"contribution coefficients in a RADIANCE scene\" [25]. The term \"scene\" collectively refers to the geometry and material properties of all the surfaces that are being considered in the calculation. Assuming every surface in the scene to be of equal radiance, at any point in the scene the \"contribution coefficient\" from a particular surface relates to the fraction of radiant energy received from it. _Rontrib_ permits the calculation of both radiance and irradiance coefficients through different input parameters. As documented in [25], these coefficients typically relate to radiant flux transfer between sky and ground or optical systems such as light pipes and shading systems. The specificity of input parameters in each instance depends on the type of coefficient, material properties of the surfaces and the complexity of geometry. To calculate view factors, a hitherto undocumented application, _rcontrib_ needs to be invoked in the irradiance (-I) mode with a single ambient bounce (-ab 1). The resultant direct \"contribution coefficient\" of a finite distant surface \(A_{1}\) at a given differential surface \(dA_{1}\) is its view factor multiplied by \(\pi\). This is syntactically expressed and illustrated in Figure 3.  
As shown in Figure 3a, the differential surface \(dA_{1}\) is specified by the cartesian coordinates \((x_{1},y_{1},z_{1})\) and direction vector \((vx_{1},vy_{1},vz_{1})\). The green dots on the surface indicate Monte Carlo sampling which is controlled by the parameter N for ambient divisions (-ad) and limit weight (-lw) as shown in Figure 3b. The parameter for ambient bounces needs to be retained to its default value of one to ensure that no diffuse interreflection between surfaces is considered. For standard _rcontrib_ simulations relating to electric lights and daylight, the ambient bounces are usually set to four and higher. The syntax for the command is shown in Figure 3c. The process of calculating view factors can be explained in the following steps:  
1. For a given infinitesimal area \(dA_{1}\), N rays are stochastically mapped over a hemispherical basis as shown in Figure 4. The approach for randomly mapping these rays is based on the methodology proposed by [PERSON] and [PERSON] [26]. For the random sampling to converge, such that the results from two independent ray tracing processes are numerically within a tolerance range of less than 1%, a large number of samples is required. Figure 3: Calculation of view factor between a differential surface and a finite surface with _rcontrib_. The dots on the finite surface in (**a**) indicate the sampling controlled by the -ad parameter. As shown by (**b**), increased sampling will improve the estimation of the view factor. An explanation of the terms in the syntax (**c**) is provided in the nomenclature. 2. For each ray that strikes the geometry of the surface(s) identified through \"surfaceIdentifier\", a contribution is added. The contribution of a single ray will be equal to \(\pi\)/N, where the presence of the value of \(\pi\) is owing to the use of irradiance integral. 3. The sum of all ray contributions to the surface identified through the surface identifier constitutes the fraction of the total hemispherical basis viewed by the infinitesimal area. This fraction constitutes an approximation of the view factor. As explained through Figure 3c, the output generated through RADIANCE is the approximate view factor multiplied by a factor of \(\pi\). The process outlined in the above steps is the basis of all view factor calculations discussed in this paper. The mathematical basis for this calculation can be expressed by Equation (5), where the term \(E_{ind}\) denotes indirect-irradiance. The other terms have the same interpretation as in Equation (4).