Home > utilities > turbine_area_sigma.m

turbine_area_sigma

PURPOSE ^

Calculate the fraction of the rotor swept area is occupying each sigma layer

SYNOPSIS ^

function sigma_frac = turbine_area_sigma(H, Ht, r, sigLay, plot_fig, subplot_info)

DESCRIPTION ^

 Calculate the fraction of the rotor swept area is occupying each sigma layer

 Example Usage:

 sigma_frac = turbine_area_sigma(H, Ht, r, sigLay, plot_fig, subplot_info)

 Input Parameters:     H  - mean sea level (m)
                       Ht - height of turbine hub above seabed (m)
                       r  - turbine rotor radius (m)
                       sigLay - number of sigma layers (not levels) in the model
                       plot_fig - optional; flag to plot a figure
                       subplot_info - optional; if present should be an
                       array containing the three parameters to subplot
                       that should be used to put the figure into a
                       subplot.

 Rory O'Hara Murray, 19-Nov-2014
 Simon Waldman, 2016.

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 % Calculate the fraction of the rotor swept area is occupying each sigma layer
0002 %
0003 % Example Usage:
0004 %
0005 % sigma_frac = turbine_area_sigma(H, Ht, r, sigLay, plot_fig, subplot_info)
0006 %
0007 % Input Parameters:     H  - mean sea level (m)
0008 %                       Ht - height of turbine hub above seabed (m)
0009 %                       r  - turbine rotor radius (m)
0010 %                       sigLay - number of sigma layers (not levels) in the model
0011 %                       plot_fig - optional; flag to plot a figure
0012 %                       subplot_info - optional; if present should be an
0013 %                       array containing the three parameters to subplot
0014 %                       that should be used to put the figure into a
0015 %                       subplot.
0016 %
0017 % Rory O'Hara Murray, 19-Nov-2014
0018 % Simon Waldman, 2016.
0019 %
0020 function sigma_frac = turbine_area_sigma(H, Ht, r, sigLay, plot_fig, subplot_info)
0021 
0022 assert(nargin >= 4, 'Not enough arguments.');
0023 assert(isnumeric(sigLay) && sigLay - fix(sigLay) < eps, 'sigLay (4th parameter) must be an integer number of sigma layers.');
0024 
0025 if nargin<5
0026     plot_fig = false;
0027 end
0028 if nargin<6
0029     splot = false;
0030 else
0031     splot = true;
0032 end
0033 
0034 dT = H - Ht; % turbine hub depth
0035 
0036 assert(dT>r, 'Turbine will stick out of water');
0037 
0038 dLay = H./sigLay;
0039 zLev = [0:-dLay:-H]';
0040 
0041 % what sigma layer is the hub in?
0042 drsl = zLev+dT; % depth of hub relative to each sigma level
0043 hub_sigma = sum(drsl>=0);
0044 
0045 %% draw sigma levels / layers
0046 if plot_fig
0047     if splot
0048         subplot( subplot_info(1), subplot_info(2), subplot_info(3) )
0049     else
0050         figure
0051     end
0052     plot([-r r], zLev*[1 1])
0053     xlabel('Distance (m)')
0054     ylabel('Depth (m)')
0055     title([num2str(H, '%2.0f') ' m water depth'])
0056     
0057     % draw rotor area
0058     a=0;
0059     b=-dT;
0060     ang = 0:pi/20:2*pi;
0061     x=r*cos(ang);
0062     y=r*sin(ang);
0063     hold on
0064     plot(a+x,b+y, a, b, 'o')
0065 end
0066 %% what fraction of the rotor area is in each sigma layer?
0067 
0068 % loop trough all segments below the hub
0069 dBot=-drsl(-drsl>=0);% the minimum of this array is hub height above a sigma level
0070 numBot=sum(dBot<=r);
0071 segmentsBotCum = [];
0072 for ii=1:numBot
0073     phi = acos(dBot(ii)/r);
0074     sector = phi*r*r;
0075     triBot(ii) = r*sin(phi)*dBot(ii);
0076     segmentsBotCum(ii) = sector-triBot(ii);
0077 end
0078 
0079 % loop through all the segments above the hub
0080 dTop=flip(drsl(drsl>=0));
0081 numTop=sum(dTop<=r);
0082 segmentsTopCum = [];
0083 for ii=1:numTop
0084     phi = acos(dTop(ii)/r);
0085     sector = phi*r*r;
0086     triTop(ii) = r*sin(phi)*dTop(ii);
0087     segmentsTopCum(ii) = sector-triTop(ii);
0088 end
0089 
0090 
0091 segmentsTopCum2 = flip(segmentsTopCum);
0092 segmentsTop = segmentsTopCum2-[0 segmentsTopCum2(1:end-1)];
0093 segmentsBot = segmentsBotCum-[segmentsBotCum(2:end) 0];
0094 
0095 % check that there are segments below/above hub, i.e. whether the rotors
0096 % actually span multiple sigma layers
0097 % sig_cent is area of the rotors in the layer the hub is in
0098 if numTop>0 & numBot>0
0099     sigCent = pi*r*r-segmentsTopCum(1)-segmentsBotCum(1);   
0100 elseif numTop==0 & numBot>0
0101     sigCent = pi*r*r-segmentsBotCum(1);
0102 elseif numTop>0 & numBot==0
0103     sigCent = pi*r*r-segmentsTopCum(1);
0104 elseif numTop==0 & numBot==0 % entire rotor is confined to one sigma layer
0105     sigCent = pi*r*r;   
0106 end
0107     
0108 % if sigCent is zero then the hub must exactely co-inside with a sigma
0109 % level (unusual...) check it's larger than a very small area (or zero)
0110 if sigCent>0
0111     % if hub co-insides exactely with a sigma level
0112     segments = [segmentsTop sigCent segmentsBot];
0113     segments_frac = segments./(pi*r*r);
0114     sig_span = hub_sigma + [-length(segmentsTop) length(segmentsBot)];
0115     numSigma = numTop+numBot+1; % total number of occupied sigma layers
0116 else
0117     segments = [segmentsTop segmentsBot];
0118     segments_frac = segments./(pi*r*r);
0119     sig_span = hub_sigma + [-length(segmentsTop) length(segmentsBot)-1];
0120     numSigma = numTop+numBot; % total number of occupied sigma layers
0121 end
0122 
0123 % work out the fraction of the turbine area in each sigma layer
0124 sigma_frac = zeros(1,sigLay);
0125 sigma_frac(sig_span(1):sig_span(2)) = segments_frac;
0126 
0127 total_frac = sum(sigma_frac);
0128

Generated on Wed 20-Feb-2019 16:06:01 by m2html © 2005