FINAL INDEPENDENT PROJECT
Monte Carlo Simulation for evaluation of view factor between two surface
The objective of the project:
- To develop a MATLAB code for direct determination of view factor between two surfaces using Monte Carlo technique.
- Plot the graph between number ray vs view factor
Geometrical information about the project
Two rectangular shapes 3 m by 2 m parallel surfaces are aligned and separated by 3 m. A 0.5 m diameter hole has been drilled through Surface 2. The hole's center coincides with the rectangle's centre as shown in Figure 1. Using the Monte Carlo approach, calculate the view factor of surface 1 to surface 2.

Figure 1 Front view of schematic diagram.
Monte Carlo Method
The Monte Carlo methodology is a sophisticated simulation approach that may be used to solve a wide range of engineering issues; the method is especially useful when a physical system has many variables and the relationships between these variables are difficult to define using analytical or numerical approaches. The Monte Carlo approach relies on a random number generator to statistically sample variables from a given distribution. The statistical sampling is similar to what happens in games of chance like poker or roulette. The Monte Carlo technique is called after the Monte Carlo Casino in Monaco.
Determination of View Factors with the Monte Carlo Method
The formal definition needs the assessment of a double integral in order to determine a view factor between two surfaces directly quite difficult. Many geometries cannot be integrated analytically and numerous numerical integrations in several dimensions are necessary. The Monte Carlo approach is a strong choice.
The Monte Carlo approach is used in this section to calculate the view factor for the situation depicted in Figure 1. Surfaces 1 and 2 are parallel rectangles in which a hole was inserted and both surfaces have diffuse emitters.
To determine the view factor from surface 1 to surface 2, by the Monte Carlo method, it is necessary to track the ‘rays’ of emitted radiation from surface 1. The emission's direction is chosen at random from a known directional distribution. Each ray is represented as a vector that propagates from a known place on surface 1 in a randomly determined direction. Some of the rays collide with the second surface. The view factor is calculated as the ratio of the number of rays that impact surface 2 to the total number of rays emitted from surface 1; this estimate increases as more and more rays are created and tracked.
The Monte Carlo approach for finding the view factor from surface 1 to surface 2 is summarized as follows:
- Choose the position surface.
- Determine the ray's direction.
- Check the ray from surface 1 hit with surface 2.
The libraries used in the present study are as follows
- Rand- generation of random variables.
- Functions- call a function from various sources in Matlab.
- If… else… statement, While Loop and For loop- For the execution of calculation several times.
- Legend- Used in the plot for identifying the graphical lines
Computer code with explanation
function[hit, xi, yi]=Ray_surf(x, y, a, b, d, D)
% x, y ray from the surface 1
% a, b width and height of the two rectangle surface
% d distance between the two rectangular surface
% D hole diameter in surface 2
% hit ray hits surface 2
% xi, yi the surface point intersection
Ptheta=rand; % random number uniformly distributed
theta=asin(sqrt(Ptheta)); % determine the polar angle
Pphi=rand; % uniformly distributed random number between 0 and 1
phi=Pphi*2*pi; % determine the azimuthal angle
xi=x+d*tan(theta)*cos(phi); % determine the intersection point
yi=y+d*tan(theta)*sin(phi);
if (xi<0) % if conditions for ray hitting surface
hit=0; % ray does not hit the surface
elseif (xi>b)
hit=0; % ray does not hit the surface
elseif (yi<0)
hit=0; % ray does not hit the surface
elseif (yi>a)
hit=0; % ray does not hit the surface
elseif (sqrt((xi-b/2)^2+(yi-a/2)^2)<(D/2)) % circle formula with conditions
hit=0; % ray does not hit the surface
else
hit=1; % ray hit the surface
end;
end
N=[100 500 1000 2000 10000 15000 20000 30000 40000 60000 70000 80000 ] % Number of rays to generate
a=2;% Width of the rectangle
b=3;% Height of the rectangle
d=1;% Distance between the rectangles (m)
D=1;% Diameter of hole in surface 2 (m)
for t=1:10 % iteration
for i=1:length(N)
ray=0; % counter for the number of ray
hits=0; % counter for the number of impingements
while (ray<N(i)) % Loop when N rays have been generated
ray=ray+1; % increment ray counter
%% randomly select a ray origin
x=rand*b;
y=rand*a;
%% see if ray hits surface 2
[hit,xi,yi]=Ray_surf(x,y,a,b,d,D);
if (hit==1)
hits=hits+1; % Ray hits then increment hit counter
end
end
F(i)=hits/ray;%storing view factor for differnt rays
end
plot(N,F,Marker="*",LineWidth=1.5) % graph plotting
xlabel('Number of rays') % name at x-axis
ylabel('View factor') % name at y-axis
hold on
legend('Iteration 1',' Iteration 2','Iteration 3','Iteration 4','Iteration 5','Iteration 6','Iteration 7','Iteration 8','Iteration 9','Iteration 10')
end
The output is plotted results between the number of rays’ vs view factor
The solution obtained using the Monte Carlo techniques for solving gray surface problems is shown in Figure 1 and it is noticed that the Monte Carlo technique converges to the deterministic solution as N increases. Further, it is observed that the view factor is found to be 38 % after 10 iterations. This indicates that radiation transferred from surface 1 hit surface 2 with 38 % of radiation, for instance, when the surface 1 has 1000 W of energy it can transfer 380 W to surface 2

Figure 2 illustrate the view factor for different rays