-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSuccessive_Approximation.m
More file actions
60 lines (47 loc) · 2.21 KB
/
Successive_Approximation.m
File metadata and controls
60 lines (47 loc) · 2.21 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
% User input
enclosingWidth = input('Enter width: ');
enclosingHeight = input('Enter height: ');
percentageUnprotected = (input('Enter percentage of unprotected area: '))/100;
raditionIntensity = 84; %kW/m^2, manually input for now, 168 normal load, 84 reduced load
% View Factor Calculation
recalculatedRadiationIntensity = raditionIntensity * percentageUnprotected;
criticalRadiationIntensity = 12.6; %kW/m^2, compatibility for more will be added later
targetViewFactor = criticalRadiationIntensity / recalculatedRadiationIntensity;
disp(class(targetViewFactor));
% Final bonudary distance result
separationResult = separationDistanceCalculation(enclosingWidth, enclosingHeight, targetViewFactor);
boundaryDistance = separationResult/2;
% Printing results
fprintf('Minimum separation distance is %.*f m \n',3 , separationResult);
fprintf('The boundary distance is %.*f m ',3 , boundaryDistance);
function output = separationDistanceCalculation(a, b, c)
% Initial Variables
enclosingWidth = a;
enclosingHeight = b;
viewFactor = 0;
targetViewFactor = round(c, 4);
separationDistance = 0;
% While loop failsafe
maxIterationCount = 50000;
iterationCount = 0;
% Calculating correct separation distance
% Rounds the calculated view factor to 4d.p to check if it is the correct
% distance. Also contains the loop failsafe to ensure there is no infinite
% loop occuring.
while round(viewFactor, 4) ~= targetViewFactor && iterationCount < maxIterationCount
% Neccessary calculations for view factor equiation
X = enclosingWidth/(2*separationDistance);
Y = enclosingHeight/(2*separationDistance);
% View Factor equation
viewFactor = (2/pi)*((X/sqrt(1+X*X))*atan(Y/sqrt(1+X*X))+(Y/sqrt(1+Y*Y))*atan(X/sqrt(1+Y*Y)));
% Increases separation distance and count for each iteration
separationDistance = separationDistance + 0.001;
iterationCount = iterationCount + 1;
% Displays relevant values for each iteration
% disp(iterationCount);
% disp(viewFactor);
% disp(separationDistance);
end
output = separationDistance;
disp('Complete')
end