can someone assist I am struggling to convert the DHI DNI and GHI from W/m^2 to kWh/m^2
10 views (last 30 days)
Show older comments
% solar irradiation on a HORIZONTAL SURFACE
Cn = 0.7; % Clearance index
I0 = 1353; % Solar constant
latitude = -34.005133; % Latitude of the location
days =1; % Number of days in the month
hours = 24; % Number of hours in a day
% Initialize matrices to store results
dec_deg = zeros(days, 1); % Declination angles in degrees
DNI = zeros(days, hours); % Direct Normal Irradiation
DHI = zeros(days, hours); % Diffuse Horizontal Irradiance
GHI = zeros(days, hours); % Global Horizontal Irradiance
for n = 1:days
% Calculate declination angle for the day (in degrees)
dec_deg(n) = 23.45 * sind((360/365) * (n + 284));
% Convert declination angle from degrees to radians
dec_rad = deg2rad(dec_deg(n));
for time = 1:hours
% Calculate hour angle
h = (12 - time) * 15; % Hour angle in degrees
h_rad = deg2rad(h); % Hour angle in radians
% Calculate diffuse factor (Cs)
Cs = 0.095 + 0.04 * sin(deg2rad(360/365) * (n - 100));
% Calculate extraterrestrial solar irradiation (I)
I = I0 * (1 + 0.034 * cos(deg2rad(360 * n / 365.25)));
% Calculate atmospheric optical depth (k)
k = 0.174 + 0.035 * sin(deg2rad((360/365) * (n - 100)));
% Calculate solar altitude angle (alt)
Lat = deg2rad(latitude); % Latitude angle in radians
alt = asin(cos(Lat) * cos(dec_rad) * cos(h_rad) + (sin(Lat) * sin(dec_rad)));
alt_deg = rad2deg(alt); % Daily Solar Altitude Angle
% Ensure the solar altitude angle is non-negative
if alt_deg < 0
alt_deg = 0;
end
% Calculate air mass (AM)
AM = 1 / sin(deg2rad(alt_deg)); % Air Mass
% Calculate Direct Normal Irradiation (DNI) for the current hour
DNI(n, time) = Cn * I * exp(-k * AM);
% Calculate Diffuse Horizontal Irradiance (DHI) for the current hour
DHI(n, time) = Cs * DNI(n, time);
% Calculate Global Horizontal Irradiance (GHI) for the current hour
GHI(n, time) = (DNI(n, time) + DHI(n, time)) ; % Convert to W/m^2
end
end
% Display matrices
disp("Direct Normal Irradiation (DNI) for 1 day (24 hours each): ");
disp(DNI)
disp("Diffuse Horizontal Irradiance (DHI) for 1 day (24 hours each): ");
disp(DHI)
disp("Global Horizontal Irradiance (GHI) for 1 day (24 hours each): ");
disp(GHI)
% Sum up the values in DNI and DHI matrices (which are 1x1 matrices)
sum_DNI = sum(DNI(:))
sum_DHI = sum(DHI(:))
GHI_per_year = (sum_DNI + sum_DHI)
0 Comments
Answers (1)
VBBV
on 14 Mar 2024
% solar irradiation on a HORIZONTAL SURFACE
Cn = 0.7; % Clearance index
I0 = 1353; % Solar constant
latitude = -34.005133; % Latitude of the location
days =1; % Number of days in the month
hours = 24; % Number of hours in a day
% Initialize matrices to store results
dec_deg = zeros(days, 1); % Declination angles in degrees
DNI = zeros(days, hours); % Direct Normal Irradiation
DHI = zeros(days, hours); % Diffuse Horizontal Irradiance
GHI = zeros(days, hours); % Global Horizontal Irradiance
for n = 1:days
% Calculate declination angle for the day (in degrees)
dec_deg(n) = 23.45 * sind((360/365) * (n + 284));
% Convert declination angle from degrees to radians
dec_rad = deg2rad(dec_deg(n));
for time = 1:hours
% Calculate hour angle
h = (12 - time) * 15; % Hour angle in degrees
h_rad = deg2rad(h); % Hour angle in radians
% Calculate diffuse factor (Cs)
Cs = 0.095 + 0.04 * sin(deg2rad(360/365) * (n - 100));
% Calculate extraterrestrial solar irradiation (I)
I = I0 * (1 + 0.034 * cos(deg2rad(360 * n / 365.25)));
% Calculate atmospheric optical depth (k)
k = 0.174 + 0.035 * sin(deg2rad((360/365) * (n - 100)));
% Calculate solar altitude angle (alt)
Lat = deg2rad(latitude); % Latitude angle in radians
alt = asin(cos(Lat) * cos(dec_rad) * cos(h_rad) + (sin(Lat) * sin(dec_rad)));
alt_deg = rad2deg(alt); % Daily Solar Altitude Angle
% Ensure the solar altitude angle is non-negative
if alt_deg < 0
alt_deg = 0;
end
% Calculate air mass (AM)
AM = 1 / sin(deg2rad(alt_deg)); % Air Mass
% Calculate Direct Normal Irradiation (DNI) for the current hour
DNI(n, time) = Cn * I * exp(-k * AM);
% Calculate Diffuse Horizontal Irradiance (DHI) for the current hour
DHI(n, time) = Cs * DNI(n, time);
% Calculate Global Horizontal Irradiance (GHI) for the current hour
GHI(n, time) = (DNI(n, time) + DHI(n, time)) ; % Convert to W/m^2
end
end
% Display matrices
disp("Direct Normal Irradiation (DNI) for 1 day (24 hours each): ");
disp(DNI)
disp("Diffuse Horizontal Irradiance (DHI) for 1 day (24 hours each): ");
disp(DHI)
disp("Global Horizontal Irradiance (GHI) for 1 day (24 hours each): ");
disp(GHI)
% Sum up the values in DNI and DHI matrices (which are 1x1 matrices)
sum_DNI = sum(DNI(:))/(24*1000) % in kWh/m^2
sum_DHI = sum(DHI(:))/(24*1000) % in kWh/m^2
GHI_per_year = (sum_DNI + sum_DHI)% in kWh/m^2
1 Comment
See Also
Categories
Find more on Language Fundamentals in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!